Xcode: copying static library target to new project - xcode

I am trying to use the objective-c API provided by Google for Youtube using this link.
The project provided has a target for creating a static library. The documentation asks to copy the target into my project instead of the static library it produces.
The library project includes a target for building a static library for iOS apps. The static library target should be dragged into your application project's Build Phases "Link Binary with Libraries" list.
I am not able to do this. Is this what I am supposed to drag?
Since I could not find a way to drag the target, I went to the derived data folder and copied static library into the project. It worked but only partially. Can someone tell me what I am doing wrong?

no you should drag library from left side (Project Navigator).
But in bottom of (Link Binary with Libraries) section presents + and - buttons that do the same functionality as dragging, so you also can add library with plus button
Also if you build this lib from source don't remember add it to Target Dependency section

Related

Can't find JavaScriptCore.framework in Xcode link libaries

I am trying to link the JavaScriptCore.framework since you have to do it manually as of React Native 0.58. I tried following the steps to "Link Binary With Libraries" but did not find any frameworks in the dropdown that appears. Do you know what setting I need to set for this to populate? I know on other projects (workspace for React Native), it automatically appears.
You can find it from the path below.
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/JavaScriptCore.framework

How to use System.Security.Cryptography in Xamarin.Forms PCL

By reference to this link https://developer.xamarin.com/api/namespace/System.Security.Cryptography/
May I know how do I include this in my Xamarim.Forms PCL project? When I include in, Visual Studio is giving error as the picture below
May I know if anybody has any idea how to solve this? Thanks.
The namespace is available both in Xamarin.iOS and Xamarin.Android. You could make platform specific implementations for both platforms and then resolve them with the DependencyService
You would have your interface for whatever you need in your PCL
public interface ICryptoService // or whatever
{
string Cipher(string stringToCipher);
string Decipher(string stringToDecipher);
}
and then implement these in your platform specific projects
using System.Security.Cryptography;
namespace MyApp.Droid
{
public class CryptoService : ICryptoService
{
// implement interface
}
}
To make the implementation visible to DependencyService you have to use the DependencyAttribute
[assembly: Xamarin.Forms.Dependency(typeof(MyApp.Droid.CryptoService)]
You can now obtain an instance in your PCL with
var cryptoService = DependencyService.Get<ICryptoService>();
and then use it. The steps for iOS are basically the same. For UWP you have to register the implementation manually, see here.
Edit:
Since it's likely that the implementation will be the same for all platforms, you could introduce a shared project and put the implementation there. All you have to do now is referencing the shared project from your iOS and Android projects.
Edit 2:
Adding a shared project to an existing Xamarin.Forms solution is quite easy. Just right-click your solution in VS, choose Add -> New Project... (I only have a german localized VS at hand at the moment, but it should be something in the lines of that). Now select Shared Project, give it a name and click OK, there will be a new shared project in your solution.
Now right-click your platform specific project and choose Add -> Reference.... The window to add a reference should open and on the left you can choose the source of the reference (Assemblys, Projects, Shared Projects, COM and Browse). Select Shared Project and then the project you just created. Any code file in your shared project will now be compiled with your platform specific project as if the code file was in the platform specific project (watch for namespaces!). Repeat for the other platform specific projects.

Installation process of Gzip framework in Swift

How to install the Gzip framework in swift 3.0.1 and also how to use it in swift 3 and iOS 10.
For This actually they given the following instructions like
1.Build Gzip framework.
2.In Build Phases, add Gzip.framework library to your project.
3.import Gzip in your Swift file.
4.Use in your code.
But among all steps How to implement the 1st step like building the Gzip framework.
Thanks in advance.
1.For the solution, Just download the project from the GitHub and then open it.
2.Now in the project navigator panel expand the folder named "product".
3.In that folder beneath you can see the Gzip.framework in red color, on that you right click in order to see it in the Finder.
4.From that Finder location, you just drag and drop into your project.
5.In General tab under linker and binaries you add the framework.
6.And finally import the header module like "import GZip"for required class and then implement the required things.

How to add js file to my xcode project?

I add some js and css files in my xcode left project tree. but when I build this project , I got the warning : no rule to process file '$(PROJECT_DIR)/js/builder.js' of type sourcecode.javascript for architecture i386
I think if I lost some setting with my project in xcode , but How to add some like js and css files? Thank you very much!
When you add the JavaScript file, Xcode detects that the file is a source code file, assumes you want to compile it and automatically adds it to the Compile Sources build phase.
To stop Xcode trying to compile it and make it copy the file instead, expand your target in the Groups and Files list, remove the JavaScript file from the Compile Sources build phase and add it to the Copy Bundle Resources build phase.
For Xcode 4, click on the main project, click on Build Phases. Open up Compile Sources and Copy Bundle Resources then you can then simply drag the files from one to the other.
I got the same problem and I could solve this problem with simple technique in Xcode5. when you add/drag your HTML files into Xcode bundle you need add them by grouping as 2 types
1.assets
2.index.html
you need to add these two files only.
assets folder contains all HTML files like images,.js, content,css. All HTML files should be
included in assets folder. what I mean is you need to group all HTML files in assets folder as a single folder.
Then you drag that particular folder which contains ASSETS and INDEX.HTML files into Xcode bundle.
Then do some changes in your controller declaration and implementation sections. That's it you can run your application in simulator now.If any one have not understood my answer please let me know I will add clear information with screen shots.
I hope it will help some one..Thank you!
If anyone have any doubts still let me know i'll explain step by step

how to call the c static library in a cocoa app?

I have two projects, a Cocoa application and a static c library which it uses.
Then didn't in the same folder.For example:the name of c static library is libXXX.a,it in the XXXcore folder.the cocoa application in another folder that is the same level with the XXXcore folder. When I try to compile the cocoa application,I have the link error result.It is seem to change the search path in the cocoa app info(General panel).But it is not work,why?
If you're using Xcode, you can add a link to static library by adding the library to Frameworks folder in the project.
ok. I have the answer:
add the .a library to your cocoa project
edit the path of Header Search paths and Library Search paths in the project info panel(build panel)
don't forget the copy option while adding the library to your project.
Thanks Mehrdad Afshari for your help!

Resources