Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
2 of 3 tasks
dchandrani opened this issue Sep 19, 2023 · 20 comments
Closed
2 of 3 tasks

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

dchandrani opened this issue Sep 19, 2023 · 20 comments

Comments

@dchandrani
Copy link

dchandrani commented Sep 19, 2023

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?

  • 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

  • I agree to follow this project's Code of Conduct
@emawby
Copy link
Contributor

emawby commented Sep 19, 2023

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

@michael-joseph-payne
Copy link

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

@emawby
Copy link
Contributor

emawby commented Sep 22, 2023

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

@ThakarRajesh
Copy link

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

@dchandrani
Copy link
Author

@ThakarRajesh It's not working in my case.

Screenshot 2023-09-25 at 3 28 13 PM

@dchandrani
Copy link
Author

@ThakarRajesh Getting error Framework 'OneSignal' not found.

Screenshot 2023-09-25 at 3 33 31 PM

@husainazkas
Copy link

same here after upgrade xcode version to 15

@emawby
Copy link
Contributor

emawby commented Sep 27, 2023

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

@dchandrani
Copy link
Author

@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

@andj207
Copy link

andj207 commented Sep 30, 2023

Add like emawby mentioned and import OneSignalFramework works for me.

@secretmoo35
Copy link

@emawby
Copy link
Contributor

emawby commented Oct 2, 2023

@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

@temcewen
Copy link

temcewen commented Oct 3, 2023

@emawby import OneSignalFramework in what file?

@secretmoo35
Copy link

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

@temcewen
Copy link

temcewen commented Oct 3, 2023

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

@sv-22
Copy link

sv-22 commented Oct 3, 2023

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.

@temcewen
Copy link

temcewen commented Oct 3, 2023

@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
Copy link

temcewen commented Oct 3, 2023

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.

@emawby
Copy link
Contributor

emawby commented Oct 6, 2023

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

@Vedsaga
Copy link

Vedsaga commented May 28, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests