0

I have a Notification Extension in my app. However, when I build my app it conflicts with the pod FBSDKLoginKit. It gives me the following error in the FBSDKCoreKit:

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

My Podfile looks like this (I've missed out irrelevant pods):

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

How do I fix this?

Tometoyou
  • 7,792
  • 12
  • 62
  • 108
  • 1
    From what I understand, you're calling the 'sharedApplication' in a non-controller view class. So it has nothing todo with your podfile afaik. Try inheriting the extension to a UIViewController for testing purposes and try again. – TheNitram Jun 28 '18 at 18:46
  • The error occurs in Facebook's `FBSDKLoginKit` framework, imported using Cocoapods. I don't have control over this code. – Tometoyou Jun 28 '18 at 18:50
  • Check this link. It might help you out. https://stackoverflow.com/questions/34225213/uiapplication-sharedapplication-not-available – TheNitram Jun 28 '18 at 18:55

1 Answers1

1

Move your OneSignalNotificationServiceExtension target out of your main target in your Podfile. Don't forget to also define use_frameworks! in it!

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

pod install, Clean and Build and that should do the trick

Jordan
  • 31
  • 4