Skip to content

Commit 3676c71

Browse files
authored
fix: disable jetifier for generated native examples (#563)
1 parent 4646e08 commit 3676c71

File tree

1 file changed

+30
-16
lines changed

1 file changed

+30
-16
lines changed

packages/create-react-native-library/src/utils/generateExampleApp.ts

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -172,30 +172,44 @@ export default async function generateExampleApp({
172172
spaces: 2,
173173
});
174174

175-
// If the library is on new architecture, enable new arch for iOS and Android
176-
if (arch === 'new') {
177-
// Android
178-
// Change newArchEnabled=false to newArchEnabled=true in example/android/gradle.properties
179-
const gradleProperties = await fs.readFile(
175+
if (type === 'native') {
176+
let gradleProperties = await fs.readFile(
180177
path.join(directory, 'android', 'gradle.properties'),
181178
'utf8'
182179
);
183180

184-
await fs.writeFile(
185-
path.join(directory, 'android', 'gradle.properties'),
186-
gradleProperties.replace('newArchEnabled=false', 'newArchEnabled=true')
181+
// Disable Jetifier.
182+
// Remove this when the app template is updated.
183+
gradleProperties = gradleProperties.replace(
184+
'android.enableJetifier=true',
185+
'android.enableJetifier=false'
187186
);
188187

189-
// iOS
190-
// Add ENV['RCT_NEW_ARCH_ENABLED'] = 1 on top of example/ios/Podfile
191-
const podfile = await fs.readFile(
192-
path.join(directory, 'ios', 'Podfile'),
193-
'utf8'
194-
);
188+
// If the library is on new architecture, enable new arch for iOS and Android
189+
if (arch === 'new') {
190+
// iOS
191+
// Add ENV['RCT_NEW_ARCH_ENABLED'] = 1 on top of example/ios/Podfile
192+
const podfile = await fs.readFile(
193+
path.join(directory, 'ios', 'Podfile'),
194+
'utf8'
195+
);
196+
197+
await fs.writeFile(
198+
path.join(directory, 'ios', 'Podfile'),
199+
"ENV['RCT_NEW_ARCH_ENABLED'] = '1'\n\n" + podfile
200+
);
201+
202+
// Android
203+
// Change newArchEnabled=false to newArchEnabled=true in example/android/gradle.properties
204+
gradleProperties = gradleProperties.replace(
205+
'newArchEnabled=false',
206+
'newArchEnabled=true'
207+
);
208+
}
195209

196210
await fs.writeFile(
197-
path.join(directory, 'ios', 'Podfile'),
198-
"ENV['RCT_NEW_ARCH_ENABLED'] = '1'\n\n" + podfile
211+
path.join(directory, 'android', 'gradle.properties'),
212+
gradleProperties
199213
);
200214
}
201215
}

0 commit comments

Comments
 (0)