bagsy/apps/mobile/scripts/patch-expo-podspec.mjs
bananabas 215a70b377 feat: downgrade to Expo 54 + React Native 0.75 for stability
- Downgraded from Expo 55 + RN 0.76 to Expo 54 + RN 0.75 (better compatibility)
- Eliminated JSI string conversion API mismatch errors
- Fixed postinstall patch script path resolution
- All 82 CocoaPods dependencies now resolve correctly
- Podfile.lock generated successfully
- Ready for local iOS builds on Xcode

Next: Open Bagsy.xcworkspace in Xcode and build for iPhone 16
2026-03-27 17:44:18 +00:00

75 lines
2.4 KiB
JavaScript

#!/usr/bin/env node
/**
* Patch script for Expo.podspec
*
* This script applies necessary patches to the Expo podspec to support
* React Native 0.76 with the old architecture (RCT_NEW_ARCH_ENABLED = 0).
*
* Without these patches, pod install fails because:
* 1. get_folly_config() is not available when RCT_NEW_ARCH_ENABLED=0
* 2. ReactAppDependencyProvider is only available in the new architecture
*/
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const projectRoot = path.join(__dirname, '..');
const podspecPath = path.join(projectRoot, '..', '..', 'node_modules/expo/Expo.podspec');
if (!fs.existsSync(podspecPath)) {
console.log('[patch-expo-podspec] Expo podspec not found, skipping patch');
process.exit(0);
}
const content = fs.readFileSync(podspecPath, 'utf-8');
// Patch 1: Wrap get_folly_config() in a condition
const patch1From = `reactNativeTargetVersion = reactNativeVersion.split('.')[1].to_i
compiler_flags = get_folly_config()[:compiler_flags]`;
const patch1To = `reactNativeTargetVersion = reactNativeVersion.split('.')[1].to_i
# get_folly_config is only available in new architecture mode
compiler_flags = ''
begin
if ENV['RCT_NEW_ARCH_ENABLED'] == '1'
compiler_flags = get_folly_config()[:compiler_flags]
end
rescue
compiler_flags = ''
end`;
// Patch 2: Conditionally require ReactAppDependencyProvider
const patch2From = ` s.dependency 'React-RCTAppDelegate'
s.dependency 'React-RCTFabric'
s.dependency 'ReactAppDependencyProvider'`;
const patch2To = ` s.dependency 'React-RCTAppDelegate'
s.dependency 'React-RCTFabric'
# ReactAppDependencyProvider is only available in the new architecture
if ENV['RCT_NEW_ARCH_ENABLED'] == '1'
s.dependency 'ReactAppDependencyProvider'
end`;
let modified = content;
if (!content.includes(patch1To)) {
modified = modified.replace(patch1From, patch1To);
console.log('[patch-expo-podspec] Applied patch 1: conditional get_folly_config()');
}
if (!content.includes(patch2To)) {
modified = modified.replace(patch2From, patch2To);
console.log('[patch-expo-podspec] Applied patch 2: conditional ReactAppDependencyProvider');
}
if (modified !== content) {
fs.writeFileSync(podspecPath, modified, 'utf-8');
console.log('[patch-expo-podspec] Successfully patched Expo.podspec');
} else {
console.log('[patch-expo-podspec] Expo.podspec already patched, skipping');
}