Repository navigation
Xcode 11 Swift Packages incompatible with "flutter build" #44811
Copy link
Copy link
Closed
Labels
c: crashStack traces logged to the consoleStack traces logged to the consolet: xcode"xcodebuild" on iOS and general Xcode project management"xcodebuild" on iOS and general Xcode project managementtoolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.
Description
We are trying to use a Swift package using the newly integrated Swift Package Manager in Xcode 11 in our iOS specific platform code. While it works as long as we build the app via Xcode, we cannot build or run the app using the flutter tool.
Steps to Reproduce
- Create a new Flutter app
- Open the Xcode project
- Select "File" -> "Swift Packages" -> "Add Package Dependency"
- Add any package, e.g. "https://github.com/doneservices/ApsEnvironment"
- Try and build the app: "flutter build ios"
- Observe below documented error
Target Platform: iOS
Target OS version/browser: iOS 13
Devices: iPhone 8, iPhone 11 Pro
command
flutter build ios
exception
ProcessException: ProcessException: Process "/usr/bin/xcodebuild" exited abnormally:
xcodebuild: error: Could not resolve package dependencies:
Packages are not supported when using legacy build locations, but the current project has them enabled.
Command: /usr/bin/xcodebuild -list
#0 runCheckedAsync (package:flutter_tools/src/base/process.dart:259:7)
<asynchronous suspension>
#1 XcodeProjectInterpreter.getInfo (package:flutter_tools/src/ios/xcodeproj.dart:270:36)
<asynchronous suspension>
#2 buildXcodeProject (package:flutter_tools/src/ios/mac.dart:279:70)
<asynchronous suspension>
#3 BuildIOSCommand.runCommand (package:flutter_tools/src/commands/build_ios.dart:84:43)
<asynchronous suspension>
#4 FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:490:18)
#5 _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:71:64)
#6 _rootRunUnary (dart:async/zone.dart:1132:38)
#7 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#8 _FutureListener.handleValue (dart:async/future_impl.dart:137:18)
#9 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:678:45)
#10 Future._propagateToListeners (dart:async/future_impl.dart:707:32)
#11 Future._completeWithValue (dart:async/future_impl.dart:522:5)
#12 Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:552:7)
#13 _rootRun (dart:async/zone.dart:1124:13)
#14 _CustomZone.run (dart:async/zone.dart:1021:19)
#15 _CustomZone.runGuarded (dart:async/zone.dart:923:7)
#16 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:963:23)
#17 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#18 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#19 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:116:13)
#20 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:173:5)
flutter doctor
[✓] Flutter (Channel stable, v1.9.1+hotfix.6, on Mac OS X 10.14.6 18G1012, locale en-SE)
• Flutter version 1.9.1+hotfix.6 at /Users/linus/coding/flutter
• Framework revision 68587a0916 (9 weeks ago), 2019-09-13 19:46:58 -0700
• Engine revision b863200c37
• Dart version 2.5.0
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.1)
• Android SDK at /Users/linus/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.1
• ANDROID_HOME = /Users/linus/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.2.1, Build version 11B500
• CocoaPods version 1.8.4
[✓] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 41.1.2
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
[✓] VS Code (version 1.39.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.6.0
[✓] Connected device (2 available)
• A10 • DIN7YS5DU4V4PNNJ • android-arm • Android 7.0 (API 24)
• Linus’ iPhone • 00008030-001135E63430802E • ios • iOS 13.2
• No issues found!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
c: crashStack traces logged to the consoleStack traces logged to the consolet: xcode"xcodebuild" on iOS and general Xcode project management"xcodebuild" on iOS and general Xcode project managementtoolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.
Activity
LinusU commentedon Nov 13, 2019
I've tried experimenting with
xcodebuild -listto see where exactly it goes wrong. If I runxcodebuild -listand pass it the Xcode Workspace (-workspace Runner.xcworkspace) it works, but if I pass it the project it fails (-project Runner.xcodeproj)jmagman commentedon Nov 13, 2019
Does it work from Xcode?
Are you using the Legacy Build System or the New Build System? See #1 #20685 (comment)
LinusU commentedon Nov 13, 2019
@jmagman
It works from Xcode.
The New Build System.
I've tried both with and without
install! 'cocoapods', :disable_input_output_paths => true, it doesn't make a difference. Also, it works without that line when building with Xcode, so I don't seem to have the "double Flutter.framework" problem.jmagman commentedon Nov 13, 2019
I can reproduce. When I build Runner.xcodeproj in Xcode I get the same error.
That seems like an Xcode bug? The project is not using the legacy build system, unless I'm totally misunderstanding what "legacy build locations" means.
At the least, xcodeproj.dart should be passing in the -workspace flag.
Thanks for the helpful debugging, @LinusU.
jmagman commentedon Nov 13, 2019
I can't even add Swift Packages directly to the project instead of the workspace (not that you would want to for a flutter app).
jmagman commentedon Nov 13, 2019
Actually that won't work, the point of that
-listcommand is to ensure the Runner target exists, but the-workspacelist only has schemes, which makes sense.umaqs commentedon Jan 24, 2020
Hi @jmagman
I am facing a similar issue and I am using the new build system. As I need to solve this urgently, would downgrading flutter help? If yes what version should I downgrade to?
I have attached the logs:
Flutter crash report; please file at https://github.com/flutter/flutter/issues.
command
flutter build ios
exception
ProcessException: ProcessException: Process exited abnormally:
xcodebuild: error: Could not resolve package dependencies:
Packages are not supported when using legacy build locations, but the current project has them enabled.
Command: /usr/bin/xcodebuild -list
flutter doctor
jmagman commentedon Jan 24, 2020
I think don't downgrading Flutter would help. The workaround is to run
ios/Runner.xcworkspacefrom Xcode.Okay I was misunderstanding, I think "legacy build locations" isn't related to the legacy build system, it's related to where the
SYMROOTis pointed.From the command line, Flutter points almost everything that would be written into DerviedData (not the module cache I think) instead into
path/to/flutter/app/build/. And I think Xcode is interpreting this as having some "legacy" build location. So that's why it's working from Xcode but not from Flutter.jmagman commentedon Jan 28, 2020
When I opened Runner.xcodeproj (not Runner.xcworkspace) > File > Project Settings > Per-User Project Settings: > Advanced I saw this:
My
Runner.xcodeproj/project.xcworkspace/xcuserdata/USER.xcuserdatad/WorkspaceSettings.xcsettingsfile had:Then I switched it in the GUI to Xcode Default, which changed that key from UseTargetSettings to UseAppPreferences. Then I had to re-launch Xcode, and I could add Swift packages to the project and I was able to
flutter build ios.I'm not sure why it's getting set to UseTargetSettings by default. That file is .gitignored and Flutter doesn't generate it...
jmagman commentedon Jan 28, 2020
I think this is because the compatibilityVersion in the generated Xcode project is set to Xcode 3.2. A new non-Flutter Xcode project uses Xcode 9.3. Let's update the templates to that.
jmagman commentedon Jan 30, 2020
#49654 updated the compatibility version for new flutter apps, but doesn't migrate existing ones. The manual migration is to go into the File inspector and swap Project Format from "Xcode 3.2-compatible" to "Xcode 9.3-compatible".
or swap File > Project Settings > Per-User Project Settings: > Advanced from Legacy to Xcode Default

chandrabezzo commentedon Oct 5, 2020
Command
Logs
ProcessException: Process exited abnormally:
Command line invocation:
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -list
xcodebuild: error: Could not resolve package dependencies:
Packages are not supported when using legacy build locations, but the current project has them enabled. Command: /usr/bin/xcodebuild, OS error code: 74
Flutter Application Metadata
Type: app
Version: null
Material: true
Android X: false
Module: false
Plugin: false
Android package: null
iOS bundle identifier: null
Creation channel: stable
Creation framework version: bbfbf17
Plugins
plugin_scaffold-3.1.0
assessment
jmagman commentedon Oct 5, 2020
@chandrabezzo See #57083
github-actions commentedon Aug 11, 2021
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.