Prevent duplicate symbols when building static library with Cocoapods

后端 未结 6 1385
天涯浪人
天涯浪人 2020-12-07 21:32

While I\'ve seen many questions dealing with Cocoapods and static libraries, most of them seem to assume you\'ll eventually have a single workspace with your static library

6条回答
  •  一生所求
    2020-12-07 22:00

    I had the same issue. I managed the dependencies of my library with cocoapods using the following podfile format:

    platform :ios, '6.0'
    pod 'AFNetworking'
    

    This resulted in a Pods-dummy.o file in my .a file. If I then included this library in another project using the same podfile format, they both created a Pods-dummy.o symbol and results in a linker error. The solution is to use a different podfile format which results in a namespaced Pods-dummy symbol:

    platform :ios, '6.0'
    target "MyProject" do
        pod 'AFNetworking'
    end
    

    This results in a Pods-MyProject-dummy.o file, which won't cause duplicate symbols.

    Note: if you switch your project over to using the new podfile format, make sure to unlink libPods.a from your project, since it will hang around as a broken link because the new pods library is named Pods-MyProject

提交回复
热议问题