1

更新到 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)
4

1 回答 1

1

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

解决方案是在 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-03-05T12:45:30.663 回答