I have made a static library after going through http://www.icodeblog.com/2011/04/07/creating-static-libraries-for-ios/. To test this library i made a new project and drag the static library on to the project and tried to test its one method. But it is giving me the error " "_OBJC_CLASS_$_MyLib", referenced from:". MyLib is the name of the library i created.
Steps i took in creating static library. 1. Created a new Xcode project. 2. Choose option to create cocoa touch static library. 3. Wrote two functions in MyLib.h and wrote the implementations one for fibonacci series and other for generating factorial of a number. 3. Built the project and write click on the MyLib.a file with the portion to reveal in finder. 4. Drag MyLib.a file and MyLib.h in a new folder called MyLib.
Any help please
When building libraries, frameworks or applications for iOS, XCode will only compile object code for the architectures specified in the build settings for the target. XCode will also only link to binaries that have the specified architecture built in.
In XCode if you select your target you can see under the build settings tab, the architecture for your target. It will contain values like arm6, arm7, and i386.
When running code in the iOS simulator you are running your code on your desktop which is the i386 architecture.
When running on the device the binary has "slices" which are built for that architecture. If the correct architecture "slice" is not present in the binary, it will not run.
If you get the missing i386 architecture error running an iOS application in the simluator you need to make sure that your application and all its dependent libraries have been built for i386 architecture.
Also check that "build active architecture only" is set to NO in the build settings for the target.
If you cant rebuild dependent libraries because you dont have the source, you will have to test on a device supporting arm6 or arm7 architecture.
I had the exact same problem and was finally able to get it working in Xcode 4.5 and iOS 6 when I read the answer on this thread. The answer by @idz works well but its not ideal that you have to include the library's project in your app's project and then set it as a dependency.
Steps 1-8 are very simple and explicit. You also need to ensure that the header search paths project setting is accurate. Good luck!
XCode 4.3: Static Library Generation
I had same Problem when i tried to add a c header in cpp file like below
After a long struggling period I learnt that to import c header in cpp file you need to do this:
and my problem was solved.