ios - 更新到 React Native 0.60+ 后未链接动态库
问题描述
更新到 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)
解决方案
@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"
推荐阅读
- laravel-5 - Sourcetree 删除了我的文件
- argparse - 如何在python的类中使用argparse
- python - 如何以编程方式获取 GCP VM 实例的计费详细信息?
- hadoop - 比较集群之间的海量数据
- kotlin - Mockito:模拟间接注入的单例
- typescript - 如何在 Deno 中读取本地文件?
- xml - 如何在 XSLT 中使用大于函数进行标记出现
- spring - CAS & Spring Security --autoLogin
- git - 有什么好的方法可以限制 git/gerrit 上的一次代码更改大小
- swift - 从 Textview 中减去字符