Flutter Braintree not working in Apple M1

Viewed 177

I am having issues while compiling Flutter Braintree in Apple M1. I even tried creating a new project only with flutter_braintree 2.2.0, still doesn't compile.

Attached is the flutter doctor and logs of the project.

Flutter Doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.8.1, on macOS 12.0.1 21A559 darwin-arm, locale en-AU)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0-rc5)
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] VS Code (version 1.61.2)
[✓] Connected device (2 available)

• No issues found!

Logs

Launching lib/main.dart on iPhone 13 in debug mode...
Running pod install...
Running Xcode build...
Xcode build done.                                            6.8s
Failed to build iOS app
Error output from Xcode build:
↳
    objc[95440]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libamsupport.dylib (0x1da8cf130) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x107bc02c8). One of the two will be used. Which one is undefined.
    objc[95440]: Class AMSupportURLSession is implemented in both /usr/lib/libamsupport.dylib (0x1da8cf180) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x107bc0318). One of the two will be used. Which one is undefined.
    ** BUILD FAILED **


Xcode's output:
↳
    /Users/project/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_braintree-2.2.0/ios/Classes/FlutterBraintreeDropInPlugin.swift:163:121: warning: expression implicitly coerced from 'String?' to 'Any'
                    flutterResult(["paymentMethodNonce": buildPaymentNonceDict(nonce: result?.paymentMethod), "deviceData": deviceData])
                                                                                          ^~~~~~~~~~
    /Users/project/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_braintree-2.2.0/ios/Classes/FlutterBraintreeDropInPlugin.swift:163:121: note: provide a default value to avoid this warning
                    flutterResult(["paymentMethodNonce": buildPaymentNonceDict(nonce: result?.paymentMethod), "deviceData": deviceData])
                                                                                          ^~~~~~~~~~
                                                                                          ?? <#default value#>
    /Users/project/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_braintree-2.2.0/ios/Classes/FlutterBraintreeDropInPlugin.swift:163:121: note: force-unwrap the value to avoid this warning
                    flutterResult(["paymentMethodNonce": buildPaymentNonceDict(nonce: result?.paymentMethod), "deviceData": deviceData])
                                                                                          ^~~~~~~~~~
                                                                                          !
    /Users/project/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_braintree-2.2.0/ios/Classes/FlutterBraintreeDropInPlugin.swift:163:121: note: explicitly cast to 'Any' with 'as Any' to silence this warning
                    flutterResult(["paymentMethodNonce": buildPaymentNonceDict(nonce: result?.paymentMethod), "deviceData": deviceData])
                                                                                          ^~~~~~~~~~
                                                                                          as Any
    Command CompileSwiftSources failed with a nonzero exit code
    /Users/project/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_braintree-2.2.0/ios/Classes/BaseFlutterBraintreePlugin.swift:3:8: error: could not find module 'Braintree' for target 'arm64-apple-ios-simulator'; found: x86_64-apple-ios-simulator, x86_64, at: /Users/project/Developer/testing_braintree/build/ios/Debug-iphonesimulator/Braintree/Braintree.framework/Modules/Braintree.swiftmodule
    import Braintree
           ^
    /Users/project/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_braintree-2.2.0/ios/Classes/BaseFlutterBraintreePlugin.swift:3:8: error: could not find module 'Braintree' for target 'arm64-apple-ios-simulator'; found: x86_64-apple-ios-simulator, x86_64, at: /Users/project/Developer/testing_braintree/build/ios/Debug-iphonesimulator/Braintree/Braintree.framework/Modules/Braintree.swiftmodule
    import Braintree
           ^
    /Users/project/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_braintree-2.2.0/ios/Classes/BaseFlutterBraintreePlugin.swift:3:8: error: could not find module 'Braintree' for target 'arm64-apple-ios-simulator'; found: x86_64-apple-ios-simulator, x86_64, at: /Users/project/Developer/testing_braintree/build/ios/Debug-iphonesimulator/Braintree/Braintree.framework/Modules/Braintree.swiftmodule
    import Braintree
           ^
    note: Using new build system
    note: Planning
    note: Build preparation complete
    note: Building targets in dependency order

Could not build the application for the simulator.
Error launching application on iPhone 13.
1 Answers

Add this code on the Podfile,

 post_install do |installer|
  installer.pods_project.build_configurations.each do |config|
    config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
  end
end

And from Xcode pass to build iOS 9.0 to 12.0

Related