我是iOS开发的新手,一开始就遇到了这个问题:当我试图运行我的helloworld应用程序时,xcodebuild失败了(由于太长,我只写了最后几行(:
81 errors generated.
<unknown>:0: error: failed to emit precompiled header '/Users/mehec/Library/Developer/Xcode/DerivedData/Runner-cssmbpuzzkyjvpfghedbpvdhbbmr/Build/Intermediates.noindex/PrecompiledHeaders/Runner-Bridging-Header-swift_2PXLF604USZTM-clang_KLU4EDN5EN1U.pch' for bridging header '/Users/mehec/Desktop/bgp/learn_flutter_0_test/ios/Runner/Runner-Bridging-Header.h'
<unknown>:0: error: generate-pch command failed with exit code 1 (use -v to see invocation)
note: Using new build system
note: Planning build
note: Constructing build description
然后我尝试在xcode中构建和运行,一切都很好。
我尝试过颤振清理和颤振升级,甚至创建了一个新项目,但没有效果
我使用的是macOS 10.14.6,IntelliJ Idea 2020.1,Flutter 1.17.5和1.19.0,Xcode 11.3.1
main.dart中的代码:
import 'package:flutter/material.dart';
void main() {
runApp(Center(
child: Text(
"hello world",
textDirection: TextDirection.rtl,
),
));
}
扑动医生:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, 1.19.0-4.3.pre, on Mac OS X 10.14.6 18G5033, locale en-US)
[✗] Android toolchain - develop for Android devices
✗ Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
If the Android SDK has been installed to a custom location, set ANDROID_SDK_ROOT to that location.
You may also want to add it to your PATH environment variable.
[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
[!] Android Studio (not installed)
[✓] IntelliJ IDEA Ultimate Edition (version 2020.1.3)
[✓] Connected device (1 available)
! Doctor found issues in 2 categories.
谢谢!
我也遇到了类似的问题。从Xcode.app生成成功,但从命令行或Android Studio生成失败。
最后,我重新安装了rbenv,问题就解决了。
在Github的其他评论中,有些人用conda deactivate
解决了这个问题,所以我认为这个问题是由Xcode.app没有引用的开发环境中的一个bug引起的,比如ruby或python环境。