Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xcode 11 Swift Packages incompatible with "flutter build" #44811

Closed
LinusU opened this issue Nov 13, 2019 · 14 comments · Fixed by #49654
Closed

Xcode 11 Swift Packages incompatible with "flutter build" #44811

LinusU opened this issue Nov 13, 2019 · 14 comments · Fixed by #49654
Labels
c: crash Stack traces logged to the console t: xcode "xcodebuild" on iOS and general Xcode project management tool Affects the "flutter" command-line tool. See also t: labels.

Comments

@LinusU
Copy link

LinusU commented Nov 13, 2019

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

  1. Create a new Flutter app
  2. Open the Xcode project
  3. Select "File" -> "Swift Packages" -> "Add Package Dependency"
  4. Add any package, e.g. "https://github.com/doneservices/ApsEnvironment"
  5. Try and build the app: "flutter build ios"
  6. 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!
@LinusU
Copy link
Author

LinusU commented Nov 13, 2019

I've tried experimenting with xcodebuild -list to see where exactly it goes wrong. If I run xcodebuild -list and pass it the Xcode Workspace (-workspace Runner.xcworkspace) it works, but if I pass it the project it fails (-project Runner.xcodeproj)

@jmagman
Copy link
Member

jmagman commented 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
Copy link
Author

LinusU commented Nov 13, 2019

@jmagman

Does it work from Xcode?

It works from Xcode.

Are you using the Legacy Build System or the New Build System?

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
Copy link
Member

jmagman commented Nov 13, 2019

I can reproduce. When I build Runner.xcodeproj in Xcode I get the same error.

: Packages are not supported when using legacy build locations, but the current project has them enabled.
x-xcode-log://0667FC40-91AB-4C63-947C-94E93DB222B8 Missing package product 'ApsEnvironment', please fix package resolution errors before building

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
Copy link
Member

jmagman commented 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).

Screen Shot 2019-11-13 at 11 36 00 AM

@jmagman jmagman added c: crash Stack traces logged to the console t: xcode "xcodebuild" on iOS and general Xcode project management tool Affects the "flutter" command-line tool. See also t: labels. labels Nov 13, 2019
@jmagman
Copy link
Member

jmagman commented Nov 13, 2019

At the least, xcodeproj.dart should be passing in the -workspace flag.

Actually that won't work, the point of that -list command is to ensure the Runner target exists, but the -workspace list only has schemes, which makes sense.

@jmagman jmagman added this to Awaiting triage in Tools - Xcode review Jan 10, 2020
@umaqs
Copy link

umaqs commented 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

#0      RunResult.throwException (package:flutter_tools/src/base/process.dart:141:5)
#1      _DefaultProcessUtils.run (package:flutter_tools/src/base/process.dart:275:19)
<asynchronous suspension>
#2      XcodeProjectInterpreter.getInfo (package:flutter_tools/src/ios/xcodeproj.dart:342:49)
#3      buildXcodeProject (package:flutter_tools/src/ios/mac.dart:281:70)
#4      BuildIOSCommand.runCommand (package:flutter_tools/src/commands/build_ios.dart:80:43)
<asynchronous suspension>
#5      FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:615:18)
#6      _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:73:64)
#7      _rootRunUnary (dart:async/zone.dart:1134:38)
#8      _CustomZone.runUnary (dart:async/zone.dart:1031:19)
#9      _FutureListener.handleValue (dart:async/future_impl.dart:139:18)
#10     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:680:45)
#11     Future._propagateToListeners (dart:async/future_impl.dart:709:32)
#12     Future._completeWithValue (dart:async/future_impl.dart:524:5)
#13     Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:554:7)
#14     _rootRun (dart:async/zone.dart:1126:13)
#15     _CustomZone.run (dart:async/zone.dart:1023:19)
#16     _CustomZone.runGuarded (dart:async/zone.dart:925:7)
#17     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:965:23)
#18     _microtaskLoop (dart:async/schedule_microtask.dart:43:21)
#19     _startMicrotaskLoop (dart:async/schedule_microtask.dart:52:5)
#20     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
#21     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:175:5)

flutter doctor

