fix(ios): use Xcode 26 workaround in sync-only mode

--sync was calling npx cap sync ios directly, so pod install failed
on Xcode 26 (objectVersion 70). Define run_cap_sync_with_workaround
once before sync-only and use it for both --sync and the full build;
remove the duplicate definition at Step 6.6.
This commit is contained in:
Jose Olarte III
2026-02-06 16:50:53 +08:00
parent f5cb70ec8b
commit fe9cdd6398

View File

@@ -349,10 +349,56 @@ if [ "$CLEAN_ONLY" = true ]; then
exit 0 exit 0
fi fi
# Xcode 26 / CocoaPods workaround for cap sync (used by sync-only and full build)
# Temporarily downgrade project.pbxproj objectVersion 70 -> 56 so pod install succeeds.
run_cap_sync_with_workaround() {
local PROJECT_FILE="ios/App/App.xcodeproj/project.pbxproj"
if [ ! -f "$PROJECT_FILE" ]; then
log_error "Project file not found: $PROJECT_FILE (run full build first?)"
return 1
fi
local current_version
current_version=$(grep "objectVersion" "$PROJECT_FILE" | head -1 | grep -o "[0-9]\+" || echo "")
if [ -z "$current_version" ]; then
log_error "Could not determine project format version for Capacitor sync"
return 1
fi
if [ "$current_version" = "70" ]; then
log_debug "Applying Xcode 26 workaround for Capacitor sync: temporarily downgrading to format 56"
if ! sed -i '' 's/objectVersion = 70;/objectVersion = 56;/' "$PROJECT_FILE"; then
log_error "Failed to downgrade project format for Capacitor sync"
return 1
fi
log_info "Running Capacitor sync..."
if ! npx cap sync ios; then
log_error "Capacitor sync failed"
sed -i '' 's/objectVersion = 56;/objectVersion = 70;/' "$PROJECT_FILE" || true
return 1
fi
log_debug "Restoring project format to 70 after Capacitor sync..."
sed -i '' 's/objectVersion = 56;/objectVersion = 70;/' "$PROJECT_FILE" || true
log_success "Capacitor sync completed successfully"
else
log_debug "Project format is $current_version, running Capacitor sync normally"
if ! npx cap sync ios; then
log_error "Capacitor sync failed"
return 1
fi
log_success "Capacitor sync completed successfully"
fi
}
# Handle sync-only mode # Handle sync-only mode
if [ "$SYNC_ONLY" = true ]; then if [ "$SYNC_ONLY" = true ]; then
log_info "Sync-only mode: syncing with Capacitor" log_info "Sync-only mode: syncing with Capacitor (with Xcode 26 workaround if needed)"
safe_execute "Syncing with Capacitor" "npx cap sync ios" || exit 6 safe_execute "Syncing with Capacitor" "run_cap_sync_with_workaround" || exit 6
log_success "Sync completed successfully!" log_success "Sync completed successfully!"
exit 0 exit 0
fi fi
@@ -433,13 +479,13 @@ fi
# it back to 70 when opened, which is fine. # it back to 70 when opened, which is fine.
# #
# NOTE: Both explicit pod install AND Capacitor sync (which runs pod install # NOTE: Both explicit pod install AND Capacitor sync (which runs pod install
# internally) need this workaround. See run_pod_install_with_workaround() # internally) need this workaround. run_pod_install_with_workaround() is below;
# and run_cap_sync_with_workaround() functions below. # run_cap_sync_with_workaround() is defined earlier (used by --sync and Step 6.6).
# #
# TO REMOVE THIS WORKAROUND IN THE FUTURE: # TO REMOVE THIS WORKAROUND IN THE FUTURE:
# 1. Check if xcodeproj gem has been updated: bundle exec gem list xcodeproj # 1. Check if xcodeproj gem has been updated: bundle exec gem list xcodeproj
# 2. Test if pod install works without the workaround # 2. Test if pod install works without the workaround
# 3. If it works, remove both workaround functions below # 3. If it works, remove run_pod_install_with_workaround() and run_cap_sync_with_workaround()
# 4. Replace with: # 4. Replace with:
# - safe_execute "Installing CocoaPods dependencies" "cd ios/App && bundle exec pod install && cd ../.." || exit 6 # - safe_execute "Installing CocoaPods dependencies" "cd ios/App && bundle exec pod install && cd ../.." || exit 6
# - safe_execute "Syncing with Capacitor" "npx cap sync ios" || exit 6 # - safe_execute "Syncing with Capacitor" "npx cap sync ios" || exit 6
@@ -505,56 +551,7 @@ run_pod_install_with_workaround() {
safe_execute "Installing CocoaPods dependencies" "run_pod_install_with_workaround" || exit 6 safe_execute "Installing CocoaPods dependencies" "run_pod_install_with_workaround" || exit 6
# Step 6.6: Sync with Capacitor (also needs workaround since it runs pod install internally) # Step 6.6: Sync with Capacitor (uses run_cap_sync_with_workaround defined above for Xcode 26)
# Capacitor sync internally runs pod install, so we need to apply the workaround here too
run_cap_sync_with_workaround() {
local PROJECT_FILE="ios/App/App.xcodeproj/project.pbxproj"
# Check current format version
local current_version=$(grep "objectVersion" "$PROJECT_FILE" | head -1 | grep -o "[0-9]\+" || echo "")
if [ -z "$current_version" ]; then
log_error "Could not determine project format version for Capacitor sync"
return 1
fi
# Only apply workaround if format is 70
if [ "$current_version" = "70" ]; then
log_debug "Applying Xcode 26 workaround for Capacitor sync: temporarily downgrading to format 56"
# Downgrade to format 56 (supported by CocoaPods)
if ! sed -i '' 's/objectVersion = 70;/objectVersion = 56;/' "$PROJECT_FILE"; then
log_error "Failed to downgrade project format for Capacitor sync"
return 1
fi
# Run Capacitor sync (which will run pod install internally)
log_info "Running Capacitor sync..."
if ! npx cap sync ios; then
log_error "Capacitor sync failed"
# Try to restore format even on failure
sed -i '' 's/objectVersion = 56;/objectVersion = 70;/' "$PROJECT_FILE" || true
return 1
fi
# Restore to format 70
log_debug "Restoring project format to 70 after Capacitor sync..."
if ! sed -i '' 's/objectVersion = 56;/objectVersion = 70;/' "$PROJECT_FILE"; then
log_warn "Failed to restore project format to 70 (Xcode will upgrade it automatically)"
fi
log_success "Capacitor sync completed successfully"
else
# Format is not 70, run sync normally
log_debug "Project format is $current_version, running Capacitor sync normally"
if ! npx cap sync ios; then
log_error "Capacitor sync failed"
return 1
fi
log_success "Capacitor sync completed successfully"
fi
}
safe_execute "Syncing with Capacitor" "run_cap_sync_with_workaround" || exit 6 safe_execute "Syncing with Capacitor" "run_cap_sync_with_workaround" || exit 6
# Step 7: Generate assets # Step 7: Generate assets