I have built a static library (let's call it A) that depends on CFNetwork.framework, which is being successfully built in xCode. I have included CFNetwork.framework in the "link binary with li开发者_高级运维braries" build phase. This static library has its own project.
For some reason, when try to use this static library in another project (let's call it B), it fails in the linking phase, complaining that CFNetwork's symbols could not be found.
I have added A as a dependency in B's target (so that A always gets compiled before B successfully) and I also have added A to B's "Link Binary With Libraries" build phase.
Has anyone ever had a similar issue?
EDIT: If I add CFNetwork.framework to B's "Link Binary With Libraries" build it starts building successfully.
Yes, you will also need to add CFNetwork.framework
as a dependency in project B
.
That is the correct manner of setting up your dependencies. You'll need to document the reliance upon CFNetwork.framework
in the release notes for static library A
.
Definitely have a look at Guidelines for Creating Frameworks, specifically "What to Include in Your Framework". You'll see that Apple advises against creating umbrella frameworks (i.e. including something like CFNetwork.framework in your distributed static library).
Don’t Create Umbrella Frameworks
While it is possible to create umbrella frameworks using Xcode, doing so is unnecessary for most developers and is not recommended. Apple uses umbrella frameworks to mask some of the interdependencies between libraries in the operating system. In nearly all cases, you should be able to include your code in a single, standard framework bundle. Alternatively, if your code was sufficiently modular, you could create multiple frameworks, but in that case, the dependencies between modules would be minimal or nonexistent and should not warrant the creation of an umbrella for them.
If you have a lot of dependencies, it's worth considering a dependency management tool like Cocoapods.
精彩评论