Cannot run application on simulator after installing Xcode 11 - CFBundleVersion error

IosXcodeXcode10Xcode11

Ios Problem Overview


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.

Ios Solutions


Solution 1 - Ios

There is a lot of misinformation in the answers here, so I wanted to provide an authoritative response.

The issue here is that the new version of CoreSimulator.framework with Xcode 11 beta does validation on CFBundleVersion that previous versions did not do. These checks are valid, and it does represent an issue in your application, but there's also a bug in how the checks were performed in Xcode 11 Beta 1 which compounds the issue.

First, fix the CFBundleVersion in your Info.plist. It should consist of only numbers and up to two periods (ie ##.[.##[.##]], eg: 12.4.2).

Second, after fixing CFBundleVersion, you need to killall -9 CoreSimulatorBridge because the old value is unfortunately cached in CoreSimulatorBridge, preventing it from recognizing the new value. This part was a bug, and it was addressed in Xcode 11 Beta 2.

Solution 2 - Ios

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 :)

Solution 3 - Ios

I went to targets and found "Version" field is empty, just fill a number, for example 1.0

enter image description here

Solution 4 - Ios

I had the same problem. I find the Xcode 11 Beta Release Notes had explain it.

Bundles without a CFBundleVersion are invalid and can’t be properly installed on 
devices or simulators. CoreSimulator now checks and rejects such bundles earlier in
the process with a clearer error message. (49892531)

And this link is the format of CFBundleVersion.

When I resolved this problem, I found out if having the CFBundleVersion problem when running App for the first time. Then it always has problem no matter whether the format is correct or not. So I restart the Xcode and the Simulator, and change the CFBundleVersion to a correct format, the App running correctly.

Solution 5 - Ios

Combining Sgeven.Zheng and Cristik's answers.

CAUSE

Installing Xcode11 Beta installs a new version of CoreSimulator.framework with the following update:

> https://developer.apple.com/documentation/xcode_release_notes/xcode_11_beta_release_notes > > "Bundles without a CFBundleVersion are invalid and can't be properly > installed on devices or simulators. CoreSimulator now checks and > rejects such bundles earlier in the process with a clearer error > message. (49892531)"

The following won't fix the issue:

  • Uninstalling Xcode11 Beta
  • Uninstalling and reinstalling Xcode 10

This is because CoreSimulator.framework is installed in /Library/Developer/PrivateFrameworks/CoreSimulator.framework, which is outside the Xcode.app bundle. When re-installed, xcode10 detects that the currently installed version of CoreSimulator.framework is newer than what xcode10 would have installed, so it leaves it as-is.

SHORT-TERM FIX

  1. Uninstall xcode11
  2. Install Xcode 10 (No need to re-install if it's already installed)
  3. Remove /Library/Developer/PrivateFrameworks/CoreSimulator.framework
  4. Launch Xcode 10 and agree to install command line tools

LONG-TERM FIX

Since this is not a "real" bug but is instead the intended behavior of Xcode11, steps will eventually need to be taken to ensure that apps are always built with a valid CFBundleVersion.

Solution 6 - Ios

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

Solution 7 - Ios

Hi I've resolved just now with this: I had in my info.plist only this key:

<key>CFBundleShortVersionString</key>
<string>2.1</string>

... and so now all works adding this:

<key>CFBundleVersion</key>
<string>2.1</string>

with the simulator that works again....

NOTE: without CFBundleVersion my app had worked perfectly on physical device!!!

Solution 8 - Ios

It's a new feature in Xcode11.

In release note it said:

>Bundles without a CFBundleVersion are invalid and can’t be properly installed on devices or simulators. CoreSimulator now checks and rejects such bundles earlier in the process with a clearer error message. (49892531)

You can:

  1. Edit your CFBundleVersion by the style of this LINK
  2. Reset your Xcode and simulator
  3. Run again, you will see it works again

When you run app in simulator success, you can change back your CFBundleVersion again, you will found it still can work XD

Solution 9 - Ios

If you get the following running error.

(* see the attached screenshots below)

This is how you can to solve this issue.

Done in few steps.

Step 1) Go to your project navigator in Xcode.

Step 2) In the info.plist.

Step 3) Add a * (Bundle versions string, short) below the (Bundle Version)

// Hint: Select the + sign to browse it if necessary .

Step 4) In the Value field (String), add the version, but with decimal period this time.

So if the (Bundle Version) is 4, make sure to add a period to it 4.0

Step 5) Build Succeed.

   Happy Coding :-)

Solution 10 - Ios

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

Solution 11 - Ios

In my case it was running the simulator/coresimulator version for 11 beta vs the one for 10.1 -> Killing and letting Xcode reopen the simulator solved the problem.

Solution 12 - Ios

I ran into this same issue as well.

I didn't get so far as to trying some of the other options provided here, but I was able to get back to building for simulator by simply deleting the /DerivedData directory.

If you're unsure as to where to find it, simply do this: Xcode -> Preferences -> Locations and select the arrow next to the path for Derived Data

Solution 13 - Ios

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.

Solution 14 - Ios

I was confronting this problem yesterday. The situation is that I pull my code from git and tried to compile, after that, I may not able to run my app on the simulator (Or archive app to submit to the app store, the version number has not been put into archive info list, no version information as 1.3.4(123)). The error message is CFbundleVersion is not correctly setup. My Xcode version is 11.4 (11E146).

so I tried following the method:

  1. Fix the CFBundleVersion in your Info.plist.(setup correct version format, numbers or X.X.XX)

  2. change the Bundle identifier, for instance, add a prefix address com.example to com.example.test. Then try to compile and install the app on the simulator. Right now, you could see the app can install normally.

  3. Then change Bundle identifier to your original one, such as com.example. Then try again, you will see you could install the app on the simulator or archive normally.

Solution 15 - Ios

In Xcode Version 12.0 beta 3 I was having continuous problem launching the Simulator. I tried all the above mentioned techniques. Nothing worked. I solved by adding this property to the Info.plist: Bundle version string (short) and setting its value to 1.0 See Image Here

Solution 16 - Ios

I faced a similar issue for hours, this is what actually worked for me.

  1. Navigate to the Resources folder
  2. Find Info.plist
  3. Add a key-value pair: CFBundleShortVersionString:
  4. Clean Build Folder
  5. Clear Device Cache
  6. Run and Build

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionPiotr SękaraView Question on Stackoverflow
Solution 1 - IosJeremy Huddleston SequoiaView Answer on Stackoverflow
Solution 2 - IosCristikView Answer on Stackoverflow
Solution 3 - IosOmar N ShamaliView Answer on Stackoverflow
Solution 4 - IosSgeven.ZhengView Answer on Stackoverflow
Solution 5 - Iosel_tigroView Answer on Stackoverflow
Solution 6 - IosSamBView Answer on Stackoverflow
Solution 7 - IosBlasco73View Answer on Stackoverflow
Solution 8 - IosEthan WenView Answer on Stackoverflow
Solution 9 - IosBugDoctorView Answer on Stackoverflow
Solution 10 - IosStevenTsoooView Answer on Stackoverflow
Solution 11 - IosJames StewartView Answer on Stackoverflow
Solution 12 - IosRay BarreraView Answer on Stackoverflow
Solution 13 - IosSundeepView Answer on Stackoverflow
Solution 14 - IosYin GongView Answer on Stackoverflow
Solution 15 - IosAbdullah KhanView Answer on Stackoverflow
Solution 16 - IosacquayefrankView Answer on Stackoverflow