Cannot run application on simulator after installi

2020-02-09 23:54发布

Yesterday, I've downloaded beta version of Xcode 11. After that, I've opened my project and tried to run with new Xcode. Unfortunately error has occurred with message:


Failed to install the requested application
Domain: NSPOSIXErrorDomain
Code: 22
Failure Reason: The application's CFBundleVersion is invalid.
Recovery Suggestion: Ensure your bundle contains a CFBundleVersion with a valid semantic version number.
--

I've closed beta version and tried to run again with latest stable version of Xcode (10.2.1), but the same error has occurred. I need to mention that before attempting to run a project with Xocde 11, it worked without any problems on Xcode 10. Nothing has been changed before and after running with beta Xcode.

What I've already tried:

  • I've removed Xcode 11 beta
  • I've cleaned my project and pulled it from latest branch
  • I've completely removed Xcode 10 from:
~/Library/Caches/com.apple.dt.Xcode
~/Library/Developer
~/Library/MobileDevice
~/Library/Preferences/com.apple.dt.Xcode.plist
/Library/Preferences/com.apple.dt.Xcode.plist
/System/Library/Receipts/com.apple.pkg.XcodeExtensionSupport.bom
/System/Library/Receipts/com.apple.pkg.XcodeExtensionSupport.plist
/System/Library/Receipts/com.apple.pkg.XcodeSystemResources.bom
/System/Library/Receipts/com.apple.pkg.XcodeSystemResources.plist
  • And then installed fresh stable version 10.2.1

I can run other projects which was not tested with Xcode 11 without any problems.

My last idea is to just reinstall macOS, but I would like to don't do it.

Edit: I’ve forgot to mention that application is working on physical iPhone XS.

10条回答
Emotional °昔
2楼-- · 2020-02-10 00:19

Happened to me too, wasted almost an entire day scouting for possible causes.

The steps that finally fixed the problem and allowed me to install on simulator:

  1. Quit Xcode and iOS Simulator
  2. Remove /Library/Developer (the one from root), or rename it if you want to keep a backup
  3. Relaunch Xcode, agree with the installation of command line tools
  4. Continue work where you left over :)

Besides the steps mentioned in the question (fully uninstall Xcode 11, fully uninstall Xcode 10 and reinstall it afterwards), I also tried cloning the project in another location, circulating through all possible locations for derived data, installing other simulator runtimes and trying on those. None of them worked, luckily the console log app shown the path for the process that rejected the app bundle, it was one of the binaries installed by Xcode in /Library/Developer/PrivateFrameworks/CoreSimulator.framework.

Seems that Xcode 11 installed a newer version of the frameworks, and Xcode 10 was not overwriting them. Removing the whole /Library/Developer folder triggered the command line tools installation, which finally brought back the simulator runtime that properly worked in Xcode 10.

You gotta love the betas :)

查看更多
趁早两清
3楼-- · 2020-02-10 00:22

In my case, the Build Version field was empty. I added the value there but still it didn't work. I tried killall -9 CoreSimulatorBridge command and that also didn't help. Finally when I checked the xml of the info.plist (Open as -> Source code), the CFBundleVersion key was not present and the version was displayed in the info.plist through CFBundleShortVersionString.

I just added the CFBundleVersion key as given below in the info.plist and it worked.

<key>CFBundleVersion</key> <string>$(MARKETING_VERSION)</string>

I hope it helps someone else too.

查看更多
forever°为你锁心
4楼-- · 2020-02-10 00:24

In my case, the "Build Version" field on my target was empty, I changed it to 1 and the app was able to install.

查看更多
一夜七次
5楼-- · 2020-02-10 00:33

Adding onto this, I noticed that if your CFBundleVersion does not spec out to:

This key is a machine-readable string composed of one to three period-separated integers, such as 10.14.1. The string can only contain numeric characters (0-9) and periods. it will not build on simulator

link

查看更多
登录 后发表回答