OneSignal-Flutter-SDK icon indicating copy to clipboard operation
OneSignal-Flutter-SDK copied to clipboard

[Bug]: Getting error when tryping to run on iOS17 - XCode 15

Open dchandrani opened this issue 2 years ago • 20 comments
trafficstars

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?

1. Use XCode 15
2. Updated onesignal_flutter: ^5.0.1
3. Run project on simulator

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?

  • [X] iOS
  • [ ] Android

Relevant log output

Xcode build done.                                           17.6s
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.

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

dchandrani avatar Sep 19 '23 13:09 dchandrani

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

emawby avatar Sep 19 '23 17:09 emawby

This has been an enormous time suck trying to migrate - and now I'm finding out the docs aren't finished yet.

michael-joseph-payne avatar Sep 22 '23 19:09 michael-joseph-payne

@tgloc96 Interesting I am not able to reproduce that. The only similar issue I have found is this one in another SDK

emawby avatar Sep 22 '23 20:09 emawby

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. Screenshot 2023-09-25 at 2 40 30 PM

ThakarRajesh avatar Sep 25 '23 09:09 ThakarRajesh

@ThakarRajesh It's not working in my case.

Screenshot 2023-09-25 at 3 28 13 PM

dchandrani avatar Sep 25 '23 09:09 dchandrani

@ThakarRajesh Getting error Framework 'OneSignal' not found.

Screenshot 2023-09-25 at 3 33 31 PM

dchandrani avatar Sep 25 '23 10:09 dchandrani

same here after upgrade xcode version to 15

husainazkas avatar Sep 27 '23 09:09 husainazkas

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

image

It should now look like this image

emawby avatar Sep 27 '23 16:09 emawby

@emawby Did add the way you have mentioned. But still not able to build the project.

Screenshot 2023-09-27 at 10 16 19 PM

dchandrani avatar Sep 27 '23 16:09 dchandrani

Add like emawby mentioned and import OneSignalFramework works for me.

andj207 avatar Sep 30 '23 08:09 andj207

The same problem, and I looked at this, it works.

https://stackoverflow.com/questions/77187534/cycle-inside-project-building-could-produce-unreliable-results-cycle-details

secretmoo35 avatar Oct 02 '23 11:10 secretmoo35

@emawby Did add the way you have mentioned. But still not able to build the project.

Screenshot 2023-09-27 at 10 16 19 PM

Sorry like andj207 mentioned you also must import OneSignalFramework

emawby avatar Oct 02 '23 17:10 emawby

@emawby import OneSignalFramework in what file?

temcewen avatar Oct 03 '23 01:10 temcewen

The same problem, and I looked at this, it works.

https://stackoverflow.com/questions/77187534/cycle-inside-project-building-could-produce-unreliable-results-cycle-details

  1. You can use OneSignal as is without the need to import anything additional.
  2. Open "TARGETS > Runner > Build Phases" and move "Embed Foundation Extensions" Above "Thin Binary"
Screenshot 2566-10-03 at 09 08 39 Screenshot 2566-10-03 at 09 08 28 Screenshot 2566-10-03 at 09 09 43

secretmoo35 avatar Oct 03 '23 02:10 secretmoo35

@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.

temcewen avatar Oct 03 '23 02:10 temcewen

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 avatar Oct 03 '23 18:10 shkvoretz

@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)
        }
    }
    
}

temcewen avatar Oct 03 '23 18:10 temcewen

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.

temcewen avatar Oct 03 '23 18:10 temcewen

@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?

emawby avatar Oct 06 '23 19:10 emawby

In case it's Friday afternoon or anytime after 1am: Opening xcodeproj instead of xcworkspace will cause an error like this...

https://stackoverflow.com/questions/29500227/getting-error-no-such-module-using-xcode-but-the-framework-is-there

Solved it... Phew after 3 days

Vedsaga avatar May 28 '24 18:05 Vedsaga