|
43 | 43 |
|
44 | 44 | CI_KEYCHAIN_NAME = "fastlane_ci" |
45 | 45 | CI_KEYCHAIN_PASSWORD = "fastlane_ci_password" |
| 46 | +IOS_INFO_PLIST = "#{ROOT_DIR}/src-tauri/gen/apple/lunch_iOS/Info.plist" |
| 47 | + |
| 48 | +# Get the app version from Cargo.toml |
| 49 | +def get_app_version |
| 50 | + cargo_toml = File.read("#{ROOT_DIR}/src-tauri/Cargo.toml") |
| 51 | + if cargo_toml =~ /^version\s*=\s*"([^"]+)"/ |
| 52 | + $1 |
| 53 | + else |
| 54 | + "1.0.0" |
| 55 | + end |
| 56 | +end |
| 57 | + |
| 58 | +# Update iOS build number to be unique for TestFlight |
| 59 | +def update_ios_build_number |
| 60 | + key = api_key |
| 61 | + return unless key |
| 62 | + |
| 63 | + app_version = get_app_version |
| 64 | + UI.message("App version from Cargo.toml: #{app_version}") |
| 65 | + |
| 66 | + # Get latest build number from TestFlight for this version |
| 67 | + begin |
| 68 | + latest_build = latest_testflight_build_number( |
| 69 | + api_key: key, |
| 70 | + app_identifier: APP_IDENTIFIER, |
| 71 | + version: app_version |
| 72 | + ) |
| 73 | + UI.message("Latest TestFlight build number for v#{app_version}: #{latest_build}") |
| 74 | + rescue => e |
| 75 | + UI.message("No existing builds found for v#{app_version}, starting at 1") |
| 76 | + latest_build = 0 |
| 77 | + end |
| 78 | + |
| 79 | + new_build = latest_build + 1 |
| 80 | + UI.message("New build number: #{new_build}") |
| 81 | + |
| 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 |
| 98 | + |
| 99 | + new_build |
| 100 | +end |
46 | 101 |
|
47 | 102 | # Setup temporary keychain for CI environments |
48 | 103 | def setup_ci_keychain |
@@ -90,6 +145,15 @@ platform :ios do |
90 | 145 | keychain_password: ENV['CI'] ? CI_KEYCHAIN_PASSWORD : nil |
91 | 146 | ) |
92 | 147 |
|
| 148 | + # Initialize iOS project if needed (creates Info.plist) |
| 149 | + unless File.exist?(XCODEPROJ) |
| 150 | + UI.message("Initializing iOS project...") |
| 151 | + sh("cd #{ROOT_DIR}/src-tauri && npx tauri ios init") |
| 152 | + end |
| 153 | + |
| 154 | + # Update build number to be unique for TestFlight |
| 155 | + update_ios_build_number |
| 156 | + |
93 | 157 | # Configure Xcode project signing before Tauri build |
94 | 158 | update_code_signing_settings( |
95 | 159 | use_automatic_signing: false, |
@@ -155,6 +219,15 @@ platform :ios do |
155 | 219 | keychain_password: ENV['CI'] ? CI_KEYCHAIN_PASSWORD : nil |
156 | 220 | ) |
157 | 221 |
|
| 222 | + # Initialize iOS project if needed (creates Info.plist) |
| 223 | + unless File.exist?(XCODEPROJ) |
| 224 | + UI.message("Initializing iOS project...") |
| 225 | + sh("cd #{ROOT_DIR}/src-tauri && npx tauri ios init") |
| 226 | + end |
| 227 | + |
| 228 | + # Update build number to be unique for App Store |
| 229 | + update_ios_build_number |
| 230 | + |
158 | 231 | # Configure Xcode project signing before Tauri build |
159 | 232 | update_code_signing_settings( |
160 | 233 | use_automatic_signing: false, |
|
0 commit comments