每当我在我的Flutter应用程序的项目根目录中从终端运行 flutter build ios 时,我都会返回:
找不到“ xcodebuild”。要开发iOS,需要使用Xcode 9.0或更高版本。
在构建设备时遇到错误。 我拥有最新的Xcode(版本10.0)。
Flutter医生:
[✓] Flutter (Channel beta, v0.8.2, on Mac OS X 10.13.6 17G65, locale en-GB)
• Flutter version 0.8.2 at /Users/h/flutter
• Framework revision 5ab9e70727 (2 weeks ago), 2018-09-07 12:33:05 -0700
• Engine revision 58a1894a1c
• Dart version 2.1.0-dev.3.1.flutter-760a9690c2
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
• Android SDK at /Users/h/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-27, build-tools 27.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
• All Android licenses accepted.
[!] iOS toolchain - develop for iOS devices
✗ Xcode installation is incomplete; a full installation is necessary for iOS development.
Download at: https://developer.apple.com/xcode/download/
Or install Xcode via the App Store.
Once installed, run:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
• ios-deploy 1.9.2
• CocoaPods version 1.5.3
[✓] Android Studio (version 3.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 24.2.1
• Dart plugin version 173.4700
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
[✓] Connected devices (1 available)
• h iPhone • 77afb908fc6c490d3fca62cdde9a74ab4e45b4f0 • ios • iOS 11.4.1
! Doctor found issues in 1 category.
我认为从外部HD运行Xcode时会引发IOS问题
答案 0 :(得分:12)
我的问题的根源是Flutter无法找到最新安装的Xcode版本。
要修复此问题,请转到Xcode-> preferences-> locations->命令行工具的设置值。
答案 1 :(得分:3)
flutter doctor -v
的建议很明确
✗ Xcode installation is incomplete; a full installation is necessary for iOS development.
Download at: https://developer.apple.com/xcode/download/
Or install Xcode via the App Store.
Once installed, run:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Develope
您可以尝试启动Xcode,并在要求安装缺少的组件时同意。
Id建议您尝试在应该获得Xcode 10支持的dev
或master
频道。否则,请检查此建议https://github.com/flutter/flutter/issues/20685#issuecomment-413524718
答案 2 :(得分:3)
在终端中运行以下命令:
1- cd your_project_path
2- sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
3- sudo xcodebuild -license
4-打开-a模拟器
5次扑打
答案 3 :(得分:1)
如果您通过Apple Developer Download Center或其他来源手动安装了Xcode 10,那么首先,将您的Xcode重命名为您下载的版本名称,就像我下载Xcode 10.1版本一样,因此对我来说重命名的名称为Xcode10。 1.app .app扩展名是可选的,因为它已经具有.app扩展名...
然后,将此命令粘贴到您的终端上,
sudo xcode-select --switch /Applications/Xcode10.1.app/Contents/Developer
注意:Xcode版本(即Xcode10.1.app)是强制性的,否则,请重命名并添加它,以确保安全,并且没有任何副作用 >
答案 4 :(得分:0)
已修复问题,方法是切换到开发人员通道,并将Xcode从外部HD移动到内部,命令成功执行。
答案 5 :(得分:0)
答案 6 :(得分:0)
如果你已经有 Xcode 并且随机出现这个错误,只需按照 Flutter Doctor 的建议运行这些命令:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -runFirstLaunch
答案 7 :(得分:-3)
要修复它,请转到 Xcode->preferences->locations->set value for command Line tools。