pikaju / flutter-braintree

Flutter plugin that wraps the native Braintree SDKs. Enables payments with credit cards, PayPal, Google Pay and more.
https://pub.dev/packages/flutter_braintree
MIT License
64 stars 116 forks source link

Can't build for iOS on M1 Mac #97

Closed SeriousMonk closed 2 years ago

SeriousMonk commented 2 years ago

When building for iOS on a macbook with Apple's M1 chip I get the following:

Launching lib/main.dart on iPhone 13 in debug mode...
Running pod install...
Running Xcode build...
Xcode build done.                                            5.9s
Failed to build iOS app
Error output from Xcode build:
↳
    --- xcodebuild: WARNING: Using the first of multiple matching destinations:
    { platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Any iOS Simulator Device }
    { platform:iOS Simulator, id:FCD8FF6E-F729-410F-A8AA-B221820307FE, OS:15.0, name:iPad (9th generation) }
    { platform:iOS Simulator, id:DCAABD82-0D1C-44A8-93A8-645030B57419, OS:15.0, name:iPad Air (4th generation) }
    { platform:iOS Simulator, id:659E68E1-9832-4778-BA7E-6AC5D6C1914B, OS:15.0, name:iPad Pro (9.7-inch) }
    { platform:iOS Simulator, id:34D4BD20-A9AE-425E-9433-F784A7110B1E, OS:15.0, name:iPad Pro (11-inch) (3rd generation) }
    { platform:iOS Simulator, id:5A792C68-651F-4079-AF4F-C3D8E6C56879, OS:15.0, name:iPad Pro (12.9-inch) (5th generation) }
    { platform:iOS Simulator, id:30936882-4BDA-475F-B1A6-CC2D5E921953, OS:15.0, name:iPad mini (6th generation) }
    { platform:iOS Simulator, id:8D8ACE63-502E-42B3-91AE-B51BBC74E337, OS:15.0, name:iPhone 8 }
    { platform:iOS Simulator, id:5569F036-40CB-4FE0-BF25-1B7FC6A9AEE5, OS:15.0, name:iPhone 8 Plus }
    { platform:iOS Simulator, id:553391BE-4C3F-4407-9834-04C7E4D6E6EC, OS:15.0, name:iPhone 11 }
    { platform:iOS Simulator, id:28762146-A8BD-4591-BDD6-0B02854904B7, OS:15.0, name:iPhone 11 Pro }
    { platform:iOS Simulator, id:A9EDF32A-6C67-49D3-82BD-8ABB686039A6, OS:15.0, name:iPhone 11 Pro Max }
    { platform:iOS Simulator, id:56660E0B-230E-4355-A3F2-79B2E71EB777, OS:15.0, name:iPhone 12 }
    { platform:iOS Simulator, id:5F7D29AE-B024-4CEB-9038-6FE67F9C3EFC, OS:15.0, name:iPhone 12 Pro }
    { platform:iOS Simulator, id:DCE48F47-EA8D-4160-9143-FF62E9F35930, OS:15.0, name:iPhone 12 Pro Max }
    { platform:iOS Simulator, id:0783DE6B-63C4-494C-AC46-19EB933F56A1, OS:15.0, name:iPhone 12 mini }
    { platform:iOS Simulator, id:9168136B-6550-48ED-85A5-14AFC64BD925, OS:15.0, name:iPhone 13 }
    { platform:iOS Simulator, id:51CEC37E-A743-48AF-BDFF-2D129E13B05C, OS:15.0, name:iPhone 13 Pro }
    { platform:iOS Simulator, id:71227852-4232-4EFE-B479-5DD10FF21A7D, OS:15.0, name:iPhone 13 Pro Max }
    { platform:iOS Simulator, id:18BD7FFD-53A0-4029-A654-C7811DD6DCAF, OS:15.0, name:iPhone 13 mini }
    { platform:iOS Simulator, id:320A29CA-A1AE-49FD-A107-F73146A447E5, OS:15.0, name:iPhone SE (2nd generation) }
    { platform:iOS Simulator, id:D8359BED-C506-442C-A873-C8D2633A1DF1, OS:15.0, name:iPod touch (7th generation) }
    { platform:macOS, arch:arm64, variant:Designed for [iPad,iPhone], id:00008103-000121EE1AF1001E }
    { platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device }
    ** BUILD FAILED **

Xcode's output:
↳
    Command CompileSwiftSources failed with a nonzero exit code
    Command CompileSwiftSources failed with a nonzero exit code
    Command CompileSwiftSources failed with a nonzero exit code
    /Users/lena/.pub-cache/hosted/pub.dartlang.org/flutter_braintree-2.0.0+1/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/lena/Documents/franz_dev/EgoMenu/build/ios/Debug-iphonesimulator/Braintree/Braintree.framework/Modules/Braintree.swiftmodule
    import Braintree
           ^
    /Users/lena/.pub-cache/hosted/pub.dartlang.org/flutter_braintree-2.0.0+1/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/lena/Documents/franz_dev/EgoMenu/build/ios/Debug-iphonesimulator/Braintree/Braintree.framework/Modules/Braintree.swiftmodule
    import Braintree
           ^
    /Users/lena/.pub-cache/hosted/pub.dartlang.org/flutter_braintree-2.0.0+1/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/lena/Documents/franz_dev/EgoMenu/build/ios/Debug-iphonesimulator/Braintree/Braintree.framework/Modules/Braintree.swiftmodule
    import Braintree
           ^
    Command CompileSwiftSources failed with a nonzero exit code
    Command CompileSwiftSources failed with a nonzero exit code
    note: Using new build system
    note: Planning
    note: Build preparation complete
    note: Building targets in parallel

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

it has to be something to do with the architecture, but I can't figure out how to fix it, any ideas?

Thanks :)

SeriousMonk commented 2 years ago

Solved by adding

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

to the Podfile