无法在iOS模拟器上构建应用程序,但Android正常运行 – Xcode错误

huangapple go评论116阅读模式
英文:

Unable to Build App on iOS Simulator, but Android Works Fine - Xcode Error

问题

在尝试在iOS模拟器上使用Xcode运行我的Flutter应用时,我遇到了一个问题。这个应用在Android设备上运行得很顺利,但当我尝试在iPhone 14模拟器上以调试模式启动它时,我遇到了以下错误:

在调试模式下启动lib/main.dart上的iPhone 14...
运行Xcode构建...
Xcode构建完成。1.7秒
无法构建iOS应用程序
来自Xcode构建的错误输出:
↳
    2023-08-05 01:00:25.408 xcodebuild[11793:9648559] DVTCoreDeviceEnabledState:通过用户默认设置设置为DVTCoreDeviceEnabledState_Disabled
    (DVTEnableCoreDevice=disabled)
    xcodebuild: 错误: 无法找到与提供的目标说明符匹配的目标:
                { id:A628B341-6F32-408D-6FB6-D1B6607D2426 }

        “Runner”方案的可用目标:
                { platform:macOS, arch:arm64, variant:Designed for [iPad,iPhone], id:00008103-000A56263CD3001E }
                { platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device }

Xcode的输出:
↳
    将结果捆绑包写入路径:
        /var/folders/pn/41kpr78131x00zrg7zqwrsmr0000gn/T/flutter_tools.UeSLMM/flutter_ios_build_temp_dirABaxrN/temporary_xcresult_bundle


无法为模拟器构建应用程序。
在iPhone 14上启动应用程序时出错。

我对为什么应用在iOS模拟器上无法构建感到困惑,而在Android上却可以无缝运行。我确保使用了最新的Flutter和Xcode版本,但错误仍然存在。是否有人能够解释可能导致这个问题以及如何解决它的原因?对于任何见解或建议,我将不胜感激。谢谢!

英文:

I am facing an issue while trying to run my Flutter app on an iOS simulator using Xcode. The app runs smoothly on Android devices, but when I attempt to launch it on an iPhone 14 simulator in debug mode, I encounter the following error:

Launching lib/main.dart on iPhone 14 in debug mode...
Running Xcode build...                                                  
Xcode build done.                                            1.7s
Failed to build iOS app
Error output from Xcode build:
↳
    2023-08-05 01:00:25.408 xcodebuild[11793:9648559] DVTCoreDeviceEnabledState: DVTCoreDeviceEnabledState_Disabled set via user default
    (DVTEnableCoreDevice=disabled)
    xcodebuild: error: Unable to find a destination matching the provided destination specifier:
                { id:A628B341-6F32-408D-6FB6-D1B6607D2426 }

        Available destinations for the "Runner" scheme:
                { platform:macOS, arch:arm64, variant:Designed for [iPad,iPhone], id:00008103-000A56263CD3001E }
                { platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device }

Xcode's output:
↳
    Writing result bundle at path:
        /var/folders/pn/41kpr78131x00zrg7zqwrsmr0000gn/T/flutter_tools.UeSLMM/flutter_ios_build_temp_dirABaxrN/temporary_xcresult_bundle


Could not build the application for the simulator.
Error launching application on iPhone 14.

I'm puzzled as to why the app fails to build on the iOS simulator while it works flawlessly on Android. I've made sure to use the latest Flutter and Xcode versions, but the error persists. Could someone shed some light on what might be causing this issue and how to resolve it? Any insights or suggestions would be greatly appreciated. Thank you!

答案1

得分: 0

你的项目是否支持iOS 14,并尝试以下脚本:

flutter clean
pod cache clean --all
rm -rf ios/Flutter/Flutter.framework

flutter pub get
pod install
flutter run

附上flutter doctor日志。

英文:

Could you define if your project supports iOS 14,and perhaps try below scripts:

flutter clean
pod cache clean  --all
rm -rf ios/Flutter/Flutter.framework

flutter pub get
pod install
flutter run

PS: attach flutter doctor logs

答案2

得分: 0

为解决这个问题,您可以将您的Xcode版本回退到早期的版本。2023年6月1日,苹果发布了Xcode 14.3.1,令我无法在VScode中运行模拟器,原因不明。为了解决这个问题,我选择下载了之前的版本,即Xcode 14.2。随后,我通过选择这个下载的版本来进行了必要的Xcode设置调整。要执行此调整,请按照以下步骤操作:导航到Xcode > 设置 > 位置,然后转到命令行工具部分,单击下拉菜单,然后选择您下载的版本。

要访问和获取以前的版本,您可以访问以下网站:https://developer.apple.com/download/all/

我相信这些信息会对您有所帮助。在花费了一周的时间探索多种解决方案后,我发现这种方法是唯一能产生积极结果的方法。

英文:

To resolve this issue, you can revert your Xcode version to an earlier release. On June 1, 2023, Apple introduced Xcode 14.3.1, which inexplicably prevented me from running simulators in VScode. To overcome this, I opted to download a previous iteration, namely Xcode 14.2. Subsequently, I made the necessary adjustment to my Xcode settings by selecting this downloaded version. To perform this adjustment, follow these steps: Navigate to Xcode > Settings > Locations, proceed to the Command Line Tools section, click on the dropdown menu, and then choose the version you downloaded.

For accessing and acquiring previous versions, you can visit the following website: https://developer.apple.com/download/all/

I trust this information proves valuable. Having devoted a week to exploring multiple solutions, I found this approach to be the singular one that yielded positive results.

huangapple
  • 本文由 发表于 2023年8月5日 13:06:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/76840212.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定