I have created a custom universal framework by following this tutorial
tutorial.
Here My question is how to import a static library .a files into framework.??
Thanks in advance.
Just drag and drop the .a file into your frameworks folder.
Or you can go to Build Phases -> Link Binary With Libraries -> Click on the '+' sign -> Add Other (bottom left) -> choose your .a and click Add
Make sure to include the header files of your static library in your new project as well.
In my custom framework project setup I have added the static library which I have created to link binary with libraries and I have added the static library header files to Aggregate target copy files build phase. thats it builded like charm. and that framework is working fine.
Related
I have a library that I'd like to use in a Cocoa project, (specifically vgmstream).
To use this, is it as simple as dragging the necessary files into Xcode? Or would I have to build or bundle it in some way in order to use it?
If you have built static/shared libraries and the header files, you can easily drag them into the project. Otherwise, you'd have to build the libraries your self, or drag in all the source files to the project.
The so called framework that Xcode uses, is just a folder with .framework extension containing a Headers folder and a static library with it's name the same as the folder name without extension.
When I'm working on an Android app, I can control+click on a function call in editor to navigate to the function source. This works well for classes in the project and classes in Android SDK. However, if I control click on a function call that is from an Android Support Library (say: android-support-v13.jar), I'm taken to a file that has the function signature but the contents say "compiled code".
I tried adding the path to the support library's source to Project Structure->Sources but looks like that didn't make any difference.
How do I set this up right.
Navigate to Project Structure | Libraries
If you haven't already, create a library and add the android-support-v13.jar
In the same library, click "Attach Files or Directories..." and select the Android Support Library's src directory (<android-sdk>\extras\android\support\v13\src)
Add this library as a project dependency
Your library should look something like this:
I've done a some looking around but most of the answers I've found have been or felt incomplete and have left me a little confused. I have been given a C Library that I need to compile into a static library using XCode 4.3 and then use in a separate iOS app project, but I'm unsure about how to proceed. I'm not sure if the directory structure matters or not, but here it is anyways:
Library -> Section1 -> src -> .c files
-> sec1 -> .h files
-> sec1.h
-> Section2 -> src -> .c files
-> sec2 -> .h files
-> sec2.h
I've been trying to work from this: http://blog.stormyprods.com/2008/11/using-static-libraries-with-iphone-sdk.html which was linked in a question similar to this one though being from 2008 its fairly out of date, nor could I get it to work. There is also this question: Including external C library with Xcode but it doesn't go into the details of actually generating the library, before then including in a separate project.
If someone could provide a clear and up-to-date answer I, and many others, would very much appreciate it I'm sure. Let me know if any more information is needed!
To build the static library:
Create a static library project in Xcode
Add all the .c and .h file to the project
Compile
The easiest way to use this library is then to add this static library project to you application project. This avoids having to worry about creating fat libraries (i.e. libraries with code for both the simulator and device).
To add the static library project to your application project:
Choose File > Add Files to ""...
Add the .xcodeproj for your static library
Click on your app's .xcodeproj in the Project Navigator to show build options
Click on your app's target and choose the "Build Phases" tab.
Expand the "Link With Binaries Section"
Click the '+' button
Expand the "Workspace" section (you should see your library, a .a file, there)
Click on your library and you should be good to go.
Apologies for excruciating level of detail above, but somehow people always seem to forget to do steps 4-8 and then they wonder why they are getting link errors!
Xcode will not be able to find the headers for your library. You can either add the public headers to your project as you would any other header file or set the "Header Search Paths" in your build settings.
Try the Universal Framework project, as seen on github: https://github.com/kstenerud/iOS-Universal-Framework/. I have used this extensively, and it works nicely. You just create a new XCode project for that library, put in all the source and header files, and it will build a static Framework. That you can use in other projects, and you also don't have to worry about the header search paths.
I have two projects that are build on 2 different compilers. I need to combine both into one single app. Found out from a source that it is possible to compile any one of the project into a library and add it into the other to use it.
I fairly new this concept. Has any one done anything like this? How do i convert one of the project into a library and how would i connect the two? Will i still able to call the views in that project(library) in my other project? I am using XCODE 4.2 and iOS 5.
Create a "Cocoa Touch Static Library" to build your "Project"/target, and include the then-built library (with its public headers) into the second one. Note that the details depend quite a bit on what you mean by "project" and by "call the views" (which looks a bit wrong).
If you have two existing projects (with .xcodeproj files), open the "app" project (guessing one is of such kind), and include the lib project inside it (by drag & drop, or by "Add Files..."). Not the opposite.
Then in the "Build Phases" of the app project, you can add your "lib" project as a target dependencies (making your lib to always build when building your app). Finally, add the lib project product (the .a) in the "Link" build phases of the "app" project.
I built a static library with MGTwitterEngine and some OAuth / TouchJSon libs.
Then I added that within the main XCode proj of an app.
I'm having trouble with this feature of XCode (build and archive). After I added the libs, the "build and archive" no longer generates a .IPA
Do you know a good tutorial to make some proper use of this archive feature ?
What should I do within the XCode Projet to make sure it will work correctly with my static libs ?
ps: The second is the most important to me.
Thanks in advance ;)
You should change your static library's "Build Settings", make sure Skip Install is set to YES
If still not work, check your static library's "Build Phases", make sure:
After that, your Archive should be OK.
But if your Xcode start to report who can not find your static library's .h files, you can just add them into your project as references, or change your project's "Build Settings", let it find your .h files in your static library's folder.
According to the Apple engineers, you should not use the "Copy Headers" build phase with static libraries on iOS - it's only intended for dynamic libraries (oddly using "Copy Headers" works fine for most cases, but definitely breaks the 'Archive' case).
Instead add a "Copy Files" build phase, setup like this:
If you are using the static libraries template, this build phase should already be present.
Drag all the header files that should be exposed into this section.
You also need to see "Skip Install" for the library to yes as other people have answered.
The video for WWDC 2012 Seassion 408 "Working with Schemes and Projects in Xcode" covers this from timestamp 45:18.