OneSignal / OneSignal-Flutter-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your flutter app with OneSignal
https://www.onesignal.com
Other
606 stars 204 forks source link

[Bug]: No Module Found "OneSignalExtension" in NotificationService.swift #857

Open asadamatic opened 3 months ago

asadamatic commented 3 months ago

What happened?

I followed this Flutter SDK setup guide. I used the provided swift code and my iOS build kept failing after it. I rebuilt my app using XCode, and it gave me this error in the NotificaitonService swift file.

Steps to reproduce?

1. Use the code provided in the Flutter SDK Setup guide for the `NotificationService` swift file.
2. Try building the Flutter app for iOS normally, and it will fail without providing much information.
3. Build the app using XCode.

What did you expect to happen?

I expected the code from the official guide to work without any issues.

OneSignal Flutter SDK version

Release 5.1.2

Which platform(s) are affected?

Relevant log output

OneSignalNotificationServiceExtension
/Users/user/AndroidStudioProjects/shopify_app/ios/OneSignalNotificationServiceExtension/NotificationService.swift
/Users/user/AndroidStudioProjects/shopify_app/ios/OneSignalNotificationServiceExtension/NotificationService.swift:45:8 No such module 'OneSignalExtension'

flutter_local_notifications
/Users/user/.pub-cache/hosted/pub.dev/flutter_local_notifications-16.3.3/ios/Classes/FlutterLocalNotificationsPlugin.m
/Users/user/.pub-cache/hosted/pub.dev/flutter_local_notifications-16.3.3/ios/Classes/FlutterLocalNotificationsPlugin.m:6:17 Method definition for 'setRegisterPlugins:' not found

flutter_local_notifications-flutter_local_notifications_privacy
/Users/user/AndroidStudioProjects/shopify_app/ios/Pods/Pods.xcodeproj The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 9.0, but the range of supported deployment target versions is 12.0 to 17.4.99.

onesignal_flutter
/Users/user/.pub-cache/hosted/pub.dev/onesignal_flutter-5.1.2/ios/Classes/OneSignalPlugin.m
/Users/user/.pub-cache/hosted/pub.dev/onesignal_flutter-5.1.2/ios/Classes/OneSignalPlugin.m:58:16 Null passed to a callee that requires a non-null argument

/Users/user/.pub-cache/hosted/pub.dev/onesignal_flutter-5.1.2/ios/Classes/OSFlutterInAppMessages.m
/Users/user/.pub-cache/hosted/pub.dev/onesignal_flutter-5.1.2/ios/Classes/OSFlutterInAppMessages.m:104:47 Incompatible pointer types sending 'OSFlutterInAppMessages *' to parameter of type 'NSObject<OSInAppMessageClickListener> * _Nullable'

/Users/user/.pub-cache/hosted/pub.dev/onesignal_flutter-5.1.2/ios/Classes/OSFlutterPushSubscription.m
/Users/user/.pub-cache/hosted/pub.dev/onesignal_flutter-5.1.2/ios/Classes/OSFlutterPushSubscription.m:33:17 Method definition for 'sharedInstance' not found

/Users/user/.pub-cache/hosted/pub.dev/onesignal_flutter-5.1.2/ios/Classes/OSFlutterUser.m
/Users/user/.pub-cache/hosted/pub.dev/onesignal_flutter-5.1.2/ios/Classes/OSFlutterUser.m:91:35 Incompatible pointer types sending 'NSDictionary *' to parameter of type 'NSArray<NSString *> * _Nonnull'

/Users/user/.pub-cache/hosted/pub.dev/onesignal_flutter-5.1.2/ios/Classes/OSFlutterUser.m:103:32 Incompatible pointer types sending 'NSDictionary *' to parameter of type 'NSArray<NSString *> * _Nonnull'

OneSignalXCFramework
/Users/user/AndroidStudioProjects/shopify_app/ios/Pods/Pods.xcodeproj The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 11.0, but the range of supported deployment target versions is 12.0 to 17.4.99.

Code of Conduct

markosole commented 1 month ago

I am having same issue, with error on Podfile import:

import UserNotifications

import OneSignalExtension    // < Shows error No such modlue 'OneSignalExtension'
// rest of the swift code...

I am using Xcode version 14.1 and flutter version 3.19.6 with Dart 3.3.4. I have repeated steps 3 times following guide. Only thing that isn't available in this Xcode is "Minimum Deployments" for iOS version. There is only "Deployment Target".

@asadamatic have you managed to get it working?

elishae621 commented 1 month ago

I am having the exact same problem. @markosole have you found a solution?

markosole commented 1 month ago

Hi @elishae621 yes I have manged to sort it out and it works now. There are few things that I did:

One last thing is to adjust settings in your project (you will run into issues if you don't. Check this post for details: https://github.com/OneSignal/OneSignal-Flutter-SDK/issues/790

In Xcode, in your app target build phases, you should have something called "Embed App Extensions" or "Embed Foundation Extensions" at the end of the build phases. If you drag it BEFORE "Run Script", it should prevent this build error to happen.

It will probably be somewhere at the bottom, so drag and drop it above. Now your can built your app ;)

image