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.

Piotr Sękara
  • 710
  • 1
  • 5
  • 8
  • What value do you have for the CFBundleVersion? – rmaddy Jun 04 '19 at 19:41
  • Do you use a source control ? If yes, try to look at the changes before opening the project with Xcode 11 – cesarmarch Jun 04 '19 at 19:45
  • @maddy - I've version 0.1 from the beggining of the project. Nothing has changed here and it was working also so far. – Piotr Sękara Jun 04 '19 at 19:45
  • @cesarmarch - Yeap, as I've said, repository was pulled from latest working version. Nothing has changed. – Piotr Sękara Jun 04 '19 at 19:46
  • Oh I didn't read well sorry. Did you just clean and pull or do a full checkout of the project ? – cesarmarch Jun 04 '19 at 19:50
  • @cesarmarch No worries, I've cleaned and pulled repo, and then I've also done a full fresh checkout of the project. I've also tried to run the project from my friend- nothing. – Piotr Sękara Jun 04 '19 at 19:51
  • Can you just try changing for 1.0 ? – cesarmarch Jun 04 '19 at 19:54
  • Already tried that - I was setting 0.1, 1.0, 1.1.0, 1.0.1 etc. - nothing has worked. – Piotr Sękara Jun 04 '19 at 19:55
  • Have you tried to reset your simulator ? – cesarmarch Jun 04 '19 at 20:17
  • While removing completely Xcode, I’ve also removed all simulators - nothing – Piotr Sękara Jun 04 '19 at 20:20
  • 1
    I know this is probably not a very helpful comment, but I had this with my project too. I don't know what exactly made it disappear for me, but I did the following things and then it ended up working fine. 1. Turned off internet connection, 2. Added CFBundleVersion to every single plist file in my project, 3. Deleted DerivedData folder, 4. Closed Xcode and simulators, 5. Built the project with Xcode 10 and iOS 12 simulator, 6. Closed Xcode 10 and tried building it with Xcode 11 and it worked. I don't know why, even after reverting plist file changes it's still working. – silicon_valley Jun 04 '19 at 21:43
  • I'm getting the same issue. tried cleaning, deleting derived data, resetting simulator, rebooting all to no luck. Strange thing is that it complied last night on the same version of the code and Xcode 11 Beta. – Hendrix Jun 04 '19 at 22:50
  • 1
    update. it stopped working in Xcode 10 too. but some voodoo magic dance of clean build deleting derived data in Xcode 10 allowed it build. then did the same magic steps and viola, it builds. Not helpful I know, but I'm just as confused as when I got this problem. – Hendrix Jun 04 '19 at 23:14
  • 1
    Erasing all content and settings in each of my sims seemed to work for me. I am able to build and run our app in Xcode 10 / iOS 12 sim and Xcode 11 / iOS 13 sim. – bradleyrzeller Jun 05 '19 at 00:09
  • Don't know what to say... I was already trying to clean derived data, build folder and sims many times before, but I've decided to give one more chance for some magic dances on the Xcode and after many tries of removing dd, cleaning build folder and erasing sim content, project has runned on the simulator. Don't know how and don't know what happened. Nothing has changed in the project files (configs/plists etc.) when trying to run on simulator. It seems to me like some magic bug. I needed 12 attempts of this sequence to run application on simulator. – Piotr Sękara Jun 05 '19 at 06:11
  • I tried cleaning derived data , resetting simulator, still same issue. – Badrinath Jun 05 '19 at 23:17

17 Answers17

56

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.

Jeremy Huddleston Sequoia
  • 22,938
  • 5
  • 78
  • 86
  • 1
    The caching bug is addressed in Xcode 11 Beta 2. If you are still getting error messages with Xcode 11 Beta 2 or later, please make sure you actually fixed your project's Info.plist ;) – Jeremy Huddleston Sequoia Jun 20 '19 at 16:00
  • 1
    Errr... if I'm not wrong CFBundleVersion is the "build number" which is more like 123456, but not 12.4.2. What you are talking about represents the app version and is called CFBundleShortVersionString in Info.plist. – RAM237 Apr 16 '20 at 16:58
22

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

Cristik
  • 30,989
  • 25
  • 91
  • 127
  • 2
    Same solution worked here as well. I iteratively deleted stuff, starting with ~/Library/Developer/Xcode/Derived Data and ultimately it took removing the main /Library/Developer folder to clear up the issue. Thank you for your post. – Brains Jun 07 '19 at 17:27
  • For me, it's working fine after removing this folder: /Library/Developer Its due to Xcode 11 installation – Ekambaram E Jun 08 '19 at 07:09
