Skip to content

Commit 5a0ce0c

Browse files
fix (fastlane): set version in tauri.conf.json before iOS build
Tauri was overwriting Info.plist with default version 1.0.0 during build. Now sets both version and bundle.iOS.bundleVersion in tauri.conf.json before running tauri ios init/build. - Read app version from Cargo.toml - Query TestFlight for latest build number - Set version (CFBundleShortVersionString) and bundleVersion (CFBundleVersion) in tauri.conf.json before Tauri processes it 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 6106ecf commit 5a0ce0c

1 file changed

Lines changed: 33 additions & 28 deletions

File tree

fastlane/Fastfile

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ def get_app_version
5555
end
5656
end
5757

58-
# Update iOS build number to be unique for TestFlight
59-
def update_ios_build_number
58+
# Get the next unique build number for TestFlight
59+
def get_next_build_number
6060
key = api_key
61-
return unless key
61+
return 1 unless key
6262

6363
app_version = get_app_version
6464
UI.message("App version from Cargo.toml: #{app_version}")
@@ -78,25 +78,29 @@ def update_ios_build_number
7878

7979
new_build = latest_build + 1
8080
UI.message("New build number: #{new_build}")
81+
new_build
82+
end
8183

82-
# Update Info.plist with new version and build number
83-
if File.exist?(IOS_INFO_PLIST)
84-
set_info_plist_value(
85-
path: IOS_INFO_PLIST,
86-
key: "CFBundleShortVersionString",
87-
value: app_version
88-
)
89-
set_info_plist_value(
90-
path: IOS_INFO_PLIST,
91-
key: "CFBundleVersion",
92-
value: new_build.to_s
93-
)
94-
UI.success("Updated iOS Info.plist: v#{app_version} (#{new_build})")
95-
else
96-
UI.important("iOS Info.plist not found at #{IOS_INFO_PLIST} - will be created by tauri ios init")
97-
end
84+
# Update tauri.conf.json with version from Cargo.toml and unique build number
85+
def update_tauri_config_version
86+
app_version = get_app_version
87+
build_number = get_next_build_number
9888

99-
new_build
89+
tauri_conf_path = "#{ROOT_DIR}/src-tauri/tauri.conf.json"
90+
tauri_conf = JSON.parse(File.read(tauri_conf_path))
91+
92+
# Set app version (CFBundleShortVersionString)
93+
tauri_conf["version"] = app_version
94+
95+
# Set iOS-specific bundle version (CFBundleVersion) for unique build numbers
96+
tauri_conf["bundle"] ||= {}
97+
tauri_conf["bundle"]["iOS"] ||= {}
98+
tauri_conf["bundle"]["iOS"]["bundleVersion"] = build_number.to_s
99+
100+
File.write(tauri_conf_path, JSON.pretty_generate(tauri_conf))
101+
UI.success("Updated tauri.conf.json: v#{app_version} (build #{build_number})")
102+
103+
{ version: app_version, build: build_number }
100104
end
101105

102106
# Setup temporary keychain for CI environments
@@ -145,15 +149,16 @@ platform :ios do
145149
keychain_password: ENV['CI'] ? CI_KEYCHAIN_PASSWORD : nil
146150
)
147151

148-
# Initialize iOS project if needed (creates Info.plist)
152+
# Update tauri.conf.json with version and unique build number BEFORE init
153+
# This ensures Tauri uses the correct version when generating the iOS project
154+
update_tauri_config_version
155+
156+
# Initialize iOS project if needed (creates Info.plist with correct version)
149157
unless File.exist?(XCODEPROJ)
150158
UI.message("Initializing iOS project...")
151159
sh("cd #{ROOT_DIR}/src-tauri && npx tauri ios init")
152160
end
153161

154-
# Update build number to be unique for TestFlight
155-
update_ios_build_number
156-
157162
# Configure Xcode project signing before Tauri build
158163
update_code_signing_settings(
159164
use_automatic_signing: false,
@@ -219,15 +224,15 @@ platform :ios do
219224
keychain_password: ENV['CI'] ? CI_KEYCHAIN_PASSWORD : nil
220225
)
221226

222-
# Initialize iOS project if needed (creates Info.plist)
227+
# Update tauri.conf.json with version and unique build number BEFORE init
228+
update_tauri_config_version
229+
230+
# Initialize iOS project if needed (creates Info.plist with correct version)
223231
unless File.exist?(XCODEPROJ)
224232
UI.message("Initializing iOS project...")
225233
sh("cd #{ROOT_DIR}/src-tauri && npx tauri ios init")
226234
end
227235

228-
# Update build number to be unique for App Store
229-
update_ios_build_number
230-
231236
# Configure Xcode project signing before Tauri build
232237
update_code_signing_settings(
233238
use_automatic_signing: false,

0 commit comments

Comments
 (0)