ios - 构建目标 MyNotificationService:找不到框架
问题描述
我有一个 React Native 应用程序“MyApp”,它附加了一个“MyNotificationService”(即NotificationService.appex
嵌入Frameworks, Libraries and Embedded Content in Xcode
在目标“MyApp”下)。
到目前为止,一切都很好。
现在我想在“MyApp”命名中添加另一个 pod pod 'Google-Mobile-Ads-SDK'
,这与MyNotificationService
. 我只想安装它,所以我可以访问Google-Mobile-Ads-SDK
“MyApp”。
我的 Podfile 看起来像这样
target 'MyApp' do
use_unimodules!
config = use_native_modules!
use_react_native!(
:path => config[:reactNativePath],
:hermes_enabled => false
)
# Additional Dependencies
...
pod 'Google-Mobile-Ads-SDK'
target 'MyNotificationService' do
use_native_modules!
inherit! :complete
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'NO'
# deletes each pods deployment target definition and instead uses the definition of the main project
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
end
end
end
end
但是,在我运行之后pod install
,我尝试构建MyApp
使用 XCode 的调试版本,但 XCode 抱怨:
Build Target MyNotificationService
Link MyNotificationService (arm64)
Directory not found for option '-F/Users/.../Library/Developer/Xcode/DerivedData/MyApp-abcabcabcabcabc/Build/Products/Debug-iphoneos/XCFrameworkIntermediates/GoogleAppMeasurement'
Directory not found for option '-F/Users/.../Library/Developer/Xcode/DerivedData/MyApp-abcabcabcabcabc/Build/Products/Debug-iphoneos/XCFrameworkIntermediates/GoogleMobileAds'
Directory not found for option '-F/Users/.../Library/Developer/Xcode/DerivedData/MyApp-abcabcabcabcabc/Build/Products/Debug-iphoneos/XCFrameworkIntermediates/UserMessagingPlatform'
但是 MyNotificationService 与这些 Frameworks 无关GoogleAppMeasurement
,GoogleMobileAds
并且UserMessagingPlatform
- 那些属于Google-Mobile-Ads-SDK
并且只有主要目标MyApp
应该需要它们。
我怎么知道MyNotificationService
它不应该关心这些框架?
解决方案
确实使用抽象目标解决了问题,其中定义了“MyApp”和“MyNotificationService”作为子目标。抽象目标不是实际的 Xcode 目标,而是一个占位符或文件夹,它定义了“MyApp”和“MyNotificationService”都应该共享的 pod。要获得“MyNotificationService”,请忽略与“Google-Mobile-Ads-SDK”相关的所有内容,pod 'Google-Mobile-Ads-SDK'
仅在子目标“MyApp”中定义。
abstract_target 'Shared' do
use_unimodules!
config = use_native_modules!
use_react_native!(
:path => config[:reactNativePath],
# to enable hermes on iOS, change `false` to `true` and then install pods
:hermes_enabled => false
)
# Additional Dependencies
...
target 'MyApp' do
# no inherit statement means that target MyApp has all pods from the parent "Shared" accessible
pod 'Google-Mobile-Ads-SDK'
end
target 'MyNotificationService' do
# no inherit statement means that target MyNotificationService has all pods from the parent "Shared" accessible
use_native_modules!
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'NO'
# deletes each pods deployment target definition and instead uses the definition of the main project
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
end
end
end
end
推荐阅读
- react-native - 在 RN 中使用多个视图时的边距
- math - 三次贝塞尔路径——在拉直弧长的同时保持弧长
- jenkins - 为什么 Jenkins 因错误而失败:退出 9009
- android - 如何调试 D8 错误,例如“类型 X 被引用为 Y 的接口”?
- javascript - 如何限制从 Mongoose 数组填充返回的项目?
- google-apis-explorer - Google Knowledge Graph API 响应中缺少返回信息
- wordpress - 更改主域后无法访问 Wordpress Multisite 中的站点
- android - 为什么 appium v1.12.1 在我执行测试脚本时会出现此错误?安卓版本:6.0
- arguments - 此函数的参数过多
- c# - 为什么 EF 代码不选择单列?