【发布时间】:2021-10-14 23:24:41
【问题描述】:
我有一个 React Native 应用程序“MyApp”,它附加了一个“MyNotificationService”(即,NotificationService.appex 嵌入在目标“MyApp”中的 Frameworks, Libraries and Embedded Content in Xcode 下)。
到目前为止一切都很好。
现在我想在“MyApp”中添加另一个 pod,命名为 pod 'Google-Mobile-Ads-SDK',这与 MyNotificationService 没有任何关系。我只是想安装它,所以我可以访问“MyApp”中的Google-Mobile-Ads-SDK。
我的 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 之后,我尝试使用 XCode 构建 MyApp 的调试版本,但 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 与 GoogleAppMeasurement、GoogleMobileAds 和 UserMessagingPlatform 这些框架无关 - 它们属于 Google-Mobile-Ads-SDK,只有主要目标 MyApp 需要它们。
我如何告诉MyNotificationService 它不应该关心这些框架?
【问题讨论】:
标签: ios xcode react-native cocoapods ios-app-extension