Flipper: [iOS] use_framework!

Created on 26 Aug 2018  路  12Comments  路  Source: facebook/flipper

I'm trying to install the flipper pod in a repository where swift pods are added to the project using the use_framework! option.

Unfortunately, this triggers an error that prevents the installation from completing successfully.

[!] The 'Pods-ProjectName' target has transitive dependencies that include static binaries: 
(/path/to/Pods/CocoaLibEvent/lib/libevent.a,
/path/to/Pods/CocoaLibEvent/lib/libevent_core.a, 
/path/to/Pods/CocoaLibEvent/lib/libevent_extra.a,
/path/to/Pods/CocoaLibEvent/lib/libevent_pthreads.a,
/path/to/Pods/OpenSSL-Static/lib-ios/libcrypto.a, and
/path/to/Pods/OpenSSL-Static/lib-ios/libssl.a)

I cannot remove that option for some reasons. The most important one is a bug in Cocoapods
https://github.com/CocoaPods/CocoaPods/issues/7585

Since all the involved pods come from flipper, Is there something that we can do about it?

Most helpful comment

I tried the following

  $static_framework = ['FlipperKit', 'Flipper', 'Flipper-Folly',
    'CocoaAsyncSocket', 'ComponentKit', 'DoubleConversion',
    'glog', 'Flipper-PeerTalk', 'Flipper-RSocket', 'Yoga', 'YogaKit',
    'CocoaLibEvent', 'OpenSSL-Static', 'boost-for-react-native']

  pre_install do |installer|
    Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
    installer.pod_targets.each do |pod|
      if $static_framework.include?(pod.name)
        pod.instance_variable_set(:@host_requires_frameworks, false)
        puts pod
      end
    end
  end

It successfully generated the project and even the sample app built.

CocoaPods version 1.6.1

Try it out and feel free to open the issue, if it didn't work.

All 12 comments

Cocoapod 1.5.0 supports static swift libraries. Since our pod depends on static libraries, using use_framework1 may not work. May be replacing static libraries for Libevent and Openssl with dynamic may solve the issue. We are happy to have a PR from the community with regards to this,

Is there any work around for this? looks like the dependency 'Folly' which uses 'CocoaLibEvent' is the problem. blocker for any iOS project that uses Swift.

https://github.com/facebook/folly/tree/master/folly
https://github.com/e314521/CocoaLibEvent

Has anyone figured this out? I've tried a few different ways to get this to work to no avail...

Ok after playing around some more I have included this code in my Podfile and this works -

$static_framework = ['FlipperKit', 'Flipper', 'Folly', 
    'CocoaAsyncSocket', 'ComponentKit', 'DoubleConversion', 
    'glog', 'PeerTalk', 'RSocket', 'Yoga', 'YogaKit', 
    'CocoaLibEvent', 'OpenSSL-Static', 'boost-for-react-native']
pre_install do |installer|
    installer.pod_targets.each do |pod|
        if $static_framework.include?(pod.name)
            pod.host_requires_frameworks = false
        end
    end
end

This will cause Pods to build the pods in the array as static and the others dynamic frameworks

Above thing is still not working of me, i am still getting below error

undefined methodhost_requires_frameworks=' for

I got the same error, @dmac81 solution not working for me

[!] The 'Pods-Runner' target has transitive dependencies that include static binaries: (/Users/lijy91/Documents/Projects/blankapp/flutter_flipperkit/example/ios/Pods/CocoaLibEvent/lib/libevent.a, /Users/lijy91/Documents/Projects/blankapp/flutter_flipperkit/example/ios/Pods/CocoaLibEvent/lib/libevent_core.a, /Users/lijy91/Documents/Projects/blankapp/flutter_flipperkit/example/ios/Pods/CocoaLibEvent/lib/libevent_extra.a, /Users/lijy91/Documents/Projects/blankapp/flutter_flipperkit/example/ios/Pods/CocoaLibEvent/lib/libevent_pthreads.a, /Users/lijy91/Documents/Projects/blankapp/flutter_flipperkit/example/ios/Pods/OpenSSL-Static/lib-ios/libcrypto.a, and /Users/lijy91/Documents/Projects/blankapp/flutter_flipperkit/example/ios/Pods/OpenSSL-Static/lib-ios/libssl.a)

