Search code examples
iosflutterrevenuecat

Flutter iOS build failed after Flutter 1.22 upgrade


I just upgraded my Flutter version to 1.22.0. After upgrading and making some changes for Firebase my Android app started working, but I am unable to build and run the iOS app on emulator or on physical device.

The terminal shows the following errors when I try to run the app in the emulator or physical device. The emulator runs on iOS 14 and the physical device is on 14.0.1.

Emulator: ld: symbol(s) not found for architecture x86_64
Actual device: ld: symbol(s) not found for architecture arm64

I also executed the following commands but still not working...

flutter clean && \
rm ios/Podfile ios/Podfile.lock pubspec.lock && \
rm -rf ios/Pods ios/Runner.xcworkspace && \ 
flutter run

Flutter Doctor:

[✓] Flutter (Channel stable, 1.22.0, on Mac OS X 10.15.7 19H2, locale en-US)
    • Flutter version 1.22.0 at /Volumes/demouser/Flutter/FlutterSDK/flutter
    • Framework revision d408d302e2 (7 days ago), 2020-09-29 11:49:17 -0700
    • Engine revision 5babba6c4d
    • Dart version 2.10.0

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/demouserdemouser/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_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.0.1, Build version 12A7300
    • CocoaPods version 1.9.3

[✓] Android Studio (version 4.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 49.0.2
    • Dart plugin version 193.7547
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

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

[✓] Connected device (1 available)
    • AOSP on IA Emulator (mobile) • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)

• No issues found!

pubspec.yaml

name: demo
description: demo
version: 1.0.0+1

environment:
  sdk: ">=2.5.2 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^1.0.0
  firebase_auth: ^0.18.1+1
  cloud_firestore: ^0.14.1+2
  firebase_messaging: ^6.0.16
  firebase_storage: ^5.0.0-dev.2
  firebase_core: ^0.5.0
  firebase_admob: ^0.10.0+1
  intl_translation: ^0.17.10+1
  http: ^0.12.2
  xml: ^4.5.1
  shared_preferences: ^0.5.12
  flutter_staggered_grid_view: ^0.3.0
  flutter_signin_button: ^1.0.0
  image_picker: ^0.6.7+11
  mlkit: ^0.15.1
  cached_network_image: ^2.3.2+1
  permission_handler: ^5.0.1+1
  url_launcher: ^5.7.2
  share: ^0.6.5+2
  simple_connectivity: ^0.1.1
  us_states: ^1.0.3
  cloud_functions: ^0.6.0+1
  email_validator: ^1.0.4
  package_info: ^0.4.3
  device_info: ^0.4.2+8
  expandable: ^4.1.4
  launch_review: ^2.0.0
  xml2json: ^4.4.0
  purchases_flutter: ^1.3.1

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_launcher_icons: ^0.7.5

flutter_icons:
  image_path: "icon/new_icon.png"
  android: false
  ios: true

Terminal's output:

> Launching lib/main.dart on physical iPhone in debug mode...
> Automatically signing iOS for device deployment using specified
> development team in Xcode project: 5ABCDEFG9 Running Xcode build...
> Xcode build done.                                           118.3s
> Failed to build iOS app Error output from Xcode build: ↳
>     2020-10-06 10:59:58.676 xcodebuild[7528:47880]  DTDeviceKit: deviceType from a578d1d6cb0d414525f7dc4c6cee was NULL
>     2020-10-06 10:59:58.778 xcodebuild[7528:47881]  DTDeviceKit: deviceType from a578d1d6cb0d414525f7dc4c6cee was NULL
>     2020-10-06 10:59:58.778 xcodebuild[7528:47881]  DTDeviceKit: deviceType from a578d1d6cb0d414525f7dc4c6cee was NULL
>     ** BUILD FAILED **
Xcode's output:
↳
    /Volumes/driveD/Flutter/FlutterSDK/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.7.2/ios/Classes/FLTURLLauncherPlugin.m:153:57: warning: 'keyWindow' is deprecated: first deprecated in iOS 13.0 - Should not be used for applications that support multiple scenes as it returns a key window across all connected scenes [-Wdeprecated-declarations]
                                                           .keyWindow.rootViewController];
                                                            ^
    In module 'UIKit' imported from /Volumes/driveD/projects/new/demo/ios/Pods/Target Support Files/url_launcher/url_launcher-prefix.pch:2:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.h:134:51: note: 'keyWindow' has been explicitly marked deprecated here
    @property(nullable, nonatomic,readonly) UIWindow *keyWindow API_DEPRECATED("Should not be used for applications that support multiple scenes as it returns a key window across all connected scenes", ios(2.0, 13.0));


   -------
 ld: symbol(s) not found for architecture arm64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Constructing build description

Could not build the precompiled application for the device.

Error launching application on physical’s iPhone.

It looks like this problem is coming due to RevenueCat API. When I comment out the import purchases_flutter in the pubspec.yaml file then I am able to install the app but it crashes at startup saying connection lost.


Solution

  • Finally after doing lot of changes, I found out that the culprit was the purchases_flutter: ^1.3.1 package.

    When I remove the package from my yaml file then it starts working. There is a bug already opened for it https://github.com/RevenueCat/purchases-flutter/issues/120.

    Thank you every one for your time and help.