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
620 stars 212 forks source link

iOS fails to build after upgrading to 3.0.0 #414

Closed MrTarantula closed 2 years ago

MrTarantula commented 3 years ago

Description: After going through the upgrade steps, the app fails to build for iOS:

ld: warning: linking against a dylib which is not safe for use in application extensions: /Users/runner/work/1/s/build/ios/Release-prod-iphoneos/XCFrameworkIntermediates/OneSignal/OneSignal.framework/OneSignal
    ld: warning: Could not find or use auto-linked framework 'Flutter'
    Undefined symbols for architecture arm64:
      "_OBJC_CLASS_$_FlutterStandardMessageCodec", referenced from:
          objc-class-ref in libwebview_flutter.a(FlutterWebView.o)
      "_OBJC_CLASS_$_FlutterStandardTypedData", referenced from:
          objc-class-ref in libfirebase_remote_config.a(FLTFirebaseRemoteConfigPlugin.o)
          objc-class-ref in libsqflite.a(SqflitePlugin.o)
      "_OBJC_CLASS_$_FlutterError", referenced from:
          objc-class-ref in libfirebase_core.a(FLTFirebasePlugin.o)
          objc-class-ref in libfirebase_dynamic_links.a(FLTFirebaseDynamicLinksPlugin.o)
          objc-class-ref in libonesignal_flutter.a(OSFlutterCategories.o)
          objc-class-ref in libpath_provider.a(FLTPathProviderPlugin.o)
          objc-class-ref in libsqflite.a(SqflitePlugin.o)
          objc-class-ref in liburl_launcher.a(FLTURLLauncherPlugin.o)
          objc-class-ref in libwebview_flutter.a(FlutterWebView.o)
          ...
      "_OBJC_CLASS_$_FlutterMethodChannel", referenced from:
          objc-class-ref in libdevice_info.a(FLTDeviceInfoPlugin.o)
          objc-class-ref in libfirebase_analytics.a(FLTFirebaseAnalyticsPlugin.o)
          objc-class-ref in libfirebase_core.a(FLTFirebaseCorePlugin.o)
          objc-class-ref in libfirebase_crashlytics.a(FLTFirebaseCrashlyticsPlugin.o)
          objc-class-ref in libfirebase_dynamic_links.a(FLTFirebaseDynamicLinksPlugin.o)
          objc-class-ref in libfirebase_remote_config.a(FLTFirebaseRemoteConfigPlugin.o)
          objc-class-ref in libflutter_statusbarcolor.a(FlutterStatusbarcolorPlugin.o)
          ...
      "_FlutterMethodNotImplemented", referenced from:
          -[FLTDeviceInfoPlugin handleMethodCall:result:] in libdevice_info.a(FLTDeviceInfoPlugin.o)
          -[FLTFirebaseAnalyticsPlugin handleMethodCall:result:] in libfirebase_analytics.a(FLTFirebaseAnalyticsPlugin.o)
          -[FLTFirebaseCorePlugin handleMethodCall:result:] in libfirebase_core.a(FLTFirebaseCorePlugin.o)
          -[FLTFirebaseCrashlyticsPlugin handleMethodCall:result:] in libfirebase_crashlytics.a(FLTFirebaseCrashlyticsPlugin.o)
          -[FLTFirebaseDynamicLinksPlugin handleMethodCall:result:] in libfirebase_dynamic_links.a(FLTFirebaseDynamicLinksPlugin.o)
          -[FLTFirebaseRemoteConfigPlugin handleMethodCall:result:] in libfirebase_remote_config.a(FLTFirebaseRemoteConfigPlugin.o)
          -[FlutterStatusbarcolorPlugin handleMethodCall:result:] in libflutter_statusbarcolor.a(FlutterStatusbarcolorPlugin.o)
          ...
    ld: symbol(s) not found for architecture arm64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    ld: warning: linking against a dylib which is not safe for use in application extensions: /Users/runner/work/1/s/build/ios/Release-prod-iphoneos/XCFrameworkIntermediates/OneSignal/OneSignal.framework/OneSignal
    ld: warning: Could not find or use auto-linked framework 'Flutter'

image

Environment

