问题
Flutter iOS build fails after upgrading to Xcode 10.0 version in mac.
Nagendras-MacBook-Pro:uaenumber nagendra$ flutter run
Launching lib/main.dart on iPhone X in debug mode...
Starting Xcode build...
Xcode build done. 1.4s
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
error: Multiple commands produce '/Users/dev/Documents/projects/Personal/uaenumber/build/ios/Debug-iphonesimulator/Runner.app/Frameworks/Flutter.framework':
1) Target 'Runner' has copy command from '/Users/dev/Documents/projects/Personal/uaenumber/ios/Flutter/Flutter.framework' to '/Users/dev/Documents/projects/Personal/uaenumber/build/ios/Debug-iphonesimulator/Runner.app/Frameworks/Flutter.framework'
2) That command depends on command in Target 'Runner': script phase “[CP] Embed Pods Frameworks”
warning: The use of Swift 3 @objc inference in Swift 4 mode is deprecated. Please address deprecated @objc inference warnings, test your code with “Use of deprecated Swift 3 @objcinference” logging enabled, and then disable inference by changing the "Swift 3 @objc Inference" build setting to "Default" for the "Runner" target. (in target 'Runner')
warning: ignoring duplicated output file: '/Users/nagendra/Documents/projects/Personal/uaedialer/build/ios/Debug-iphonesimulator/Runner.app/Frameworks/Flutter.framework' (in target 'Runner')
note: Using new build systemnote: Planning buildnote: Constructing build description
Could not build the application for the simulator.
Error launching application on iPhone X.
Xcode Version - 10.0 (10A255)
I tried to recreate the project and copied all the source files to the new project folder but it doesn`t resolve the issue.
回答1:
It's a known issue. Here is the explanation and some workarounds: https://github.com/flutter/flutter/issues/20685#issuecomment-421511890
Affected projects
This issue affects all Flutter projects built using Xcode 10 that have a dependency on CocoaPods -- typically this means those that rely on plugins. Workarounds
There are two workarounds:
- Option 1: Use the legacy build system . As noted by @gi097, open ios/Runner.xcworkspace, and change the build system to Legacy Build System.
- Option 2: Use the new Xcode 10 build system. Open ios/Runner.xcworkspace Select the Runner project in the project navigator sidebar. In the main view, select the Runner target, then select the Build Phases tab. Expand the Embed Frameworks phase and select Flutter.framework from the embedded frameworks list. Click - to remove Flutter.framework from the list (be sure to keep App.framework).
Root cause
When plugins are in use, there are two competing build actions that copy Flutter.framework into the build application Frameworks directory:
The Embed Frameworks build phase for the Runner project
The [CP] Embed Pods Frameworks build phase that pod install creates in the project.
Item (1) is there to ensure the framework is copied into the built app in the case where there are no plugins (and therefore no CocoaPods integration in the Xcode project). Item (2) is there because Flutter's podspec declares Flutter.framework as a vended_framework, and CocoaPods automatically adds a copy step for each such vended_framework in the transitive closure of CocoaPods dependencies.
回答2:
This solution worked for me.
- Open ios/Runner.xcworkspace Select the Runner project in the project navigator sidebar.
- In the main view, select the Runner target, then select the Build Phases tab.
- Expand the Embed Frameworks phase and select Flutter.framework from the embedded frameworks list.
- Click - to remove Flutter.framework from the list (be sure to keep App.framework).
回答3:
This issue was fixed by opening the Runner workspace project in Xcode 10. Then navigate to File, Workspace Settings and change the build system to Legacy Build System.
回答4:
- Open ios/Runner.xcworkspace in Xcode. File > Workspace Settings... > Build System, change dropdown to New Build System (Default)
- In your Podfile, add the line
install! 'cocoapods', :disable_input_output_paths => true
- In your Flutter app, build again to trigger a
pod install
, which will automatically clean up the build phase
flutter build ios
See: https://github.com/flutter/flutter/issues/20685#issuecomment-509731873 https://github.com/flutter/flutter/issues/20685#issuecomment-510162863
Warning: Do not revert to the Xcode deprecated legacy build system to fix this issue as suggested in the other answers.
来源:https://stackoverflow.com/questions/52398521/flutter-ios-build-failure-error-with-multiple-commands-after-the-xcode-upgrade