使用通知扩展会导致Cocoapods出现问题

问题描述 投票:0回答:1

我的应用中有一个通知扩展。但是,当我构建我的应用程序时,它与pod FBSDKLoginKit冲突。它在FBSDKCoreKit中给我以下错误:

'sharedApplication' is unavailable: not available on iOS (App Extension) - Use view controller based solutions where appropriate instead.

我的Podfile看起来像这样(我错过了不相关的Pod):

workspace 'MyApp'
platform :ios, '10.0'

target 'MyApp' do
  use_frameworks!
  project 'MyApp.xcodeproj'
  pod 'FBSDKLoginKit'
  pod 'OneSignal', '>= 2.6.2', '< 3.0'

  target 'OneSignalNotificationServiceExtension' do
    pod 'OneSignal', '>= 2.6.2', '< 3.0'
  end
end

我该如何解决?

ios swift
1个回答
0
投票

OneSignalNotificationServiceExtension目标移出Podfile中的主要目标。不要忘记在其中也定义use_frameworks!

workspace 'MyApp'
platform :ios, '10.0'

target 'MyApp' do
  use_frameworks!
  project 'MyApp.xcodeproj'
  pod 'FBSDKLoginKit'
  pod 'OneSignal', '>= 2.6.2', '< 3.0'
end

target 'OneSignalNotificationServiceExtension' do
  use_frameworks!
  pod 'OneSignal', '>= 2.6.2', '< 3.0'
end

清理并构建,应该可以解决问题👍

© www.soinside.com 2019 - 2024. All rights reserved.