From 97b576eb6b810640784b4cf1fab185cdab633609 Mon Sep 17 00:00:00 2001 From: Gray Zhang Date: Tue, 23 Sep 2025 00:02:02 +0800 Subject: [PATCH] fix: properly integrate xcconfig for centralized version management - Added Version.xcconfig as the single source of truth for versions - Linked xcconfig to project configurations via baseConfigurationReference - Removed all hardcoded version values from project.pbxproj - Added Config group to project structure with xcconfig file - Updated documentation to reflect the correct process Now only need to edit V2er/Config/Version.xcconfig to update versions! No more updating multiple places in project.pbxproj. --- V2er.xcodeproj/project.pbxproj | 16 ++++++++++++---- V2er/Config/Version.xcconfig | 2 +- VERSIONING.md | 25 +++++++++---------------- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/V2er.xcodeproj/project.pbxproj b/V2er.xcodeproj/project.pbxproj index 17e0ebc..cb73cf9 100644 --- a/V2er.xcodeproj/project.pbxproj +++ b/V2er.xcodeproj/project.pbxproj @@ -203,6 +203,7 @@ 5D2B2B3926FF5DF800446F93 /* AccountInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountInfo.swift; sourceTree = ""; }; 5D2B2B3B26FF754F00446F93 /* Persist.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Persist.swift; sourceTree = ""; }; 5D2B2B3D26FF797600446F93 /* AccountState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountState.swift; sourceTree = ""; }; + 5DA0000000000000000001 /* Version.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Version.xcconfig; sourceTree = ""; }; 5D2DD00726FB353C0001C85A /* DefaultReducer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultReducer.swift; sourceTree = ""; }; 5D2DD00926FB443D0001C85A /* GlobalActions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GlobalActions.swift; sourceTree = ""; }; 5D368C8726C419D000794B8E /* APIService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APIService.swift; sourceTree = ""; }; @@ -342,6 +343,14 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 5DA0000000000000000002 /* Config */ = { + isa = PBXGroup; + children = ( + 5DA0000000000000000001 /* Version.xcconfig */, + ); + path = Config; + sourceTree = ""; + }; 5D179BFD2496F6EC00E40E90 /* Widget */ = { isa = PBXGroup; children = ( @@ -448,6 +457,7 @@ 5D436FE724791C2C00FFA37E /* V2er */ = { isa = PBXGroup; children = ( + 5DA0000000000000000002 /* Config */, 5DE5C577249D90690004DCC6 /* General */, 5DE5B4C826845F4F00569684 /* View */, 5DA2AD3326C17E7F007FB1EF /* State */, @@ -1011,6 +1021,7 @@ /* Begin XCBuildConfiguration section */ 5D43700D24791C2D00FFA37E /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 5DA0000000000000000001 /* Version.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; @@ -1061,19 +1072,18 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 15.0; - MARKETING_VERSION = 1.1.2; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - CURRENT_PROJECT_VERSION = 29; }; name = Debug; }; 5D43700E24791C2D00FFA37E /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 5DA0000000000000000001 /* Version.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; @@ -1118,14 +1128,12 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 15.0; - MARKETING_VERSION = 1.1.2; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = iphoneos; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-O"; VALIDATE_PRODUCT = YES; - CURRENT_PROJECT_VERSION = 29; }; name = Release; }; diff --git a/V2er/Config/Version.xcconfig b/V2er/Config/Version.xcconfig index fc0ad20..026b10c 100644 --- a/V2er/Config/Version.xcconfig +++ b/V2er/Config/Version.xcconfig @@ -9,4 +9,4 @@ MARKETING_VERSION = 1.1.2 // VERSION_CODE - Internal build number (e.g., 29, 30, 31...) -CURRENT_PROJECT_VERSION = 29 \ No newline at end of file +CURRENT_PROJECT_VERSION = 30 \ No newline at end of file diff --git a/VERSIONING.md b/VERSIONING.md index b7f58a4..4d032db 100644 --- a/VERSIONING.md +++ b/VERSIONING.md @@ -20,31 +20,24 @@ This project uses two version identifiers: **Versions are now defined in ONE place only!** -The version numbers are defined at the project level and automatically inherited by all targets (Debug and Release). - ### How to Update Versions -To update versions, you only need to modify **2 locations** in `V2er.xcodeproj/project.pbxproj`: +To update versions, simply edit the file `V2er/Config/Version.xcconfig`: -1. Search for the **Debug** project configuration and update: -``` -/* Debug project configuration */ -MARKETING_VERSION = 1.1.2; /* VERSION_NAME */ -CURRENT_PROJECT_VERSION = 29; /* VERSION_CODE */ -``` +```bash +# Open the file +V2er/Config/Version.xcconfig -2. Search for the **Release** project configuration and update: -``` -/* Release project configuration */ -MARKETING_VERSION = 1.1.2; /* VERSION_NAME */ -CURRENT_PROJECT_VERSION = 29; /* VERSION_CODE */ +# Update these two lines: +MARKETING_VERSION = 1.1.2 # VERSION_NAME (user-facing version) +CURRENT_PROJECT_VERSION = 29 # VERSION_CODE (build number) ``` -That's it! The target configurations will automatically inherit these values. +**That's it!** No need to edit project.pbxproj or any other files. The xcconfig file is automatically loaded by Xcode and applies to all build configurations. ## Important Notes -1. **Both values must be updated** in both Debug and Release configurations +1. **Only update Version.xcconfig** - Never modify version numbers in project.pbxproj 2. **VERSION_CODE must always increase** - even for the same VERSION_NAME 3. **Fastlane auto-increment**: Our Fastlane setup automatically increments VERSION_CODE for TestFlight builds 4. **Info.plist**: Automatically uses these values via: