简体   繁体   English

在 Xcode 项目中使用 Swift Package 管理器添加依赖项时生成错误

[英]Build error when adding a dependency using Swift Package Manager in Xcode for a Flutter project

In my Flutter project, I need to add dependencies on the native iOS part of my project.在我的 Flutter 项目中,我需要添加对我项目的本机 iOS 部分的依赖项。

For that, I use Swift Package Manager.为此,我使用 Swift Package 管理器。

But each time I try to run my app, after adding a dependency, I get the following build error:但是每次我尝试运行我的应用程序时,在添加依赖项后,我都会收到以下构建错误:

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 -list

More details here .更多细节在这里

Since I'm new to iOS development, how can I add dependencies in Xcode so my Flutter app works?由于我是 iOS 开发的新手,如何在 Xcode 中添加依赖项,以便我的 Flutter 应用程序有效?

Thanks.谢谢。

I think I might have the fix for you.我想我可能会为你解决问题。

Please close your workspace in XCode, and go back and open the.xcodeproj file INSTEAD of the.xcworkspace file.请关闭 XCode 和 go 中的工作区,然后打开 .xcodeproj 文件而不是 .xcworkspace 文件。

(/yourApp/ios/Runner.xcodeproj most likely) (/yourApp/ios/Runner.xcodeproj 最有可能)

When the project is open, in XCode menu bar click File -> Project Settings -> Advanced.打开项目后,在 XCode 菜单栏中单击文件 -> 项目设置 -> 高级。

Change the option from LEGACY to XCODE DEFAULT.将选项从 LEGACY 更改为 XCODE DEFAULT。

Now open the.xcworkspace again and it should work!现在再次打开.xcworkspace,它应该可以工作了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM