【问题标题】:Flutter Braintree not working in Apple M1Flutter Braintree 在 Apple M1 中不起作用
【发布时间】:2021-12-29 12:32:52
【问题描述】:

我在 Apple M1 中编译 Flutter Braintree 时遇到问题。 我什至尝试只使用flutter_braintree 2.2.0创建一个新项目,仍然无法编译。

附上项目的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!

日志

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.

【问题讨论】:

    标签: flutter flutter-dependencies braintree flutter-test apple-m1


    【解决方案1】:

    在 Podfile 上添加这段代码,

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

    并从 Xcode 通行证构建 iOS 9.0 到 12.0

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-04
      • 2021-04-03
      • 1970-01-01
      • 2017-08-16
      • 2018-05-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多