使用模拟器时执行flutter run 报出下面一大堆错误 注意只有模拟器有这种问题,真机可以正常运行
Oops; flutter has exited unexpectedly.
Sending crash report to Google.
Crash report sent (report ID: 1f4909d52a4fc2ef)
Crash report written to /Users/admin/Tiny/Project/Git/YinHuYiTou/yhyt_app/flutter_21.log;
please let us know at https://github.com/flutter/flutter/issues.
定位到flutter_21.log
flutter run
## exception
ProcessException: ProcessException: Process "/usr/bin/xcrun" exited abnormally:
An error was encountered processing the command (domain=IXUserPresentableErrorDomain, code=1):
This app could not be installed at this time.
Could not hardlink copy /Users/admin/Library/Developer/CoreSimulator/Devices/5D883DD5-5315-474D-8E19-9E08A9FB5B4D/data/Containers/Bundle/Application/B2B708AE-0740-4AF0-9766-C736BB51DAE6/Runner.app to /Users/admin/Library/Developer/CoreSimulator/Devices/5D883DD5-5315-474D-8E19-9E08A9FB5B4D/data/Library/Caches/com.apple.mobile.installd.staging/temp.8C1dZO/extracted/Payload/Runner.app with manifest /Users/admin/Library/Developer/CoreSimulator/Devices/5D883DD5-5315-474D-8E19-9E08A9FB5B4D/data/Library/Caches/com.apple.mobile.installd.staging/temp.8C1dZO/extracted/com.apple.deltainstallcommands.com.example.yhytApp
Could not hardlink copy /Users/admin/Library/Developer/CoreSimulator/Devices/5D883DD5-5315-474D-8E19-9E08A9FB5B4D/data/Containers/Bundle/Application/B2B708AE-0740-4AF0-9766-C736BB51DAE6/Runner.app to /Users/admin/Library/Developer/CoreSimulator/Devices/5D883DD5-5315-474D-8E19-9E08A9FB5B4D/data/Library/Caches/com.apple.mobile.installd.staging/temp.8C1dZO/extracted/Payload/Runner.app with manifest /Users/admin/Library/Developer/CoreSimulator/Devices/5D883DD5-5315-474D-8E19-9E08A9FB5B4D/data/Library/Caches/com.apple.mobile.installd.staging/temp.8C1dZO/extracted/com.apple.deltainstallcommands.com.example.yhytApp
Underlying error (domain=MIInstallerErrorDomain, code=8):
Could not hardlink copy /Users/admin/Library/Developer/CoreSimulator/Devices/5D883DD5-5315-474D-8E19-9E08A9FB5B4D/data/Containers/Bundle/Application/B2B708AE-0740-4AF0-9766-C736BB51DAE6/Runner.app to /Users/admin/Library/Developer/CoreSimulator/Devices/5D883DD5-5315-474D-8E19-9E08A9FB5B4D/data/Library/Caches/com.apple.mobile.installd.staging/temp.8C1dZO/extracted/Payload/Runner.app with manifest /Users/admin/Library/Developer/CoreSimulator/Devices/5D883DD5-5315-474D-8E19-9E08A9FB5B4D/data/Library/Caches/com.apple.mobile.installd.staging/temp.8C1dZO/extracted/com.apple.deltainstallcommands.com.example.yhytApp
Command: /usr/bin/xcrun simctl install 5D883DD5-5315-474D-8E19-9E08A9FB5B4D /Users/admin/Tiny/Project/Git/YinHuYiTou/yhyt_app/build/ios/iphonesimulator/Runner.app
找到问题
Could not hardlink copy /Users/admin/Library/Developer/CoreSimulator/Devices
解决问题:
原来是在flutter中设置pubspec.yaml配置文件的时候有一个版本号的设置version: 1.0.0,问题就出在了这里,在iOS中有一个build号的概念,这里默认通过version: 1.0.0+n,通过+n,n代表build号,如果把+n去掉,那么在xcode工程中就没办法获取到build号,build那一行就为空,所有千万不要把+n去掉,
添加上了+n之后,把模拟器上面app先删除掉,再重新安装,即可解决问题
version: 1.0.0+1