I have a proj开发者_C百科ect in XCode4 with a dependent project (happens to be the Kal project).
When I update the Kal project from within XCode, then run the parent project, (this happens on the same workspace btw), it looks like XCode compiles the modified Kal project but doesn't link to the newly compiled libKal.a file.
I'm running one of the default parent project schemes. From the logs I can tell that when running, it builds the dependent project before it builds the parent project. But the only way I can get the parent project to use my changes is if I re-add the libKal.a product as a library to be linked, under "Link Binary with Libraries" section of the parent build target.
Maybe clues: - I'm using LLVM, - I have the -all_load flag on.
What if you try :
- Clean
- Rebuild
That usually works for me in such cases...
Check your Schemes. For the application that depends on a library make sure that the dependency is being built every time. I have read the scheme should already have this update but sometimes it does not. You can see an example here...
http://blog.carbonfive.com/2011/04/04/using-open-source-static-libraries-in-xcode-4/#configuring_the_projects_scheme
Basically edit the Scheme for the application and click on the Build item on the top left. You will see each of the targets which is run as a part of that Build. If you do not see the target for a dependency you can add it. Then make sure your application is listed last so that all dependencies are created first.
I can suggest you to use single workspace for your library and main projects. In main project scheme add library target before your main(to compile library before main target) and setup headers search path.
Simplify your life and use cocoaPods. Here is a good tutorial. CocoaPods will automatically create a workspace with all the libraries you need for your project. I used to have all sorts of problems like this with libraries, and now I just use Pods.
Depending on how you have your project set up, Xcode won't necessarily re-link dependent libraries. In order to get it to link every time, you need to add the project as a Target Dependency in the build phases of the target you want the library to be linked too.
Say you have a workspace named Test and two projects name TestApplication and TestLibrary. If you have them included in the workspace as separate projects, you will be able to add TestLibrary.a to TestApplication as a library in the "Link Binary With Libraries" section of the build phases of the TestApplication target, but you WON'T be able to add it in the "Target Dependencies" section.
Now, if you move TestLibrary to be a sub-project of TestAppliction (just drag it into the project within the project navigator), you will be able to add TestLibrary as a both a Library to link with AND as a Target Dependency of TestApplication. Adding it as a Target Dependency ensures that Xcode will build (if necessary) and link the library.
Sorry, but it has been a while since I figured this out set my own projects up this way, so I can't remember exactly what the situation is where the library doesn't get linked. I think it was something along the lines of that since it was a separate project, Xcode wouldn't check to see if it needed building again and just linked against the previous library. I do remember though that my work around until I figured this out was to simply touch a file in the project that needed building. I had a file named touchMe that was included as a compile source if the library project that I would touch before building. You could do the same thing to see if that fixes your problem too, if moving the library project into the dependent project isn't an option for you.
Hope that helps.
精彩评论