bagsy/apps/mobile/scripts/patch-expo-podspec.mjs
bananabas 66f538049b fix: resolve React Native 0.76 + Expo 55 compatibility for old architecture
- Patch Expo.podspec to conditionally call get_folly_config() only in new arch
- Conditionally require ReactAppDependencyProvider (new arch only)
- Downgrade React Native 0.76.0 (instead of 0.73 which had get_folly_config errors)
- Successfully completed pod install, generated Podfile.lock
- Add postinstall script to apply patches automatically on bun install
- iOS build artifacts ready in Bagsy.xcworkspace
2026-03-27 17:24:57 +00:00

74 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 podspecPath = path.join(__dirname, '../../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');
}