How to create framework from Xcode 4 project?

北战南征 提交于 2019-12-06 06:20:27

问题


I want to use CHDataStructures as framework: https://github.com/davedelong/CHDataStructures. However there is no binary of the project.

So I assume I have to build the .a file myself using xcode. How do I do that in xcode 4? I read the documentation but it is very confusing...

Any ideas?


回答1:


First we'll grab the CHDataStructures project:

git clone https://github.com/davedelong/CHDataStructures.git

Next, open the relevant CHDataStructures xcode project

open CHDataStructures-iOS.xcodeproj

I'll assume you're building for iOS from here on out (and mention what will be different for a mac app). Once xcode is up and running, ensure that iOS Static Library is selected in the scheme drop-down, and then hit run. Once done, xcode has built the binary for you, and you'll be able to find it in Products in the navigator. Open the required binary (for iOS it's the compiled .a binary, for Mac it's the .framework collection).

Finally (expanding on the documentation):

  • Open the Xcode project for your iOS app.
  • Add libCHDataStructures.a and the library header files (all the .h header files in the framework subdirectory from the xcode project above) to your project by dragging them to the "Groups & Files" pane of your xcode project.
  • In the project navigator, select your project
  • Select your target
  • Select the 'Build Phases' tab
  • Open 'Link Binaries With Libraries' expander
  • Click the '+' button
  • drag libCHDataStructures.a into the "Link Binary With Libraries" build phase.
  • Add #import "CHDataStructures.h" where necessary in your code.


来源:https://stackoverflow.com/questions/6265102/how-to-create-framework-from-xcode-4-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!