Linking a static library to an iOS project in XCode 4
I have a project ( AQGridView
) that compiles to a static library, but I can't seem to add it to my project.
Dragging in the project to my project creates a workspace, and if I try to link the libAQGridView.a
file from the DerivedData
directory it doesn't recognize it as a library. I'm not sure what I'm doing wrong.
This is the AQGridView
project. Does anyone know specifically how to use it in an XCode 4 project?
I do this as follows:
If you don't see the static library project as nested under the main project in the main project's project navigator, the most likely reason for that is that the static library's own Xcode project is still open. Quit Xcode and open up the main project that has the nested static library project in it without opening up the original static library project itself, and you should see it appearing as a nested project in your main project.
Xcode menu > View > Utilities > File Inspector
Select the static library file, and then set 'File Type' as 'Mach-O object code' in 'Identity and Type'.
Workspaces are supposed to make this easier, but I don't know that they do. The way I do it is create a workspace, add my main project, add my library project. Then go into the main project's build phases and add the library in the "Link binary with libraries" section and add the library. That should be all that is necessary, at least that's my reading, but it isn't. What I do is go into Xcode preferences, then to the Source Trees pane. Add a source tree that points to your static library's headers, then go back to the build settings for your project, then to the Header Search Paths key, and enter ${foo} there, where "foo" is whatever you called the source tree.
That's what works for me, though I don't know if that's the best or easiest way to do it.
链接地址: http://www.djcxy.com/p/50996.html上一篇: Xcode 4构建成功,命令行构建失败?