我最近开始学习KMP并陷入了这个错误。我已经从 Jetbrains KMP 向导 创建了示例项目。我在Android Studio中打开下载的项目并安装在模拟器中,它运行良好。
但是当我尝试在 XCode 中打开 iOS 项目时,我在
No such module 'ComposeApp'
文件上遇到了 ContentView
错误。请参阅屏幕截图。
在网上花了一些时间后,有人建议我需要在Android studio中重建项目,然后问题就解决了。
但是,当我在 Android studio 中点击重建/制作项目时,我收到此错误:
> Task :composeApp:compileIosMainKotlinMetadata FAILED
e: Compilation failed: An error occurred during an xcrun execution. Make sure that Xcode and its command line tools are properly installed.
Failed command: /usr/bin/xcrun xcodebuild -version
Try running this command in Terminal and fix the errors by making Xcode (and its command line tools) configuration correct.
* Source files: MainViewController.kt, Platform.ios.kt
* Compiler version: 2.0.0
* Output kind: LIBRARY
e: org.jetbrains.kotlin.konan.MissingXcodeException: An error occurred during an xcrun execution. Make sure that Xcode and its command line tools are properly installed.
Failed command: /usr/bin/xcrun xcodebuild -version
Try running this command in Terminal and fix the errors by making Xcode (and its command line tools) configuration correct.
我发现这个命令可以运行用于命令行工具安装
xcode-select --install
,当我运行时,得到了
xcode-select --install
xcode-select: note: Command line tools are already installed. Use "Software Update" in System Settings or the softwareupdate command line interface to install updates
我有最新版本的 macOS、Android Studio 和 XCode。
可能是什么问题?怎么解决这个问题呢? 任何帮助将不胜感激。
花了几个小时后,我发现我的新MacBook上没有安装JDK。 :)