Onesignal-ios-sdk: Pod error 'shared' is unavailable. use viewcontroller based solutions

Created on 11 Oct 2017  ·  33Comments  ·  Source: OneSignal/OneSignal-iOS-SDK

Hello,
I followed the instructions on IOS sdk setup page. After 'pod install', i cleaned and built my project and got "'shared' is unavailable: Use view controller based solutions where appropriate instead" errors on my other pods.

When i remove onesignal from podfile and install, the errors disappear.
Anybody has seen this error?
thanks...

Most helpful comment

Hey All,

Flagging "Require Only App-Extension-Safe API" did not work for me. I solved this by putting the following code at the bottom of my Pods file:

...

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

Also, making sure my OneSignalNotificationServiceExtension target is a child of my app target:

target 'MyAwesomeApp' do
  ...


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

People still facing this issue? @ZakSingh @RishiRaj27 @vanessaguapo

All 33 comments

@fnrbh Is this the full exact error?
Could you attach your Podfile contains so we can look into reproducing the issue?

@jkasten2 thank you for your response.

The error is : 'shared' is unavailable: use view controller based solutions where appropriate instead. TwitterPagerTabStripSettings.swift

My podfile is as follows:

 platform :ios, '9.0'

target 'mopa' do
  use_frameworks!

  # Pods for mopa
    pod 'Alamofire', '~> 4.4'
    pod 'FSPagerView'
    pod 'SDWebImage'
    pod 'SwiftKeychainWrapper'
    pod 'CHIPageControl', '~> 0.1.3'
    pod 'XLPagerTabStrip', :git => 'https://github.com/xmartlabs/XLPagerTabStrip.git'
    pod 'ActiveLabel'
    pod "Koloda"
    pod 'RxSwift',    '~> 3.0'
    pod 'RxCocoa',    '~> 3.0'
    pod 'RxDataSources', '~> 1.0'
    pod 'RxAlamofire'
    pod 'RSKImageCropper'
    pod 'OneSignal', '>= 2.5.2', '< 3.0'


  target 'mopaTests' do
    inherit! :search_paths
    # Pods for testing
  end

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

end

I have the same error when pods aren't extension compliant.
So far found 2 Siesta/UI and Quantcast

I solved the problems of other pods. I didn't use "shared" directly but used different ways to achieve the same result.

i don't think this should have been closed. thats not a really solution, just a workaround. Anytime you update your pods, all your changes would be lost, otherwise one has to manually import all of the non compliant pods to the project itself.

Also seeing this error. Surely OneSignal doesn't expect all of your other pods to be extension compliant in order to use it?

I solved it the other way around and imported the OneSignal framework locally to the project. Since i have several pods that were not extension compliant, it was easier this way. But if there's an update i'll have to do it manually, so it's not a great solution, just a quick fix.

I am facing same issue..
has anybody solve this by cocoapods ?

I had same problem . So setting require only app-extension-safe api to No to other pod setting helped

I had the same problem too.

Any one got the solution?
I am also getting the same error in my other pod files...

Hi, we are planning to fix this - there is already an open issue for the app-extension-unsafe code (#396) and we will be addressing it by making our extension-specific code its own subspec framework.

In the mean time, setting the require only app-extension safe api in your Notification Service Extension's build settings should temporarily allow you to build.

Because there is already an issue for this I won't be reopening the ticket

Hi @Nightsd01 !
Thanks for your response. But the require only app-extension safe api in Notification Service Extension's build settings couldn't help me to resolve the error. Can you suggest me any thing else.

Hi @RishiRaj27 , i could't solve it that way either. As i said above I ended up importing the onesignal pod content to my project and using it inside instead of using a pod. Not an ideal solution, but it did the job.

@RishiRaj27 can you post your Podfile?

Thanks @Nightsd01 and @vanessaguapo !
I have followed these steps and got the solution.

  1. Download or clone thi repo.
  2. Drop and drag iOS_SDK/OneSignalSDK/Framework/OneSignal.framework into your Xcode project. Make sure to check the copy option.
  3. Add SystemConfiguration, UIKit, and UserNotifications to your framework list.
  4. You can then follow our full setup guide for the code setup.
  5. If you need the features provided by the Notification Service Extension you will need to repeat steps 2 and 3 above for this target.

@RishiRaj27 we have been working on a 3.0 release that will resolve this issue entirely. In the mean time manually including the framework should also resolve the problem

@Nightsd01 i have import in manually in one signal notification but same error in shared' is unavailable: use view controller based solutions where appropriate instead then i have change require only app-extension safe api To NO then all issue resolved. any issue in upload in app store.

I am having the same problem here, it happens whenever I add one signal in my OneSignalNotificationServiceExtension target

target 'OneSignalNotificationServiceExtension' do
pod 'OneSignal'
end

Any update here? Running into the same issue and none of the provided fixes resolve the issue.

Any update here? Running into the same issue and none of the provided fixes resolve the issue.

Go to your App's target -> Build Setting -> Require Only AppExtension-Safe API -> set to NO
Error will disappear. It's worked for me. Good Luck!

Screenshot 2019-04-07 at 5 35 57 PM

Hey All,

Flagging "Require Only App-Extension-Safe API" did not work for me. I solved this by putting the following code at the bottom of my Pods file:

...

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

Also, making sure my OneSignalNotificationServiceExtension target is a child of my app target:

target 'MyAwesomeApp' do
  ...


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

People still facing this issue? @ZakSingh @RishiRaj27 @vanessaguapo

had this problem today too what a royal pain. thanks @lukebrandonfarrell that script saved having to manually update a bunch of pod files Build Settings.

None of these solutions works for me. The issue for me comes from React-Core.

Still facing the same issue with the Onesignal version (2.11.2). Using Xcode 11 and swift.

@abhishek-gangwar I too had similar issue spent 2 days to figure it out...ended by adding
use_frameworks! outside

for example

`platform :ios, '10.0'

use_frameworks!

target 'mopa' do
pod 'Alamofire', '~> 4.4'
pod 'FSPagerView'
pod 'SDWebImage'
pod 'OneSignal'

target 'mopaTests' do
inherit! :search_paths
end

target 'OneSignalNotificationServiceExtension' do
pod 'OneSignal'
end

end`

this should work, do not forget to update OneSignal SDK, it has the latest iOS13.2 notification bug fix

any better solution yet?

@danial096 I had the same problem and solved it by removing additional pods that dealt with notifications. For example, I had OneSignal, Firebase Messaging, and Firebase InAppMessaging all in my podfile. I removed the 2 Firebase pods and then my project worked.

@Samuelford24 i dont have other pod that handle notification. The problem appear after I install onesignal pod to my notification extension. for now i just set
APPLICATION_EXTENSION_API_ONLY = NO. Hope can find a better solution soon

It's 2020 and I just got this error today after setting up using Swift. The script worked.

@lawgimenez I have the same issue. Which script worked for you?

@houmie the one below sir, with the most upvotes

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

@lawgimenez Thank you. I missed that somehow. That worked for me too.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ogres picture ogres  ·  3Comments

chmiiller picture chmiiller  ·  6Comments

KishanVyas picture KishanVyas  ·  6Comments

cassidyclawson picture cassidyclawson  ·  5Comments

ldco2016 picture ldco2016  ·  3Comments