Xcode 14 and missing sync with CFBundleVersion edit in Info.plist during Build/Archive

2.1k Views Asked by At

In my iOS apps, i have a script (a build phase actually) that upgrades the target's Info.plist CFBundleVersion to a number related to the git commit count. I've been using for a while and it works for me, never a problem.

On Xcode 14, something has changed and the script keeps working (i mean the .plist file is correctly updated) but applications no longer shows the correct build number and it's missing on Archive too. I'll add some screenshot (of a blank new project, so no settings have been altered in times).

This is Target's General Tab in Xcode 14 This is Target's General Tab

This is Target's Info TabTarget's Info Tab

This is Info.plist file correctly updated by Build Phase ScriptInfo.plist file

In previous Xcode versions, on Target's General Tab i used to have the build number synced with the one in .plist file and it was also synced when Archiving builds.

Now, if i try to archive the build, it goes out as 1.0(1).

Am I missing something or am I doing something wrong?

Hope you can understand my English. Thanks for your help.

2

There are 2 best solutions below

0
On

I use xcconfig for set version and build in Xcode. In Base.xcconfig set

MARKETING_VERSION = 22.47.0
CURRENT_PROJECT_VERSION = 221125.1437

Pay attention if you using CocoaPods you should create Release and Debug xcconfig with content Debug.xcconfig

#include "../Pods/Target Support Files/Pods-{SET_PROJECT_HERE}/Pods-{SET_PROJECT_HERE}.debug.xcconfig"
#include "Base.xcconfig"

Release.xcconfig

#include "../Pods/Target Support Files/Pods-{SET_PROJECT_HERE}/Pods-{SET_PROJECT_HERE}.release.xcconfig"
#include "Base.xcconfig"

Set values in info.plist

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

Hope its help

1
On

Feb 20th, 2023, my temporary solution:

step 0: delete the system generated info.plist

step 1: move all settings to your plist file as you did years ago and rename it to any+info.plist

step 2: after adding your any+info.plist file to project, delete it from 'Build phase copy bundle'

step 3: search build setting and make ALL "Generate info.plist" to NO

step 4: search 'Infor.plist File' and give the correct file path of you file

step 5: use this run script

#!/bin/bash

buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE") buildNumber=$(($buildNumber + 1)) /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"

step 6: leave a real number in your plist as the bundle version e.g.100

step 7: clean build folder, restart Xcode 14, and build the project

Good Luck!