Solvedflutter Multiple commands produce '/build/ios/Debug-iphonesimulator/Runner.app/Frameworks/Flutter.framework
✔️Accepted Answer
Other Answers:
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 toLegacy 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 theBuild Phases
tab. - Expand the
Embed Frameworks
phase and selectFlutter.framework
from the embedded frameworks list. - Click
-
to removeFlutter.framework
from the list (be sure to keepApp.framework
).
- Open
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 thatpod 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.
Immediate fix
The immediate fix is for us to find a way to automatically opt back in to the legacy build fix until a longer-term better solution is in place. Previous betas supported -useNewBuildSystem=NO
or -useModernBuildSystem=NO
but looks like this is removed in the GM build. Looks like currently the way to do this is to add a key-value pair (<key>BuildSystemType</key><string>Original</string>
) to ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
.
Longer-term fix
The simplest option would be to eliminate Flutter.framework from the Embed Frameworks step above and always rely on pod install, even in the case where there are no plugin dependencies. We'd need to update Flutter tool to automatically edit existing projects to remove Flutter.framework from the Embed Frameworks step.
pro: simpler code. con: makes cocoapods a required install step for Flutter development, first run involves a huge and very slow download of their repo.
A slightly nicer option would be for us to automatically detect whether the project uses plugins or not, and edit the Xcode project to check for and remove Flutter.framework from the Embed Frameworks step automatically if plugins are in use or add it if not.
pro: better user experience. con: more complex code.
Either way, we need some mechanism to automatically edit the project.pbxproj file and remove the framework from the embed frameworks build step. Supporting adding it back in isn't much incremental work and results in a better experience.
If you're still seeing this error, you will need to migrate your Xcode project:
- File > Workspace Settings... > Build System, change dropdown to New Build System (Default)
- In your Podfile, add the line
install! 'cocoapods', :disable_input_output_paths => trueSee https://github.com/flutter/flutter/blob/master/examples/platform_view/ios/Podfile for example.
3. In the Runner target "[CP] Embed Pods Framework" Build Phase, remove all Output Files.
Or you can do #1 and #2, then run pod install
from the ios directory, and CocoaPods should remove that Output file in the build phase automatically.
@gincos If you don't have a Mac you can look at PR #33684 for an example of how to tweak the Xcode files manually. If you have a Mac, please follow the above steps instead!
- Delete the file ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings. This is what's happening under the covers with File > Workspace Settings... > Build System > New Build System (Default).
https://github.com/flutter/flutter/pull/33684/files#diff-e7ad834b29956b3cbd9225dc81f2c06a - In your Podfile, add the line
install! 'cocoapods', :disable_input_output_paths => true
https://github.com/flutter/flutter/pull/33684/files#diff-4e7de62cf4dff9802f06b7f3cb120939
Hopefully your cloud pipeline should run pod install
and take care of #3 above for you.
If you are still seeing the error, you can edit ios/Runner.xcodeproj/project.pbxproj to remove the output file manually. Please be careful doing this! The Xcode project file does not take kindly to corruption.
https://github.com/flutter/flutter/pull/33684/files#diff-e9e57f7f2e911a135acd8f08e79b20e1
thanks a lot! it works.
When I want to debug the application in MacOs environment, it throw such error:
Multiple commands produce '/build/ios/Debug-iphonesimulator/Runner.app/Frameworks/Flutter.framework
warning: ignoring duplicated output file: '//build/ios/Debug-iphonesimulator/Runner.app/Frameworks/Flutter.framework' (in target 'Runner')
note: Using new build systemnote: Planning buildnote: Constructing build description
Mac 10.14 Beta
Xcode 10 beta
How to fix it? Thanks a lot