Reputation: 1288
I'm running into a framework linking issue that I couldn't solve for several days now.
Here's what I'm doing:
In Xcode 5.0.2, I create a new Framework project. I delete the default targets being created with the project, the files associated with them as well as relevant schemes (cause I want to create my own).
I create a new framework target, give it some name, say "Test1", delete the default header and implementation files, and add a new protocol to it. I build it, just for checking, everything goes smoothly.
I create another framework target, give it another name, say "Test2", delete default header and implementation files, and add a new class to it.
From Test2 build settings, I link to Test1. I try to build and it craps out:
ld: framework not found Test1
clang: error: linker command failed with exit code 1 (use -v to see invocation)
If I do not include the Test1 framework, it builds successfully, as expected (framework is not included in any files, just in build settings).
Tried cleaning&rebuilding, manually removing files, removing framework, library and header paths from settings, restarting Xcode (even computer) and a few other stuff I cannot ever remember, but to no avail. Also tried several suggestions from other SO answers but still no luck.
I'd be thankful if anyone had some idea about what's going on.
Thanks.
Edit: Here is a link to an archive with a test project created to demonstrate the above problem. I have since added the "Target 1" framework to the dependencies of Target 2 as well.
Upvotes: 0
Views: 720
Reputation: 26325
OK, it turns out the above was unrelated. Sorry for the confusion (but it's still a good idea to set your dependencies properly).
The reason Xcode can't find the framework is because you haven't added any code to it. You only have a header. Once you add a .m (or probably .c or .cpp or .mm) file to Target1, then it works as expected!
Upvotes: 1
Reputation: 26325
You need to set Target 2 to be have Target 1 as a dependency. To do so, open the Target 2 "Build Phases" pane. Twirl open "Target Dependencies". Click the "+" button to add a dependency, and when the sheet comes up, select "Target 1".
Once you've done that, every time you build Target 2, it will ensure that Target 1 is built and is in the correct place for linking.
Upvotes: 2