0

Hi guys I'm having a bit of trouble creating a static library in xcode 5. Most of the tutorials out there are done in xcode 4 and thanks to apples incredibly easy to use gui, that makes it so easy for users to transition from one program to another, so I haven't been able to make one and use it. So I get that the first step is to make the cocoa ios static library project and then to add the header and implementation files (.h and .m) that you want in your library. Next you supposed to set the header files that you want to be accessible by the user. Is it possible to set up the library in such a way that importing one header file also imports all of the other header files? Do the other header files need to be public to do this? My main problem is how do I actually set the classes which I want to be public/private and finally how do I implement this library into one of my applications? A HelloWorldLibrary example would be great!


After using the link: github.com/jverkoey/iOS-Framework

I am now having a problem with the locating of the Framework:

ld: warning: directory not found for option '-L/Users/Harry/Library/Developer/Xcode/DerivedData/SampleFramework-efznryzmlxnimoaaazjfbqjirzxq/Build/Products/Debug-iphoneos'
ld: framework not found SampleSubproject

enter image description here

4
  • 1
    github.com/jverkoey/iOS-Framework Commented Aug 5, 2014 at 12:20
  • If all other headers will be imported from one public header - you will not need to make them public Commented Aug 5, 2014 at 12:55
  • Thanks for the link rdurand. I'm going to try it out and I'll post back here with my results Commented Aug 5, 2014 at 13:18
  • I'm now getting a problem when using my test framework. ld: framework not found SampleFramework Commented Aug 5, 2014 at 15:18

1 Answer 1

1

There are steps to create static library.

I have not created in xCode 5, but have created in 4.x..

  • Create new project and select Cocoa touch static library under iOS.
  • Add Class files/Resources to your created project.
  • Set Installation Build Products Location to $(BUILT_PRODUCTS_DIR)
  • Copy headers in Build Phases
  • Set headers to Public in Target Membership
  • Build for Archiving/Profiling
  • got it from derived data (Release iphonesimulator, Release-iphoneos)
  • now merge both .a files using

lipo command from terminal like lipo -create libForDevice.a libForSimulator.a -output UniversalLib.a

  • Now copy this lib to your main xCode project and include your perticular class.

You can find more details from here

Regards.

Sign up to request clarification or add additional context in comments.

4 Comments

Why is it necessary to manually use lipo? I don't believe it is. If you create an Xcode Workspace and make the static library project a dependency of the app project then it will always build for the correct arch and there is no copying involved.
Can use Aggregate. xCode will build multiple targets at once, including command-line scripts using Aggregate.. And is required because making universal build of static library (Device/Simulator) For you info, I am giving basic tips so it can be implemented easily my friend...
github.com/jverkoey/iOS-Framework demostrates creating an aggregate target which doesn't require the use of lipo in the terminal iKing! :)
@koplocal : jverkoey's project setup uses the lipo command in the post-build script ;)

Your Answer

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