[✓] Flutter (Channel stable, 2.2.1, on macOS 11.4 20F71 darwin-x64, locale en-US) 
    • Flutter version 2.2.1 at /Users/me/Development/flutter
    • Framework revision 02c026b03c (2 weeks ago), 2021-05-27 12:24:44 -0700
    • Engine revision 0fdb562ac8
    • Dart version 2.13.1

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/me/Library/Android/sdk
    • Platform android-29, build-tools 29.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.5, Build version 12E262
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 3.5)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 40.0.2
    • Dart plugin version 191.8423
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] VS Code (version 1.56.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.23.0

[✓] Connected device (2 available)
    • iPhone 12 Pro Max (mobile) • C5521652-455B-447F-BD97-0E56E96F56E6 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
    • Chrome (web)               • chrome                               • web-javascript • Google Chrome 91.0.4472.77

• No issues found!

Steps to Reproduce Issue:

  1. Followed upgrade instructions from OneSignal site.
yunheenet commented 3 years ago

This issue is an error related to arm64 build failure in xcode12 version.

'ld: symbol(s) not found for architecture arm64'

excluded_architectures

I solved the error by adding 'arm64, i386' to the debug/profile/release item of excluded architectures as shown in the picture above.

As a result of the test, 'i386' is omitted and only 'arm64' is added to build.

MrTarantula commented 3 years ago

I already have those same values in my build settings.

yunheenet commented 3 years ago

Did you also proceed with build clean after the setting?

Reference (https://github.com/flutter/flutter/issues/41900#issuecomment-601599410)

MrTarantula commented 3 years ago

I have completely cleaned and rebuilt several times, and those values were already set anyway, so it didn't matter.

MrTarantula commented 3 years ago

One thing that does work is if I change my project configuration to None:

image

It will build but the App Store does not accept it:

ERROR ITMS-90057: "The bundle 'Payload/Runner.app/PlugIns/OneSignalNotificationServiceExtension.appex' is missing plist key. The Info.plist file is missing the required key: CFBundleShortVersionString. Please find more information about CFBundleShortVersionString at https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleshortversionstring"

ERROR ITMS-90360: "Missing Info.plist value. A value for the key 'CFBundleShortVersionString' in bundle Runner.app/PlugIns/OneSignalNotificationServiceExtension.appex is required."

Those values are set by Flutter in Info.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>$(DEVELOPMENT_LANGUAGE)</string>
    <key>CFBundleDisplayName</key>
    <string>OneSignalNotificationServiceExtension</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>$(PRODUCT_NAME)</string>
    <key>CFBundlePackageType</key>
    <string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
    <key>CFBundleShortVersionString</key>
    <string>$(FLUTTER_BUILD_NAME)</string>
    <key>CFBundleVersion</key>
    <string>$(FLUTTER_BUILD_NUMBER)</string>
    <key>NSExtension</key>
    <dict>
        <key>NSExtensionPointIdentifier</key>
        <string>com.apple.usernotifications.service</string>
        <key>NSExtensionPrincipalClass</key>
        <string>NotificationService</string>
    </dict>
</dict>
</plist>

Here is my Debug-dev.xconfig:

#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug-dev.xcconfig"
#include "Generated.xcconfig"

and my Pods-Runner.debug-dev.xcconfig:

CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO 
FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/FirebaseAnalytics/Frameworks" "${PODS_ROOT}/GoogleAppMeasurement/Frameworks" "${PODS_ROOT}/OneSignalXCFramework/iOS_SDK/OneSignalSDK/OneSignal_XCFramework" "${PODS_XCFRAMEWORKS_BUILD_DIR}/FirebaseAnalytics" "${PODS_XCFRAMEWORKS_BUILD_DIR}/GoogleAppMeasurement" "${PODS_XCFRAMEWORKS_BUILD_DIR}/OneSignal"
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 $(inherited) PB_FIELD_32BIT=1 PB_NO_PACKED_STRUCTS=1 PB_ENABLE_MALLOC=1
HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/FMDB" "${PODS_ROOT}/Headers/Public/Firebase" "${PODS_ROOT}/Headers/Public/FirebaseABTesting" "${PODS_ROOT}/Headers/Public/FirebaseCore" "${PODS_ROOT}/Headers/Public/FirebaseCoreDiagnostics" "${PODS_ROOT}/Headers/Public/FirebaseCrashlytics" "${PODS_ROOT}/Headers/Public/FirebaseDynamicLinks" "${PODS_ROOT}/Headers/Public/FirebaseInstallations" "${PODS_ROOT}/Headers/Public/FirebaseRemoteConfig" "${PODS_ROOT}/Headers/Public/GoogleDataTransport" "${PODS_ROOT}/Headers/Public/GoogleUtilities" "${PODS_ROOT}/Headers/Public/PromisesObjC" "${PODS_ROOT}/Headers/Public/device_info" "${PODS_ROOT}/Headers/Public/firebase_analytics" "${PODS_ROOT}/Headers/Public/firebase_core" "${PODS_ROOT}/Headers/Public/firebase_crashlytics" "${PODS_ROOT}/Headers/Public/firebase_dynamic_links" "${PODS_ROOT}/Headers/Public/firebase_remote_config" "${PODS_ROOT}/Headers/Public/flutter_statusbarcolor" "${PODS_ROOT}/Headers/Public/fluttertoast" "${PODS_ROOT}/Headers/Public/nanopb" "${PODS_ROOT}/Headers/Public/onesignal_flutter" "${PODS_ROOT}/Headers/Public/package_info" "${PODS_ROOT}/Headers/Public/path_provider" "${PODS_ROOT}/Headers/Public/shared_preferences" "${PODS_ROOT}/Headers/Public/sqflite" "${PODS_ROOT}/Headers/Public/url_launcher" "${PODS_ROOT}/Headers/Public/webview_flutter" $(inherited) ${PODS_ROOT}/Firebase/CoreOnly/Sources "${PODS_TARGET_SRCROOT}/Sources/FBLPromises/include"
LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/FMDB" "${PODS_CONFIGURATION_BUILD_DIR}/FirebaseABTesting" "${PODS_CONFIGURATION_BUILD_DIR}/FirebaseCore" "${PODS_CONFIGURATION_BUILD_DIR}/FirebaseCoreDiagnostics" "${PODS_CONFIGURATION_BUILD_DIR}/FirebaseCrashlytics" "${PODS_CONFIGURATION_BUILD_DIR}/FirebaseDynamicLinks" "${PODS_CONFIGURATION_BUILD_DIR}/FirebaseInstallations" "${PODS_CONFIGURATION_BUILD_DIR}/FirebaseRemoteConfig" "${PODS_CONFIGURATION_BUILD_DIR}/GoogleDataTransport" "${PODS_CONFIGURATION_BUILD_DIR}/GoogleUtilities" "${PODS_CONFIGURATION_BUILD_DIR}/PromisesObjC" "${PODS_CONFIGURATION_BUILD_DIR}/device_info" "${PODS_CONFIGURATION_BUILD_DIR}/firebase_analytics" "${PODS_CONFIGURATION_BUILD_DIR}/firebase_core" "${PODS_CONFIGURATION_BUILD_DIR}/firebase_crashlytics" "${PODS_CONFIGURATION_BUILD_DIR}/firebase_dynamic_links" "${PODS_CONFIGURATION_BUILD_DIR}/firebase_remote_config" "${PODS_CONFIGURATION_BUILD_DIR}/flutter_statusbarcolor" "${PODS_CONFIGURATION_BUILD_DIR}/fluttertoast" "${PODS_CONFIGURATION_BUILD_DIR}/nanopb" "${PODS_CONFIGURATION_BUILD_DIR}/onesignal_flutter" "${PODS_CONFIGURATION_BUILD_DIR}/package_info" "${PODS_CONFIGURATION_BUILD_DIR}/path_provider" "${PODS_CONFIGURATION_BUILD_DIR}/shared_preferences" "${PODS_CONFIGURATION_BUILD_DIR}/sqflite" "${PODS_CONFIGURATION_BUILD_DIR}/url_launcher" "${PODS_CONFIGURATION_BUILD_DIR}/webview_flutter"
OTHER_CFLAGS = $(inherited) -fmodule-map-file="${PODS_ROOT}/Headers/Public/device_info/device_info.modulemap" -fmodule-map-file="${PODS_ROOT}/Headers/Public/firebase_analytics/firebase_analytics.modulemap" -fmodule-map-file="${PODS_ROOT}/Headers/Public/firebase_core/firebase_core.modulemap" -fmodule-map-file="${PODS_ROOT}/Headers/Public/firebase_crashlytics/firebase_crashlytics.modulemap" -fmodule-map-file="${PODS_ROOT}/Headers/Public/firebase_dynamic_links/firebase_dynamic_links.modulemap" -fmodule-map-file="${PODS_ROOT}/Headers/Public/firebase_remote_config/firebase_remote_config.modulemap" -fmodule-map-file="${PODS_ROOT}/Headers/Public/package_info/package_info.modulemap" -fmodule-map-file="${PODS_ROOT}/Headers/Public/path_provider/path_provider.modulemap" -fmodule-map-file="${PODS_ROOT}/Headers/Public/shared_preferences/shared_preferences.modulemap" -fmodule-map-file="${PODS_ROOT}/Headers/Public/sqflite/sqflite.modulemap" -fmodule-map-file="${PODS_ROOT}/Headers/Public/url_launcher/url_launcher.modulemap" -fmodule-map-file="${PODS_ROOT}/Headers/Public/webview_flutter/webview_flutter.modulemap"
OTHER_LDFLAGS = $(inherited) -ObjC -l"FMDB" -l"FirebaseABTesting" -l"FirebaseCore" -l"FirebaseCoreDiagnostics" -l"FirebaseCrashlytics" -l"FirebaseDynamicLinks" -l"FirebaseInstallations" -l"FirebaseRemoteConfig" -l"GoogleDataTransport" -l"GoogleUtilities" -l"PromisesObjC" -l"c++" -l"device_info" -l"firebase_analytics" -l"firebase_core" -l"firebase_crashlytics" -l"firebase_dynamic_links" -l"firebase_remote_config" -l"flutter_statusbarcolor" -l"fluttertoast" -l"nanopb" -l"onesignal_flutter" -l"package_info" -l"path_provider" -l"shared_preferences" -l"sqflite" -l"sqlite3" -l"url_launcher" -l"webview_flutter" -l"z" -framework "CoreTelephony" -framework "FirebaseAnalytics" -framework "Foundation" -framework "GoogleAppMeasurement" -framework "OneSignal" -framework "QuartzCore" -framework "Security" -framework "StoreKit" -framework "SystemConfiguration" -framework "UIKit" -weak_framework "WebKit"
OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS -Xcc -fmodule-map-file="${PODS_ROOT}/Headers/Public/device_info/device_info.modulemap" -Xcc -fmodule-map-file="${PODS_ROOT}/Headers/Public/firebase_analytics/firebase_analytics.modulemap" -Xcc -fmodule-map-file="${PODS_ROOT}/Headers/Public/firebase_core/firebase_core.modulemap" -Xcc -fmodule-map-file="${PODS_ROOT}/Headers/Public/firebase_crashlytics/firebase_crashlytics.modulemap" -Xcc -fmodule-map-file="${PODS_ROOT}/Headers/Public/firebase_dynamic_links/firebase_dynamic_links.modulemap" -Xcc -fmodule-map-file="${PODS_ROOT}/Headers/Public/firebase_remote_config/firebase_remote_config.modulemap" -Xcc -fmodule-map-file="${PODS_ROOT}/Headers/Public/package_info/package_info.modulemap" -Xcc -fmodule-map-file="${PODS_ROOT}/Headers/Public/path_provider/path_provider.modulemap" -Xcc -fmodule-map-file="${PODS_ROOT}/Headers/Public/shared_preferences/shared_preferences.modulemap" -Xcc -fmodule-map-file="${PODS_ROOT}/Headers/Public/sqflite/sqflite.modulemap" -Xcc -fmodule-map-file="${PODS_ROOT}/Headers/Public/url_launcher/url_launcher.modulemap" -Xcc -fmodule-map-file="${PODS_ROOT}/Headers/Public/webview_flutter/webview_flutter.modulemap"
PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
PODS_ROOT = ${SRCROOT}/Pods
PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates
USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
yunheenet commented 3 years ago

'ERROR ITMS-90057: "The bundle 'Payload/Runner.app/PlugIns/OneSignalNotificationServiceExtension.appex' is missing plist key.' is located 'ios/OneSignalNotificationServiceExtension/info.plist'

in my value is

<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>

<key>CFBundleVersion</key>
<string>1</string>
MrTarantula commented 3 years ago

That looks to be a custom build variable set up by you or your team. FLUTTER_BUILD_NUMBER comes from Flutter, and also appears in my app's Info.plist..

mgonzalezc commented 3 years ago

Hello!

I may be late but this may help someone facing a similar issue.

When you are adding an extension to a Flutter project, please, check the Other Linker Flags under the Build Settings of the extension.

For me, they looked like this:

other linker flags

This is, the extension was trying to link all the libraries but it didn't know how to do it and here it was failing.

To solve the issue, just double click on the libraries, select all of them in the dialog and click remove (- button). In the end, it should look like this:

empty

After this, I could run my extension without any issue

ihadabs commented 3 years ago

Same here, I its annoying 😢 that I need to exclude the arm64 architecture eveytime I run the app on an iOS simulator.

Thanks for the great work, hope this issue get resolved ASAP.