How to resolve symbol name conflict in a Cocoa touch framework

前端 未结 4 1074
死守一世寂寞
死守一世寂寞 2021-01-01 20:10

I developed a Cocoa touch framework and am having problems with third party static framework classes which are embedded inside of it.

The problem is symbol collision

4条回答
  •  温柔的废话
    2021-01-01 20:37

    CocoaPods can help you to resolve the problem with duplicate symbols.
    Below I provided detailed explanations for how to make it happen:

    Definitions
    Let's make some definitions for simpler explanations:
    MyFramework - framework that you are developing.
    MyApplication - application that uses MyFramework.
    OtherFramework - third-party framework that is used in MyFramework and MyApplication.

    Problem
    As I understand the problem is that Xcode fails to build with "duplicated symbols" error in OtherFramework.

    Solution
    Here are conditions that you need satisfy to fix that problem:

    1) MyFramework has to refer to OtherFramework by CocoaPods:

    // MyFramework Podfile
    use_frameworks!
    pod "OtherFramework"
    

    2) MyApplication has to refer to OtherFramework by CocoaPods:

    // MyApplication Podfile
    use_frameworks!
    pod "OtherFramework"
    

    3) MyApplication can use any mechanism to refer to MyFramework (by CocoaPods or by Drag&Drop framework to project).

    4) OtherFramework has to be built with CocoaPods.
    If it's not built with CocoaPods yet, you can make it yourself.
    For this goal you need to create OtherFramework.podspec and optionally submit it to CocoaPods private repository. It doesn't matter if you have source files or just OtherFramework.framework bundle. More details for building CocoaPod here.

提交回复
热议问题