diff --git a/scripts/build-ios.sh b/scripts/build-ios.sh index c0182bf3..5f39ec51 100755 --- a/scripts/build-ios.sh +++ b/scripts/build-ios.sh @@ -349,10 +349,56 @@ if [ "$CLEAN_ONLY" = true ]; then exit 0 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 if [ "$SYNC_ONLY" = true ]; then - log_info "Sync-only mode: syncing with Capacitor" - safe_execute "Syncing with Capacitor" "npx cap sync ios" || exit 6 + log_info "Sync-only mode: syncing with Capacitor (with Xcode 26 workaround if needed)" + safe_execute "Syncing with Capacitor" "run_cap_sync_with_workaround" || exit 6 log_success "Sync completed successfully!" exit 0 fi @@ -433,13 +479,13 @@ fi # it back to 70 when opened, which is fine. # # NOTE: Both explicit pod install AND Capacitor sync (which runs pod install -# internally) need this workaround. See run_pod_install_with_workaround() -# and run_cap_sync_with_workaround() functions below. +# internally) need this workaround. run_pod_install_with_workaround() is below; +# run_cap_sync_with_workaround() is defined earlier (used by --sync and Step 6.6). # # TO REMOVE THIS WORKAROUND IN THE FUTURE: # 1. Check if xcodeproj gem has been updated: bundle exec gem list xcodeproj # 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: # - 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 @@ -505,56 +551,7 @@ run_pod_install_with_workaround() { 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) -# 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 -} - +# Step 6.6: Sync with Capacitor (uses run_cap_sync_with_workaround defined above for Xcode 26) safe_execute "Syncing with Capacitor" "run_cap_sync_with_workaround" || exit 6 # Step 7: Generate assets