When adding a dependency with Swift Package Manager in Xcode for a Flutter project, your build fails with this error message:
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
-
Close your workspace in Xcode.
-
Open the
.xcodeproj
file INSTEAD of the.xcworkspace
file (most likely /yourApp/ios/Runner.xcodeproj). -
When the project is open, in the Xcode menu bar click File -> Project Settings -> Advanced.
-
Change the option from LEGACY to XCODE DEFAULT.
-
Open the
.xcworkspace
again and it should work!