Reputation: 14236
I have to use a 3rd-party framework in my app. But when I include the framework in my project I get linker errors like the following:
duplicate symbol _SRHTTPResponseErrorKey in:
Shared/Libraries/XXX.framework/XXXSDK(SRWebSocket.o)
Shared/Libraries/YYY.framework/YYYSDK(YYYSRWebSocket.o)
Is there a way to resolve such errors without altering the framework(s) ?
Upvotes: 2
Views: 2565
Reputation: 1127
Problem is that the framework and your code (or another of your frameworks) contains the same classes/frameworks. The developer of the framework thought that making it's own framework an umbrella for the other one is a good idea - it isn't. A framework should never contain another one.
BTW: Thats the reason why every class of your ObjectiveC framework should have a prefix. It lowers the possibilities for a conflict.
There are following solutions for you:
If you add one of the two conflicting classes: Rename the class in your code. Maybe fork the framework and change the prefix of all classes or create a wrapper framework with the technic in 3).
Ask the developer to remove all external code and link it only. In addition he/she has to document the dependency so a user of the framework know which one in which version he/she has to add. You may use a dependency framework like CocoaPods/Carthage or a makefile than to fetch the depending frameworks.
If 2) isn't possible because the framework will be used by other customers and the developer wan't break their code (stupid reason by the way): Ask the developer of the framework to add for each class that isn't his own code an "Other C Flag" like described here
Upvotes: 3