10

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

enter image description here

Omar N Shamali
  • 503
  • 5
  • 11
8

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.

  • It works but it doesn't really makes any sense because even with an "Invalid" `CFBundleVersion` (previously working `CFBundleVersion`), it can be installed into a physical device. It has to be a bug. – thxou Jun 05 '19 at 07:44
  • Yes, It is a issue of Xcode Beta. Physical device is OK. – Sgeven.Zheng Jun 05 '19 at 08:13
  • From my tests, it only restricts the first installation of an app on Simulator: subsequent updates of the app can freely use invalid CFBundleVersion with Xcode 11 beta. – Cœur Jun 06 '19 at 04:14
  • still having this issue on xCode 11.5 – Pedro Soares Jun 16 '20 at 08:35
7

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.

el_tigro
  • 1,099
  • 2
  • 10
  • 22
6

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

SamB
  • 2,621
  • 4
  • 34
  • 39
  • In my case the Version and Build textboxes were both empty. I added 1.0 for the Version and 1 for the Build field and it build fine. This is the solution to try first before deleting your Library/Developer folder. This error occurred for me on Xcode 11.3 after a merge of an old branch. – MangoLassi Jan 04 '20 at 23:54
4

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!!!

Blasco73
  • 2,980
  • 2
  • 24
  • 30
  • I found this solution the best one. However you will need to make sure your OS is the latest version along with your Xcode - that was the issue for me. – Jokz Dec 30 '21 at 17:27
  • In my case I can not use static values since Xcode v13.3.x or v13.4.x . I had to reference using variables CURRENT_PROJECT_VERSION and MARKETING_VERSION and this vars MUST EXISTS in project.pbxproj. In prev. Xcode I do not have that vars and everything was working fine with static values CFBundleVersion and CFBundleShortVersionString in Info.plist. Now it is changed and Xcode as always gives stupid misleading error messages that CFBundleVersion is not in Info.plist (but it is there). See more in my answer https://stackoverflow.com/a/72726108/3826175 – mikep Jun 23 '22 at 07:27
3

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 :-)
BugDoctor
  • 39
  • 4
2

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

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Ethan Wen
  • 81
  • 2
  • Probably some kind of bug in Xcode Beta, because CFBundleVersion was setted correctly and also I've not changed anything while trying to run application in the simulator - after 12 attempts of cleaning derived data, build folder and simulator it has successfully opened in the simulator. – Piotr Sękara Jun 05 '19 at 08:21
  • What do you mean by "Reset your Xcode and simulator"? I deleted the Beta and that didn't fix my Xcode 10.2.1 installation. – Dustin Pfannenstiel Jun 06 '19 at 13:31
1

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

StevenTsooo
  • 498
  • 4
  • 13
1

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.

1

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.

Sundeep
  • 384
  • 2
  • 6
  • 1
    I think the correct value for `CFBundleVersion` should be `$(CURRENT_PROJECT_VERSION)` while the `CFBundleShortVersionString` should be `$(MARKETING_VERSION)`. – ThomasW Jul 16 '20 at 05:17
0

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

0

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.

Yin Gong
  • 221
  • 2
  • 4
0

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

0

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
acquayefrank
  • 474
  • 5
  • 21
0

After upgrade from Xcode 13.2.x to 13.4.x my app archive started to show in organizer in section "Other items" not in "iOS apps". Also in organizer app has empty version. Build to iPhone was working, build on simulator failed due to error, that I do not have CFBundleVersion in Info.plist - but I had it there. I had fixed number (not variable) and it is root of problem. I had to change static values to variables....

File Info.plist

// OLD incorrect
<key>CFBundleVersion</key>
<string>345</string>
<key>CFBundleShortVersionString</key>
<string>1.2.3</string>

// NEW correct
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>

File project.pbxproj

...
CURRENT_PROJECT_VERSION = 345;
MARKETING_VERSION = 1.2.3;
...

And additionally I had to add variables to file project.pbxproj to Release and Debug sections because I did not have it there. So with older Xcode it was working this way and versions was taken from Info.plist. Now it seems that source of true are variables from project.pbxproj but Apple have incorrect error messages because it is fail to say in error that CFBundleVersion is missing in Info.plist when it is there. Finally Xcode automatically deleted CFBundleVersion and CFBundleShortVersionString from Info.plist.

I have spent many many hours of finding out what is problem. I hate upgrading Xcode - nightmare, many hours always lost.

mikep
  • 5,880
  • 2
  • 30
  • 37