�[32m[✓]�[39m Flutter (Channel stable, v1.12.13+hotfix.5, on Mac OS X 10.15.1 19B88, locale en-PK)
    �[32m•�[39m Flutter version 1.12.13+hotfix.5 at /Applications/flutter
    �[32m•�[39m Framework revision 27321ebbad (6 weeks ago), 2019-12-10 18:15:01 -0800
    �[32m•�[39m Engine revision 2994f7e1e6
    �[32m•�[39m Dart version 2.7.0

�[32m[✓]�[39m Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    �[32m•�[39m Android SDK at /Users/aliaslabukdev/Library/Android/sdk
    �[32m•�[39m Android NDK location not configured (optional; useful for native profiling support)
    �[32m•�[39m Platform android-29, build-tools 28.0.3
    �[32m•�[39m Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    �[32m•�[39m Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    �[32m•�[39m All Android licenses accepted.

�[32m[✓]�[39m Xcode - develop for iOS and macOS (Xcode 11.2.1)
    �[32m•�[39m Xcode at /Applications/Xcode.app/Contents/Developer
    �[32m•�[39m Xcode 11.2.1, Build version 11B500
    �[32m•�[39m CocoaPods version 1.8.4

�[32m[✓]�[39m Android Studio (version 3.5)
    �[32m•�[39m Android Studio at /Applications/Android Studio.app/Contents
    �[32m•�[39m Flutter plugin version 41.1.2
    �[32m•�[39m Dart plugin version 191.8593
    �[32m•�[39m Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

�[32m[✓]�[39m VS Code (version 1.41.1)
    �[32m•�[39m VS Code at /Applications/Visual Studio Code.app/Contents
    �[32m•�[39m Flutter extension version 3.7.1

�[32m[✓]�[39m Connected device (1 available)
    �[32m•�[39m Umair’s iPhone • device-id • ios • iOS 13.3

�[32m•�[39m No issues found!

@jmagman
Copy link
Member

jmagman commented Jan 24, 2020

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?

I think don't downgrading Flutter would help. The workaround is to run ios/Runner.xcworkspace from Xcode.

The project is not using the legacy build system, unless I'm totally misunderstanding what "legacy build locations" means.

Okay I was misunderstanding, I think "legacy build locations" isn't related to the legacy build system, it's related to where the SYMROOT is pointed.

Screen Shot 2020-01-24 at 12 42 38 PM

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 jmagman moved this from Awaiting triage to Engineer reviewed in Tools - Xcode review Jan 25, 2020
@jmagman
Copy link
Member

jmagman commented Jan 28, 2020

When I opened Runner.xcodeproj (not Runner.xcworkspace) > File > Project Settings > Per-User Project Settings: > Advanced I saw this:

Screen Shot 2020-01-28 at 2 47 07 PM

My Runner.xcodeproj/project.xcworkspace/xcuserdata/USER.xcuserdatad/WorkspaceSettings.xcsettings file had:

<key>BuildLocationStyle</key>
<string>UseTargetSettings</string>

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
Copy link
Member

jmagman commented 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
Copy link
Member

jmagman commented 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".

Screen Shot 2020-01-28 at 4 02 54 PM

or swap File > Project Settings > Per-User Project Settings: > Advanced from Legacy to Xcode Default
73312223-10950180-41dd-11ea-9a66-98d3a140f0fd

@chandrabezzo
Copy link

chandrabezzo commented Oct 5, 2020

Command

flutter build ios

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

#0      RunResult.throwException (package:flutter_tools/src/base/process.dart:172:5)
#1      _DefaultProcessUtils.run (package:flutter_tools/src/base/process.dart:328:19)
<asynchronous suspension>
#2      XcodeProjectInterpreter.getInfo (package:flutter_tools/src/ios/xcodeproj.dart:392:50)
#3      IosProject.projectInfo (package:flutter_tools/src/project.dart:531:67)
#4      IosProject.buildSettingsForBuildInfo (package:flutter_tools/src/project.dart:513:41)
#5      IosProject._parseProductBundleIdentifier (package:flutter_tools/src/project.dart:455:56)
#6      IosProject.productBundleIdentifier (package:flutter_tools/src/project.dart:432:47)
#7      BuildableIOSApp.fromProject (package:flutter_tools/src/application_package.dart:365:50)
#8      IOSApp.fromIosProject (package:flutter_tools/src/application_package.dart:348:28)
#9      ApplicationPackageStore.getPackageForPlatform (package:flutter_tools/src/application_package.dart:433:30)
#10     BuildIOSCommand.runCommand (package:flutter_tools/src/commands/build_ios.dart:93:59)
#11     FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:972:18)
<asynchronous suspension>
#12     FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:831:33)
<asynchronous suspension>
#13     FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart)
#14     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:29)
#15     _rootRun (dart:async/zone.dart:1190:13)
#16     _CustomZone.run (dart:async/zone.dart:1093:19)
#17     _runZoned (dart:async/zone.dart:1630:10)
#18     runZoned (dart:async/zone.dart:1550:10)
#19     AppContext.run (package:flutter_tools/src/base/context.dart:149:18)
#20     FlutterCommand.run (package:flutter_tools/src/runner/flutter_command.dart:820:20)
#21     CommandRunner.runCommand (package:args/command_runner.dart:197:27)
[✓] Flutter (Channel stable, 1.22.0, on Mac OS X 10.15.6 19G2021, locale en-US)
    • Flutter version 1.22.0 at /Users/bezzo/Mobile/flutter-sdk
    • Framework revision d408d302e2 (6 days ago), 2020-09-29 11:49:17 -0700
    • Engine revision 5babba6c4d
    • Dart version 2.10.0

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at /Users/bezzo/Library/Android/sdk
    • Platform android-29, build-tools 29.0.3
    • ANDROID_HOME = /Users/bezzo/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_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.0)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.0, Build version 12A7209
    • CocoaPods version 1.8.4

[✓] Android Studio (version 4.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 49.0.2
    • Dart plugin version 193.7547
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6222593)

[✓] VS Code (version 1.49.3)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.15.0

[!] Connected device
    ! Error: Docotel Bandung is not connected. Xcode will continue when Docotel
      Bandung is connected. (code -13)

! Doctor found issues in 1 category.

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
Copy link
Member

jmagman commented Oct 5, 2020

@chandrabezzo See #57083

@github-actions
Copy link

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 -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
c: crash Stack traces logged to the console t: xcode "xcodebuild" on iOS and general Xcode project management tool Affects the "flutter" command-line tool. See also t: labels.
Projects
Tools - Xcode review
  
Engineer reviewed
Development

Successfully merging a pull request may close this issue.

5 participants