5

I can't figure out how to create a cocoa touch static library in Xcode 4.

I've created static library in Xcode 3 and it worked fine. I used this tutorial. Thanks for the help.

First step I create cocoa touch static library

enter image description here

Next we can see our static library in product directory. But now this uncompiled library.

enter image description here

Next step I add some objective-c class. This class is will perform various actions, for example show NSLog messages.

enter image description here

Then I made sure there is this class exist in compile source

enter image description here

After that I build my target

enter image description here

Now I use this static library in other projects, but when I use it I get a error when linking files with my static library.

5
  • 1
    You didn't specify the problem you are facing!
    – Ravi
    Sep 15, 2011 at 17:06
  • create a static library in the XCode3 and XCode4 are different - this is my problem Sep 15, 2011 at 17:21
  • Different, but how different?
    – gcamp
    Sep 15, 2011 at 19:01
  • when i use xcode 3 for creating static library i follow next step: - first i add new target and choice 'cocoa touch' -> 'static library' - next after adding library i drag into compiling sources my class .m - next i build my static library Sep 16, 2011 at 9:53
  • but I do not know how to repeat these steps in the XСode 4 Sep 16, 2011 at 9:54

3 Answers 3

1

Open Xcode > Create New Project > iOS > Framework & Library > Cocoa Touch Static Library

6
  • I did as you wrote. Then I created a few classes and do build my library. After that I drag my build library and header classes into my other project. When I import header and call some method in my static library and after run i get error: ld: warning: ignoring file /Users/dev01/Desktop/libLiba.a, missing required architecture i386 in file Undefined symbols for architecture i386: "_OBJC_CLASS_$_MyClass", referenced from: objc-class-ref in new2AppDelegate.o ld: symbol(s) not found for architecture i386 collect2: ld returned 1 exit status Sep 16, 2011 at 10:28
  • What is /Users/dev01/Desktop/libLiba.a?
    – edc1591
    Sep 16, 2011 at 21:06
  • I changed my post. Now I have described my steps to create a static library. Sep 19, 2011 at 9:31
  • 2
    Do you get that error when you compile the project for the simulator or for an actual device? The fact that it says architecture i386 is missing sounds like your compiling your new project for the simulator, but the static library is compiled for the device.
    – edc1591
    Sep 19, 2011 at 14:16
  • Yes, I realized the error, it really is that as you write. i build my static lib for iOS Device and Run it on simulator. You know how to make a library for simulator and device? Sep 27, 2011 at 8:17
1

I struggled with this myself and, on another SO thread, found this:

iOS-Universal-Framework

0

To create an static library you can try to figure out with example example here: http://www.raywenderlich.com/41377/creating-a-static-library-in-ios-tutorial

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.