Search code examples
iosobjective-cswiftgoogle-mapscocoapods

Connect pod with static framework to another pod as dependency in podspec


I have a framework that I connect to my project as a pod. I need to connect a Google Maps in the framework. I tried to make it in podspec file:

s.dependency 'GoogleMaps'
s.dependency 'GooglePlaces'

But I get an error during pod install that 'target has transitive dependencies that include static binaries'.

I tried to add this code to podfile:

pre_install do |installer|
    def installer.verify_no_static_framework_transitive_dependencies; end
end

but it doesn't seem to work.

I have also tried to copy GoogleMaps.framework, GoogleMapsCore.framework and GooglePlaces.framework to my framework and connect them like that:

s.vendored_frameworks = "MyFrameworkFolder/GoogleMaps/*.framework"

but I get in error while compiling project which contains the pod: could not build Objective-C module 'MyFramework'

I tried to fix it in post install hook with

  if target.name.start_with?('MyFramework')
      config.build_settings["OTHER_LDFLAGS"] = '$(inherited) "-ObjC"'

but no effect.

Does anyone have an experience in solving problem like that?


Solution

  • CocoaPods 1.4.0 added the static framework podspec attribute that instructs CocoaPods to build a static framework instead of a dynamic framework and to depend upon static vendored_frameworks.

    Add s.static_framework = true to your podspec.

    More in the CocoaPods 1.4.0 announcement blog.