Open dchandrani opened 9 months ago
Hello I apologize we are working on updating our migration guide here. You likely need to update your import in your Notification Service Extension to be OneSignalFramework/OneSignalFramework.h
This has been an enormous time suck trying to migrate - and now I'm finding out the docs aren't finished yet.
@tgloc96 Interesting I am not able to reproduce that. The only similar issue I have found is this one in another SDK
Hello @dchandrani
I had the same problem. That is how I resolved it.
Change OneSignal to OneSignalFramework in the NotificationService.swift file to make it work in my app.
@ThakarRajesh It's not working in my case.
@ThakarRajesh Getting error Framework 'OneSignal' not found.
same here after upgrade xcode version to 15
That issue is usually with cocoapods having bad derived/cached data, however I would need to see your podfile to confirm.
However you also have the option of not using Cocoapods for the notification service extension target. You could try the following: Remove OneSignal from your NotificationServiceExtension section of your podfile completely. Then in Xcode navigate to the Notification Service Extension project settings and add the following XCFrameworks as dependencies: OneSignalCore.xcframework OneSignalOutcomes.xcframework OneSignalExtension.xcframework
It should now look like this
@emawby Did add the way you have mentioned. But still not able to build the project.
Add like emawby mentioned and import OneSignalFramework
works for me.
The same problem, and I looked at this, it works.
@emawby Did add the way you have mentioned. But still not able to build the project.
![]()
Sorry like andj207 mentioned you also must import OneSignalFramework
@emawby import OneSignalFramework in what file?
The same problem, and I looked at this, it works.
@secretmoo35 I appreciate the response, but I had already tried that and it didn't work.
@emawby I was able to figure out what you meant by import OneSignalFramework
, but I was using Objective-C instead of Swift at the time so I didn't figure it out till I tried to switch. It's working for me now. I do wonder what the import would have been for the Objective-C version.
Also having this issue on M1.
OneSignal integration is very frustrating, the amount of effort that we invested in constantly getting this thing to work has been massive. If this isn't resolved in timely manner we'll be switching.
@shkvoretz Nobody can help you without specifics. Are you getting the exact same error: "'OneSignal' not found"?
If so, follow the instructions that @emawby said to do, use Swift instead of Objective-C for your Notification Service Extension, and then copy this code into the Notification.swift under the OneSignalNotificationServiceExtension folder:
import UserNotifications
import OneSignalFramework
class NotificationService: UNNotificationServiceExtension {
var contentHandler: ((UNNotificationContent) -> Void)?
var receivedRequest: UNNotificationRequest!
var bestAttemptContent: UNMutableNotificationContent?
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
self.receivedRequest = request
self.contentHandler = contentHandler
self.bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
if let bestAttemptContent = bestAttemptContent {
//If your SDK version is < 3.5.0 uncomment and use this code:
/*
OneSignal.didReceiveNotificationExtensionRequest(self.receivedRequest, with: self.bestAttemptContent)
contentHandler(bestAttemptContent)
*/
/* DEBUGGING: Uncomment the 2 lines below to check this extension is excuting
Note, this extension only runs when mutable-content is set
Setting an attachment or action buttons automatically adds this */
//OneSignal.setLogLevel(.LL_VERBOSE, visualLevel: .LL_NONE)
//bestAttemptContent.body = "[Modified] " + bestAttemptContent.body
OneSignal.didReceiveNotificationExtensionRequest(self.receivedRequest, with: bestAttemptContent, withContentHandler: self.contentHandler)
}
}
override func serviceExtensionTimeWillExpire() {
// Called just before the extension will be terminated by the system.
// Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent {
OneSignal.serviceExtensionTimeWillExpireRequest(self.receivedRequest, with: self.bestAttemptContent)
contentHandler(bestAttemptContent)
}
}
}
OneSignal integration is very frustrating, the amount of effort that we invested in constantly getting this thing to work has been massive. If this isn't resolved in timely manner we'll be switching.
I know it seems difficult, but I think all notification service providers have a tough setup, and from what I've heard, OneSignal has the best service with one of the easiest setups. The issue is that they are doing a huge update from 3.x to 5.x. It's frustrating for sure, I spend 8 hours of a 12 hour day on fixing our implementation yesterday. However, the alternatives are probably worse, you're welcome to try them out though.
@shkvoretz Unfortunately these issues are with Cocoapods/NotificationServiceExtensions and are hard to debug if we cannot reproduce them. If none of the solutions in these threads have resolved your issue could you share a sample project that is experiencing the problem?
In case it's Friday afternoon or anytime after 1am: Opening xcodeproj instead of xcworkspace will cause an error like this...
Solved it... Phew after 3 days
What happened?
I updated my Xcode and migrated onesignal_flutter to 5.0.1. I have also updated pod file as instructed (pod 'OneSignalXCFramework', '>= 5.0.0', '< 6.0').
Still, I'm getting this error: Error (Xcode): Framework 'OneSignal' not found
Error (Xcode): Linker command failed with exit code 1 (use -v to see invocation)
Steps to reproduce?
What did you expect to happen?
You might encounter following error:
Failed to build iOS app Error (Xcode): Framework 'OneSignal' not found
Error (Xcode): Linker command failed with exit code 1 (use -v to see invocation)
Could not build the application for the simulator. Error launching application on iPhone 15.
OneSignal Flutter SDK version
5.0.1
Which platform(s) are affected?
Relevant log output
Code of Conduct