DailyRoundup embeds two pieces of build-time metadata into the app:
CFBundleVersion / CURRENT_PROJECT_VERSION)Both values are injected into Info.plist before each build and surfaced in the Settings screen.
The Settings → About section displays all three version fields on one line:
Version 1.0 (142) · 4b897d7
^^^ ^^^ ^^^^^^^
| | short git SHA — read from Info.plist key GitCommitHash
| commit count — read from Info.plist key GitCommitCount
marketing version — CFBundleShortVersionString
CFBundleVersion (CURRENT_PROJECT_VERSION) is not shown in this string; it is used only by the App Store and is visible in iOS Settings → General → About → DailyRoundup as the build number. On CI release builds CFBundleVersion equals the commit count; on local Debug builds it remains the static value set in project.pbxproj (currently 1).
The Xcode scheme DailyRoundup.xcscheme contains a Build Pre-Action called Set Build Number from Git that runs before every build (including Simulator runs):
GIT_COUNT=$(git -C "${SRCROOT}" rev-list --count HEAD 2>/dev/null || echo 0)
GIT_SHA=$(git -C "${SRCROOT}" rev-parse --short HEAD 2>/dev/null || echo unknown)
PLIST="${SRCROOT}/DailyRoundup/Info.plist"
/usr/libexec/PlistBuddy -c "Set :GitCommitCount ${GIT_COUNT}" "${PLIST}" >/dev/null 2>&1
/usr/libexec/PlistBuddy -c "Set :GitCommitHash ${GIT_SHA}" "${PLIST}" >/dev/null 2>&1
This script overwrites the GitCommitCount and GitCommitHash keys in DailyRoundup/Info.plist in place. The updated values are picked up immediately by the running build. Because the script writes into the source-tree Info.plist, the file will appear modified in git status after every build; this is expected and those changes can be discarded or committed as desired.
CURRENT_PROJECT_VERSION is not updated by the pre-action. Local Debug builds therefore show the static value from project.pbxproj (currently 1) as CFBundleVersion, while GitCommitCount and GitCommitHash in Info.plist are always updated to the current commit. The Settings screen reads GitCommitCount directly from Info.plist, so it always shows the real commit count regardless of the build type.
release.yml)The release.yml GitHub Actions workflow runs on every merge to main that touches iOS app files. It overrides CURRENT_PROJECT_VERSION at archive time:
- name: Archive
run: |
GIT_COUNT=$(git rev-list --count HEAD)
xcodebuild archive \
...
CURRENT_PROJECT_VERSION=$GIT_COUNT
fetch-depth: 0 is set on the actions/checkout step so that the full commit history is available and the count is accurate.
The Xcode scheme pre-action also runs during the CI archive step, so GitCommitCount and GitCommitHash in Info.plist are updated to match the CI build.
| File | Role |
|---|---|
DailyRoundup.xcodeproj/xcshareddata/xcschemes/DailyRoundup.xcscheme |
Build Pre-Action that writes GitCommitCount and GitCommitHash into Info.plist |
DailyRoundup/Info.plist |
Stores GitCommitCount and GitCommitHash; last-written values are checked into source control |
.github/workflows/release.yml |
Passes CURRENT_PROJECT_VERSION=$GIT_COUNT to xcodebuild archive; uses fetch-depth: 0 |
DailyRoundup/SettingsView.swift (aboutSection) |
Reads all three values from Bundle.main.infoDictionary and displays them |
Commit count shows 0 or unknown in a local build
The pre-action runs inside the Xcode build system, not a full shell. If the git binary is not found at its default path or SRCROOT is unexpected, the script falls back to 0 / unknown. Run the script manually in Terminal from the project root to verify:
git rev-list --count HEAD
git rev-parse --short HEAD
Commit count is wrong on CI
Check that the actions/checkout step in release.yml uses fetch-depth: 0. A shallow clone (the default fetch-depth: 1) would count only one commit.
Extending the metadata
To add more build-time values (e.g., branch name, build date):
DailyRoundup/Info.plist with a placeholder string value.PlistBuddy command to the pre-action script in DailyRoundup.xcscheme.SettingsView.swift via Bundle.main.infoDictionary?["YourKey"].