Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Commit

Permalink
[install-expo-modules] fix react-native 0.72.5 support (#4766)
Browse files Browse the repository at this point in the history
# Why

react-native 0.72.5 has a breaking change for default ios minimal version: facebook/react-native@a5e110adcf21

# How

support parsing the default ios minimal version from the **scripts/cocoapods/helpers.rb**

# Test Plan

tested install-expo-modules on a react-native 0.72.5 project
  • Loading branch information
Kudo authored Oct 3, 2023
1 parent e1f5432 commit 61ca5ca
Showing 1 changed file with 27 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,38 @@ export async function shouldUpdateDeployTargetPodfileAsync(
export async function lookupReactNativeMinIosVersionSupported(
projectRoot: string
): Promise<string | null> {
// [0] Try to parse the default version from **scripts/cocoapods/helpers.rb**
const reactNativeCocoaPodsHelper = resolveFrom.silent(
projectRoot,
'react-native/scripts/cocoapods/helpers.rb'
);
if (reactNativeCocoaPodsHelper) {
try {
const content = await fs.promises.readFile(reactNativeCocoaPodsHelper, 'utf-8');
const matchRepExp = /^\s*def self\.min_ios_version_supported\n\s*return\s*['"]([\d.]+)['"]/gm;
const matchResult = matchRepExp.exec(content);
if (matchResult) {
return matchResult[1];
}
} catch {}
}

// [1] Try to parse the default version from **scripts/react_native_pods.rb**
const reactNativePodsScript = resolveFrom.silent(
projectRoot,
'react-native/scripts/react_native_pods.rb'
);
if (!reactNativePodsScript) {
return null;
if (reactNativePodsScript) {
try {
const content = await fs.promises.readFile(reactNativePodsScript, 'utf-8');
const matchRepExp = /^def min_ios_version_supported\n\s*return\s*['"]([\d.]+)['"]/gm;
const matchResult = matchRepExp.exec(content);
if (matchResult) {
return matchResult[1];
}
} catch {}
}
try {
const content = await fs.promises.readFile(reactNativePodsScript, 'utf-8');
const matchRepExp = /^def min_ios_version_supported\n\s*return\s*['"]([\d.]+)['"]/gm;
const matchResult = matchRepExp.exec(content);
if (matchResult) {
return matchResult[1];
}
} catch {}

return null;
}

Expand Down

0 comments on commit 61ca5ca

Please sign in to comment.