Skip to content

Commit 44836fe

Browse files
committed
feat: don't add a XCode prebuild action to invoke codegen anymore
1 parent 194296b commit 44836fe

File tree

2 files changed

+2
-45
lines changed

2 files changed

+2
-45
lines changed

packages/create-react-native-library/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ async function create(_argv: yargs.Arguments<any>) {
810810
exampleCommunityCLIVersion;
811811

812812
if (arch !== 'legacy') {
813-
addCodegenBuildScript(folder, options.project.name);
813+
addCodegenBuildScript(folder);
814814
}
815815
}
816816
}

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

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,6 @@ if (isNewArchitectureEnabled()) {
1616
preBuild.dependsOn invokeLibraryCodegen
1717
}`;
1818

19-
// This is added to the example app's xcscheme file to invoke codegen before every build
20-
const XCODE_INVOKE_CODEGEN_ACTION = `
21-
<PreActions>
22-
<ExecutionAction
23-
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
24-
<ActionContent
25-
title = "Invoke Codegen"
26-
scriptText = "cd &quot;$WORKSPACE_PATH/../../../&quot; &amp;&amp; npx bob build --target codegen&#10;">
27-
</ActionContent>
28-
</ExecutionAction>
29-
</PreActions>`;
30-
3119
// You need to have the files before calling pod install otherwise they won't be registered in your pod.
3220
// So we add a pre_install hook to the podfile that invokes codegen
3321
const PODSPEC_INVOKE_CODEGEN_SCRIPT = `
@@ -40,26 +28,14 @@ const PODSPEC_INVOKE_CODEGEN_SCRIPT = `
4028
* Codegen isn't invoked for libraries with `includesGeneratedCode` set to `true`.
4129
* This patches the example app to invoke library codegen on every app build.
4230
*/
43-
export async function addCodegenBuildScript(
44-
libraryPath: string,
45-
projectName: string
46-
) {
31+
export async function addCodegenBuildScript(libraryPath: string) {
4732
const appBuildGradlePath = path.join(
4833
libraryPath,
4934
'example',
5035
'android',
5136
'app',
5237
'build.gradle'
5338
);
54-
const exampleAppBuildSchemePath = path.join(
55-
libraryPath,
56-
'example',
57-
'ios',
58-
`${projectName}Example.xcodeproj`,
59-
'xcshareddata',
60-
'xcschemes',
61-
`${projectName}Example.xcscheme`
62-
);
6339
const podfilePath = path.join(libraryPath, 'example', 'ios', 'Podfile');
6440

6541
// Add a gradle task that runs before every build
@@ -68,25 +44,6 @@ export async function addCodegenBuildScript(
6844

6945
await fs.writeFile(appBuildGradlePath, appBuildGradle);
7046

71-
// Add an XCode prebuild action.
72-
const exampleAppBuildScheme = (await fs.readFile(exampleAppBuildSchemePath))
73-
.toString()
74-
.split('\n');
75-
// Used XCode and inspected the result to determine where it inserts the actions
76-
const actionTargetLineIndex = exampleAppBuildScheme.findIndex((line) =>
77-
line.includes('<BuildActionEntries>')
78-
);
79-
exampleAppBuildScheme.splice(
80-
actionTargetLineIndex,
81-
0,
82-
XCODE_INVOKE_CODEGEN_ACTION
83-
);
84-
85-
await fs.writeFile(
86-
exampleAppBuildSchemePath,
87-
exampleAppBuildScheme.join('\n')
88-
);
89-
9047
// Add a preinstall action to the podfile that invokes codegen
9148
const podfile = (await fs.readFile(podfilePath)).toString().split('\n');
9249
const podfilePostInstallIndex = podfile.findIndex((line) =>

0 commit comments

Comments
 (0)