Flutter iOS build failure error with Multiple commands after the Xcode upgrade
Asked Answered
D

8

22

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 does not resolve the issue.

Dogtired answered 19/9, 2018 at 5:12 Comment(4)
its error regrading this framework Flutter.framework . so check again that you have not embedded framework in project build phase setting and also you added this framework in script so remove from it and build againHadhramaut
Do you mean ios folder in lib directory? Earlier it generated automatically in the lib folder. Does it require to add manually?Dogtired
i'm not familiar with Flutter.framework but your error suggest its multiple copy in your embedded library in build setting and also your compiler libraryHadhramaut
github.com/flutter/flutter/issues/20685#issuecomment-421511890 might helpEpigynous
D
22

This solution worked for me.

  1. Open ios/Runner.xcworkspace Select the Runner project in the project navigator sidebar.
  2. In the main view, select the Runner target, then select the Build Phases tab.
  3. Expand the Embed Frameworks phase and select Flutter.framework from the embedded frameworks list.
  4. Click - to remove Flutter.framework from the list (be sure to keep App.framework).
Dogtired answered 19/9, 2018 at 7:38 Comment(3)
This should be the answerBirthright
I think this command is useful: 'rm -Rf ios/Flutter/Flutter.framework'Recreation
I can't see the FLutter.framework in the Embed Frameworks phase for the Runner target. Neither can I see the file in the directory ios/Flutter/Flutter.framework.Pozzy
B
22

If you have tried everything and still cannot build the Archive successfully, then you look like my case.

It took me 3 business days to fix this. My problem happened after adding the Notification Services target to the project. But it looks like it will apply to many other cases as well:

The problem is caused by the library inside 2 target multiple commands produce. In my case, for example, in the project target and notification extension target, both GoogleUtilities had this causing them to conflict or duplicated the commands produce. The solution is to make that dependency explicit, at the top level. The pod file will look like this:

platform :ios, '10.0'
use_frameworks!
inhibit_all_warnings!

pod 'GoogleUtilities' // Add this line is very important.

target 'MyProject' do
  pod 'Firebase/Analytics'
  pod 'Firebase/Crashlytics'
  pod 'Firebase/Messaging'
# Other pods
end

target 'NotificationService' do
  pod 'Firebase/Messaging'
end

After run:

pod deintegrate
pod install 
Billi answered 7/4, 2021 at 11:47 Comment(2)
Thank you so much!Tinkling
Thanks you are the bestVellicate
M
16

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.

Mansard answered 19/9, 2018 at 6:1 Comment(0)
A
5

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. enter image description here

Archducal answered 3/7, 2019 at 15:17 Comment(0)
D
5

Edit: The latest stable version of Flutter will migrate your Xcode project to the new build system (step one below) and avoid the multiple embedded frameworks warning altogether. If it doesn't, follow the instructions at https://flutter.dev/docs/development/ios-project-migration. You no longer need to edit your Podfile (step two below).

See https://github.com/flutter/flutter/issues/20685#issuecomment-622126064

Previous answer

  1. Open ios/Runner.xcworkspace in Xcode. File > Workspace Settings... > Build System, change dropdown to New Build System (Default)
  2. In your Podfile, add the line
install! 'cocoapods', :disable_input_output_paths => true

3. 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.

Drennan answered 14/10, 2019 at 20:49 Comment(0)
L
3

I faced this problem today and nothing fixed it. Then i check my xcode project and i found that insider runner folder i found another runner show red which was not there before. So i delete that and rerun my project and it fixed my problem.

I try the above method but it didn,t fix my problem. But you can try both to see which one work for you.

Lujan answered 27/1, 2021 at 20:12 Comment(0)
R
2

Try this:

flutter clean
rm -Rf ios/Pods
rm -Rf ios/.symlinks
rm -Rf ios/Flutter/Flutter.framework
rm -Rf ios/Flutter/Flutter.podspec
rm ios/Podfile
flutter run
Recreation answered 18/8, 2022 at 3:26 Comment(0)
O
0

None of these methods work for me, I use git method to revert to the version that could be successfully built before. But keep the source code in the project lib directory to overwrite it. then flutter clean. rebuild it. then works.

Offshoot answered 30/10, 2023 at 3:55 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Neale

© 2022 - 2025 — McMap. All rights reserved.