运行项目报错
error build: Application extensions and any libraries they link to must be built with the `APPLICATION_EXTENSION_API_ONLY` build setting set to YES.
产生的原因是因为苹果公司为保证安全,建议extenstion中此类API不用。
要打开此设置是在对应的extension target中build setting相应项目,如下图:
设置为YES后 运行又会报错 'sharedApplication' is unavailable: not available on iOS (App Extension)
设置了cocopod 安装
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
def shared_pods
pod 'MJExtension'
pod 'UMCCommon'
pod 'UMCShare/Social/ReducedWeChat'
pod 'FMDB'
pod 'JPush'
pod 'MJRefresh'
pod 'MJExtension'
pod 'YYImage', :git => 'https://github.com/QiuYeHong90/YYImage.git'
pod 'SDWebImage', '~> 5.0.0'
pod 'FLAnimatedImage'
pod 'Qiniu'
pod 'AFNetworking', '~> 4.0.0'
# pod 'Ads-CN'
# pod 'Bytedance-UnionAD'#, '~> 3.5.0.4' # 穿山甲广告SDK
pod 'GDTMobSDK'
end
target 'XyKeyboardDemo' do
shared_pods
pod 'JXCategoryView'
pod 'IQKeyboardManager', '~> 6.5.5'
end
target 'CustomKeyboard' do
shared_pods
# pod 'UMCCommon'
end
最佳答案
您可以将以下 block 添加到您的 Podfile 以编程方式解决此问题。
如果您正在使用 pod,您可以将以下 block 添加到您的 Podfile 以解决此问题:
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'
end
end
end
这会将所有 pod 项目目标的 require only App-Extension-Safe Api 设置为 No 并且应该允许您的构建成功。
网友评论