Above thing is still not working of me, i am still getting below error

undefined methodhost_requires_frameworks=' for

CocoaPods 1.6.0+ host_requires_frameworks is changed to be readonly.

You can downgrade CocoaPods to 1.5.3 before facebook fix it.

@DDDrop good catch, here is the commit where they made that change:

https://github.com/CocoaPods/CocoaPods/commit/f7009cf7de0a96602a93b188c0d1e389ac180436#diff-8c725e5a3b8317f479af06a7eb820320

So this would only work on releases before 1.6.0. When I get some time I will see if there is another way around this in 1.6.0 and above.

I tried the following

  $static_framework = ['FlipperKit', 'Flipper', 'Flipper-Folly',
    'CocoaAsyncSocket', 'ComponentKit', 'DoubleConversion',
    'glog', 'Flipper-PeerTalk', 'Flipper-RSocket', 'Yoga', 'YogaKit',
    'CocoaLibEvent', 'OpenSSL-Static', 'boost-for-react-native']

  pre_install do |installer|
    Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
    installer.pod_targets.each do |pod|
      if $static_framework.include?(pod.name)
        pod.instance_variable_set(:@host_requires_frameworks, false)
        puts pod
      end
    end
  end

It successfully generated the project and even the sample app built.

CocoaPods version 1.6.1

Try it out and feel free to open the issue, if it didn't work.

I switched to using this:

  pre_install do |installer|
    Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}

  installer.pod_targets.each do |pod|
    if $static_framework.include?(pod.name)

      def pod.host_requires_frameworks=(hostRequiresFrameworks)
        @host_requires_frameworks = hostRequiresFrameworks
      end

      pod.host_requires_frameworks = false
    end
  end
end

Which I know is an utter hack but it is deploying to a Simulator and connecting to Flipper Desktop with CocoaPods 1.6.0

Will try @priteshrnandgaonkar solution when I get a chance

Update for CP 1.7+ - I tried @dmac81's solution, but it didn't work (all frameworks were still built as dynamic). What worked for me was

pre_install do |installer|
  Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
  installer.pod_targets.each do |pod|
    if $static_framework.include?(pod.name)
      def pod.build_as_static_framework?;
        true
      end
    end
  end
end

For previous CP versions, you can use the same approach (just replace build_as_static_framework with static_framework which got deprecated in CP 1.7 - https://www.rubydoc.info/gems/cocoapods/Pod/Target:static_framework%3F).

For CP 1.7+ Objective-C The following worked on the sample app with use_framework!

  $static_framework = ['FlipperKit', 'Flipper', 'Flipper-Folly',
    'CocoaAsyncSocket', 'ComponentKit', 'DoubleConversion',
    'glog', 'Flipper-PeerTalk', 'Flipper-RSocket', 'Yoga', 'YogaKit',
    'CocoaLibEvent', 'openssl-ios-bitcode', 'boost-for-react-native']

  pre_install do |installer|
    Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
    installer.pod_targets.each do |pod|
        if $static_framework.include?(pod.name)
          def pod.build_type;
            Pod::Target::BuildType.static_library
          end
        end
      end
  end
Was this page helpful?
0 / 5 - 0 ratings

Related issues

hsavit1 picture hsavit1  路  3Comments

davidmcraejr picture davidmcraejr  路  4Comments

orlandobustamantep picture orlandobustamantep  路  3Comments

usrbowe picture usrbowe  路  3Comments

hackaprende picture hackaprende  路  4Comments