From 3676c715c7f3aa809aa969657305ac915e5f4cbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20G=C3=BCner?= Date: Tue, 11 Jun 2024 14:21:17 +0300 Subject: [PATCH] fix: disable jetifier for generated native examples (#563) --- .../src/utils/generateExampleApp.ts | 46 ++++++++++++------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/packages/create-react-native-library/src/utils/generateExampleApp.ts b/packages/create-react-native-library/src/utils/generateExampleApp.ts index 0021a6e2f..7f44ad5d0 100644 --- a/packages/create-react-native-library/src/utils/generateExampleApp.ts +++ b/packages/create-react-native-library/src/utils/generateExampleApp.ts @@ -172,30 +172,44 @@ export default async function generateExampleApp({ spaces: 2, }); - // If the library is on new architecture, enable new arch for iOS and Android - if (arch === 'new') { - // Android - // Change newArchEnabled=false to newArchEnabled=true in example/android/gradle.properties - const gradleProperties = await fs.readFile( + if (type === 'native') { + let gradleProperties = await fs.readFile( path.join(directory, 'android', 'gradle.properties'), 'utf8' ); - await fs.writeFile( - path.join(directory, 'android', 'gradle.properties'), - gradleProperties.replace('newArchEnabled=false', 'newArchEnabled=true') + // Disable Jetifier. + // Remove this when the app template is updated. + gradleProperties = gradleProperties.replace( + 'android.enableJetifier=true', + 'android.enableJetifier=false' ); - // iOS - // Add ENV['RCT_NEW_ARCH_ENABLED'] = 1 on top of example/ios/Podfile - const podfile = await fs.readFile( - path.join(directory, 'ios', 'Podfile'), - 'utf8' - ); + // If the library is on new architecture, enable new arch for iOS and Android + if (arch === 'new') { + // iOS + // Add ENV['RCT_NEW_ARCH_ENABLED'] = 1 on top of example/ios/Podfile + const podfile = await fs.readFile( + path.join(directory, 'ios', 'Podfile'), + 'utf8' + ); + + await fs.writeFile( + path.join(directory, 'ios', 'Podfile'), + "ENV['RCT_NEW_ARCH_ENABLED'] = '1'\n\n" + podfile + ); + + // Android + // Change newArchEnabled=false to newArchEnabled=true in example/android/gradle.properties + gradleProperties = gradleProperties.replace( + 'newArchEnabled=false', + 'newArchEnabled=true' + ); + } await fs.writeFile( - path.join(directory, 'ios', 'Podfile'), - "ENV['RCT_NEW_ARCH_ENABLED'] = '1'\n\n" + podfile + path.join(directory, 'android', 'gradle.properties'), + gradleProperties ); } }