feat(ios): implement native share target for images
Implement iOS Share Extension to enable native image sharing from Photos and other apps directly into TimeSafari. Users can now share images from the iOS share sheet, which will open in SharedPhotoView for use as gifts or profile pictures. iOS Native Implementation: - Add TimeSafariShareExtension target with ShareViewController - Configure App Groups for data sharing between extension and main app - Implement ShareViewController to process shared images and convert to base64 - Store shared image data in App Group UserDefaults - Add ShareImageBridge utility to read shared data from App Group - Update AppDelegate to handle shared-photo deep link and bridge data to JS JavaScript Integration: - Add checkAndStoreNativeSharedImage() in main.capacitor.ts to read shared images from native layer via temporary file bridge - Convert base64 data to data URL format for compatibility with base64ToBlob - Integrate with existing SharedPhotoView component - Add "shared-photo" to deep link validation schema Build System: - Integrate Xcode 26 / CocoaPods compatibility workaround into build-ios.sh - Add run_pod_install_with_workaround() for explicit pod install - Add run_cap_sync_with_workaround() for Capacitor sync (which runs pod install internally) - Automatically detect project format version 70 and apply workaround - Remove standalone pod-install-workaround.sh script Code Cleanup: - Remove verbose debug logs from ShareViewController, AppDelegate, and main.capacitor.ts - Retain essential logger calls for production debugging Documentation: - Add ios-share-extension-setup.md with manual Xcode setup instructions - Add ios-share-extension-git-commit-guide.md for version control best practices - Add ios-share-implementation-status.md tracking implementation progress - Add native-share-target-implementation.md with overall architecture - Add xcode-26-cocoapods-workaround.md documenting the compatibility issue The implementation uses a temporary file bridge (AppDelegate writes to Documents directory, JS reads via Capacitor Filesystem plugin) as a workaround for Capacitor plugin auto-discovery issues. This can be improved in the future by properly registering ShareImagePlugin in Capacitor's plugin registry.
This commit is contained in:
@@ -404,8 +404,141 @@ elif [ "$BUILD_MODE" = "production" ]; then
|
||||
safe_execute "Building Capacitor version (production)" "npm run build:capacitor -- --mode production" || exit 3
|
||||
fi
|
||||
|
||||
# Step 6: Sync with Capacitor
|
||||
safe_execute "Syncing with Capacitor" "npx cap sync ios" || exit 6
|
||||
# Step 6: Install CocoaPods dependencies (with Xcode 26 workaround)
|
||||
# ===================================================================
|
||||
# WORKAROUND: Xcode 26 / CocoaPods Compatibility Issue
|
||||
# ===================================================================
|
||||
# Xcode 26 uses project format version 70, but CocoaPods' xcodeproj gem
|
||||
# (1.27.0) only supports up to version 56. This causes pod install to fail.
|
||||
#
|
||||
# This workaround temporarily downgrades the project format to 56, runs
|
||||
# pod install, then restores it to 70. Xcode will automatically upgrade
|
||||
# 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.
|
||||
#
|
||||
# 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
|
||||
# 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
|
||||
# 5. Update this comment to indicate the workaround has been removed
|
||||
# ===================================================================
|
||||
run_pod_install_with_workaround() {
|
||||
local PROJECT_FILE="ios/App/App.xcodeproj/project.pbxproj"
|
||||
|
||||
log_info "Installing CocoaPods dependencies (with Xcode 26 workaround)..."
|
||||
|
||||
# Check if project file exists
|
||||
if [ ! -f "$PROJECT_FILE" ]; then
|
||||
log_error "Project file not found: $PROJECT_FILE"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# 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"
|
||||
return 1
|
||||
fi
|
||||
|
||||
log_debug "Current project format version: $current_version"
|
||||
|
||||
# Only apply workaround if format is 70
|
||||
if [ "$current_version" = "70" ]; then
|
||||
log_debug "Applying Xcode 26 workaround: 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"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Run pod install
|
||||
log_info "Running pod install..."
|
||||
if ! (cd ios/App && bundle exec pod install && cd ../..); then
|
||||
log_error "pod install 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..."
|
||||
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 "CocoaPods dependencies installed successfully"
|
||||
else
|
||||
# Format is not 70, run pod install normally
|
||||
log_debug "Project format is $current_version, running pod install normally"
|
||||
if ! (cd ios/App && bundle exec pod install && cd ../..); then
|
||||
log_error "pod install failed"
|
||||
return 1
|
||||
fi
|
||||
log_success "CocoaPods dependencies installed successfully"
|
||||
fi
|
||||
}
|
||||
|
||||
safe_execute "Installing CocoaPods dependencies" "run_pod_install_with_workaround" || exit 6
|
||||
|
||||
# Step 6.5: 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
|
||||
}
|
||||
|
||||
safe_execute "Syncing with Capacitor" "run_cap_sync_with_workaround" || exit 6
|
||||
|
||||
# Step 7: Generate assets
|
||||
safe_execute "Generating assets" "npx capacitor-assets generate --ios" || exit 7
|
||||
|
||||
Reference in New Issue
Block a user