I am experiencing an issue where XCode reverts .xccurrentversion
file in my iOS app to the first version whenever xcodebuild
is run or whenever XCode is started. This means I can build the app and run tests in XCode if I discard the reversion .xccurrentversion
on XCode start. However, testing on CI is impossible because the version the tests rely on are reverted whenever xcodebuild
is run.
The commands I run to reproduce the issue
❯ git status
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: Path/.xccurrentversion
no changes added to commit (use "git add" and/or "git commit -a")
❯ git checkout "Path/.xccurrentversion"
Updated 1 path from the index
❯ git status
nothing to commit, working tree clean
❯ xcodebuild \
-scheme Scheme \
-configuration Configuration \
-sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone 16 Pro,OS=latest' \
-skipPackagePluginValidation \
-skipMacroValidation \
test > /dev/null # test fails because model version is reverted
❯ git status
HEAD detached at pull/249/merge
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: Path/.xccurrentversion
no changes added to commit (use "git add" and/or "git commit -a")
I have experienced such issue in 16.3 (16E140)
and 16.2 (16C5032a)
.
Similar issues/solutions I have found online are the following. But they are either not relevant or do not work in my case.
- https://stackoverflow.com/questions/17631587/xcode-modifies-current-coredata-model-version-at-every-launch
- https://github.com/CocoaPods/Xcodeproj/issues/81
Is anyone aware of any solution? Is there a recommended way I can run diagnostics on XCode and file a feedback?