Closed olejnjak closed 2 years ago
Our SDK doesn't use any extension-unavailable code in the extension service, so your app wouldn't get rejected. But the warning is certainly annoying.
You can also use Cocoapods, or link directly against our static binary, which would also get rid of the error, but neither of these things are necessary.
Eventually in the future I will look into either splitting out the extension-specific functionality into its own separate library, or I'll look into other approaches.
+1
We're now working on a PR to fix this issue. Unfortunately it will need to be a breaking change so it will need to wait until our next major release (3.0)
Essentially we are splitting out extension-specific functionality into a separate (smaller) framework
Here is the current state of the PR: https://github.com/OneSignal/OneSignal-iOS-SDK/pull/427
@Nightsd01 is there an existing branch with this fix? And what do you mean by or link directly against our static binary
What does that mean?
@otymartin The static OneSignal framework can be found here: https://github.com/OneSignal/OneSignal-iOS-SDK/tree/master/iOS_SDK/OneSignalSDK/Framework/OneSignal.framework
The PR #427 noted above just splits out the Notification Extension Service specific part of the SDK into its own target to make it smaller and to fix any warnings about APIs being referenced that are not available in that target. I don't believe it would fix the dynamic linking warnings.
Ahh I see - so the warnings are here to stay until 3.0.0?
Correct, it requires APPLICATION_EXTENSION_API_ONLY
to be set in the Xcode project to fix the warning. However we can't do this until SDK is split into modules as I believe it would result in compiler errors otherwise.
@JKalash So what do I set it to NO
or YES and on what the OneSignal pod? or the Extension target? Or my apps main target?
@otymartin It would be on the "OneSignal" framework project itself, like the following. https://stackoverflow.com/a/48863451/1244574 Again it will most likely create a compile issue as it is the same code base for the main target and the extension. Also the "not safe" warning is present since it doesn't know if it is referring to any APIs it can't use. However OneSignal has runtime guards so there isn't any real issues.
@JKalash Ok, although I hate seeing warnings I can live with. it knowing it won't affect the actual push delivery and App Store review process.
Thanks
@jkasten2 is this problem fixed?
@jkasten2 is this problem fixed?
@otymartin Unfortunately this issue is not simple to fix since it requires having a separate SDK for the App target and the notification service extension target with no shared symbols. We are still looking into a fix for this.
Still a problem here in June 2021.
same problem
I'm using OneSignal via SPM and have the same problem. Any solutions?
The solution for this requires modularizing the SDK and is being actively developed. I apologize for the inconvenience and thank you for your patience.
same
Same. I try to have no warnings in projects but I'll have to continue waiting.
Well, changing SDK solved my problem 😃
Seeing the same on SDK version 3.10.1 with Cocoapods.
Can anyone confirm that this is just a warning and will not be rejected by Apple if the extension is linked with theOneSignalXCFramework 3.10.1
dynamic library of OneSignal ?
It is the first answer here...https://github.com/OneSignal/OneSignal-iOS-SDK/issues/396#issuecomment-412171634
Hello! In order to fix this issue the SDK needed to be modularized to exclude references to UIApplication SharedApplication
from the package imported in the Notification Service Extension.
There is now a beta release available that fixes this issue by providing a Cocoapods subspec or SwiftPM product OneSignalExtension
to be used in Notification Service Extensions.
Note that there are a couple extra steps for Cocoapods to remove the warning, and all steps can be found in the release notes.
Also note that using OneSignalExtension
should not be required by this release (it is intended to be a non-breaking change), so please report any issues you find upon upgrading.
Hello! In order to fix this issue the SDK needed to be modularized to exclude references to
UIApplication SharedApplication
from the package imported in the Notification Service Extension.There is now a beta release available that fixes this issue by providing a Cocoapods subspec or SwiftPM product
OneSignalExtension
to be used in Notification Service Extensions.Note that there are a couple extra steps for Cocoapods to remove the warning, and all steps can be found in the release notes.
Also note that using
OneSignalExtension
should not be required by this release (it is intended to be a non-breaking change), so please report any issues you find upon upgrading.
I attempted to add the beta release to my project. I got it working for initial launch of my app but on subsequent launches of my app the OneSignal initialization code crashes.
@hieuctrac Could you share the stack trace of the crash you are getting?
On the device you installed the app on, was it running an older version of the OneSignal SDK? If so what version?
If you install your app on another device (or fully uninstall it and reinstall it on the same device) do you see the same issue?
I still get the warning, even though I've updated to 3.11.1 from 3.10.0, cleaned the build folders and recompiled everything. Is there something else I need to do? My project uses Objective-C, Cocoapods and has a deployment target of iOS 12.
@lhasiuk Can you double check that you have made these changes to your project from the 3.11.0 release notes?
For Cocoapods
- In your Podfile make sure that your Notification Service Extension target is nested in your App target.
- Use pod
OneSignal
orOneSignalXCFramework
(they are now identical) for your app target, and subspecOneSignal/OneSignalExtension
orOneSignalXCFramework/OneSignalExtension
for your Notification Service Extension target.- Then in your NotificationService class import
OneSignalExtension
instead ofOneSignal
- Lastly from the
Other Linker Flags
build setting in your Notification Service Extension target remove$(inherited)
and-framework "OneSignal"
@jkasten2 Thanks, I had not done those things. However, once I did all of them and double checked that I had, I started to have issues where the One Signal Extension is trying to include other Pods that are only used by my main application and since some of those pods reference things like [UIApplication sharedApplication], which is not available in an extension, I get errors during compilation. I tried making sure they were not mentioned in Other Linker Flags and even tried removing everything except -ObjC from Other Linker Flags, but it didn't help. Any suggestions how to solve that?
@jkasten2 Thanks, I had not done those things. However, once I did all of them and double checked that I had, I started to have issues where the One Signal Extension is trying to include other Pods that are only used by my main application and since some of those pods reference things like [UIApplication sharedApplication], which is not available in an extension, I get errors during compilation. I tried making sure they were not mentioned in Other Linker Flags and even tried removing everything except -ObjC from Other Linker Flags, but it didn't help. Any suggestions how to solve that?
I had the same issue. Did you find any solution?
@Sergozh No, I have not found a solution yet. I'm hoping that @jkasten2 will offer further assistance.
I'm using OneSignal with SPM and I'm getting the same warning. Are there any updates?
@sereisoglu This warning should be resolved if you update to the 3.11.0 SDK and follow the SwiftPM instructions in the release notes:
For Swift Package Manager Use product OneSignal for your app target, and product OneSignalExtension for your Notification Service Extension target. Then in your NotificationService class import OneSignalExtension instead of OneSignal and change references of OneSignal in method bodies to OneSignalExtension
If the above is correct in your project can you share more details about your project?
@jkasten2 Thanks, this worked. I saw that there are 2 OneSignal libraries: https://github.com/OneSignal/OneSignal-iOS-SDK https://github.com/OneSignal/OneSignal-XCFramework What exactly is the difference between them?
@sereisoglu The key thing is that you use OneSignalExtension
in the OneSignalNotificationServiceExtension instead of OneSignal
to fix this warning when using SwiftPM.
OneSignal-XCFramework
was created as SwiftPM as using OneSignal-iOS-SDK
take a lot longer to install since it git clones all history which takes a while to download on this repo.
@jkasten2 When I add OneSignal-iOS-SDK
using SPM, there are two options OneSignal
and OneSignalExtension
which one should I choose here?
If I use OneSignal-XCFramework
do I need to change OneSignal
to OneSignalExtension
?
@sereisoglu
Use OneSignal
for your main app target
Use OneSignalExtension
for your Notification Service Extension target (OneSignalNotificationServiceExtension)
This is the same no matter if you use OneSignal-iOS-SDK
or OneSignal-XCFramework
(recommend for smaller dev download size) for SwiftPM.
If I use Cocoapods and see same issue as @lhasiuk and @Sergozh with complains about [UIApplication sharedApplication]. Any solution? Also, I see that the instructions on the Onesignal tutorial page is not updated either. I tried to move the Extension outside of the main target, but that gives a different error. Any clues on how to do it?
I still get this warning with latest OneSignal framework. Latest Xcode, etc.
See this article for a workaround on how to get rid of this annoying warning. I did only use the OneSignalExtension package for my NotificationService extension and OneSignal package for my main app but that did not solve it.
So, is this still not fixed? Earlier in this thread it was going to be fixed for 3.x, but I'm getting it with 3.12.5, incorporated via SPM.
It’s been nearly five years.
Unbelievable how this is still not fixed as today. Any update on this @emawby? Maybe at least re-open the issue...?
Here is a way to at least silence the warning:
OneSignalServiceExtension
)-Xlinker -no_application_extension
as a new flagHi @JetForMe and @rursache, did you use OneSignalExtension
and not OneSignal
in your NotificationServiceExtension? Can you double check that you have made these changes to your project from the 3.11.0 release notes?
For Cocoapods
- In your Podfile make sure that your Notification Service Extension target is nested in your App target.
- Use pod
OneSignal
orOneSignalXCFramework
(they are now identical) for your app target, and subspecOneSignal/OneSignalExtension
orOneSignalXCFramework/OneSignalExtension
for your Notification Service Extension target.- Then in your NotificationService class import
OneSignalExtension
instead ofOneSignal
- Lastly from the
Other Linker Flags
build setting in your Notification Service Extension target remove$(inherited)
and-framework "OneSignal"
For Swift Package Manager
- Use product
OneSignal
for your app target, and productOneSignalExtension
for your Notification Service Extension target.- Then in your NotificationService class import
OneSignalExtension
instead ofOneSignal
and change references ofOneSignal
in method bodies toOneSignalExtension
If you have made these changes and still seeing errors, can you share what your updated error is?
Description:
Hi,
it is a bit odd that configuring OneSignal requires an app extension and OneSignal.framework is not app extension safe...
Environment
Xcode 9.4.1, integrating using Carthage 0.30.1 using Carthage integration guide
Steps to Reproduce Issue:
Anything else:![screen shot 2018-08-09 at 12 40 12](https://user-images.githubusercontent.com/3148214/43894596-e4a326b2-9bd2-11e8-986f-67946492dfef.png)