【问题标题】:Dynamic libraries not linked after updating to React Native 0.60+更新到 React Native 0.60+ 后未链接动态库
【发布时间】:2020-06-18 02:11:09
【问题描述】:

更新到 React Native 0.61.5 后,我在链接只能动态链接的库时遇到问题 (@react-native-mapbox-gl/maps)。

解决方案通常是在 Podfile 中启用动态库(设置 use_frameworks!)。但是,这会导致所有库都是动态的,并导致只能静态链接的库出现问题 (react-native-firebase)。

是否有任何解决方案可以满足这些相互冲突的要求?

当设置use_frameworks! 时,会在运行时抛出此错误:

dyld: Library not loaded: @rpath/MapboxMobileEvents.framework/MapboxMobileEvents
  Referenced from: /private/var/containers/Bundle/Application/4A4F5BC3-2A1D-4949-9423-71EF7EFE79FD/ImmoWert2Go.app/Frameworks/Mapbox.framework/Mapbox
  Reason: image not found

use_frameworks!没有设置时,pod install会抛出这个错误:

[!] The 'Pods-ImmoWert2Go' target has transitive dependencies that include statically linked binaries: (FirebaseCore, FirebaseCoreDiagnostics, GoogleDataTransportCCTSupport, GoogleDataTransport, and FirebaseInstanceID)

【问题讨论】:

    标签: ios react-native cocoapods react-native-firebase react-native-mapbox-gl


    【解决方案1】:

    @react-native-mapbox-gl/maps目前还不能作为静态库使用,所以需要将整个项目配置为使用动态库,Apple不鼓励这样做。

    解决方案是在 Podfile 的开头添加这些行:

    # Set libraries as dynamic by default
    use_frameworks!
    
    # Set specific libraries as static (react-native-firebase)
    pre_install do |installer|
      installer.pod_targets.each do |pod|
        if pod.name.start_with?('RNFB')
          def pod.build_type;
            Pod::Target::BuildType.static_library
          end
        end
      end
    end
    

    完成后,RNFirebaseUtil.h 需要修补

    #import <Firebase.h>
    

    #import "Firebase.h"
    

    【讨论】:

      猜你喜欢
      • 2020-09-14
      • 1970-01-01
      • 1970-01-01
      • 2019-11-06
      • 2020-01-05
      • 2019-11-18
      • 1970-01-01
      • 1970-01-01
      • 2019-11-18
      相关资源
      最近更新 更多