Skip to content

Commit fc4c4c1

Browse files
patch game assembly to set outputs
1 parent 3b26af2 commit fc4c4c1

File tree

5 files changed

+63
-11
lines changed

5 files changed

+63
-11
lines changed

dist/index.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58502,6 +58502,7 @@ async function GetProjectDetails(credential, xcodeVersion) {
5850258502
}
5850358503
core.debug(`Resolved Project path: ${projectPath}`);
5850458504
await fs.promises.access(projectPath, fs.constants.R_OK);
58505+
await patchGameAssemblyRunScriptOutput(projectPath);
5850558506
const projectDirectory = path.dirname(projectPath);
5850658507
core.info(`Project directory: ${projectDirectory}`);
5850758508
const projectName = path.basename(projectPath, '.xcodeproj');
@@ -58661,6 +58662,21 @@ async function GetProjectDetails(credential, xcodeVersion) {
5866158662
core.info(`------- Info.plist content: -------\n${infoPlistContent}\n-----------------------------------`);
5866258663
return projectRef;
5866358664
}
58665+
async function patchGameAssemblyRunScriptOutput(projectPath) {
58666+
const pbxprojPath = `${projectPath}/project.pbxproj`;
58667+
let pbxprojContent = await fs.promises.readFile(pbxprojPath, 'utf8');
58668+
pbxprojContent = pbxprojContent.replace(/\/\* Run Script \*\/ = \{\n([\s\S]*?)isa = PBXShellScriptBuildPhase;([\s\S]*?)name = "Run Script";([\s\S]*?)outputPaths = \(([\s\S]*?)\);/g, (match) => {
58669+
return match.replace(/outputPaths = \(([\s\S]*?)\);/, 'outputPaths = (\n "${DERIVED_FILE_DIR}/il2cpp_outputs",\n );');
58670+
});
58671+
pbxprojContent = pbxprojContent.replace(/\/\* Run Script \*\/ = \{\n([\s\S]*?)isa = PBXShellScriptBuildPhase;([\s\S]*?)name = "Run Script";([\s\S]*?)(?=shellScript = )/g, (match) => {
58672+
if (!/outputPaths = \(/.test(match)) {
58673+
return match + ' outputPaths = (\n "${DERIVED_FILE_DIR}/il2cpp_outputs",\n );\n';
58674+
}
58675+
return match;
58676+
});
58677+
await fs.promises.writeFile(pbxprojPath, pbxprojContent, 'utf8');
58678+
core.info('Patched GameAssembly Run Script output path to ${DERIVED_FILE_DIR}/il2cpp_outputs');
58679+
}
5866458680
async function checkSimulatorsAvailable(platform) {
5866558681
const destinationArgs = ['simctl', 'list', 'devices', '--json'];
5866658682
let output = '';

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@
2525
"uuid": "^10.0.0"
2626
},
2727
"devDependencies": {
28-
"@types/node": "^22.16.5",
28+
"@types/node": "^22.17.0",
2929
"@types/plist": "^3.0.5",
3030
"@types/semver": "^7.7.0",
3131
"@types/uuid": "^10.0.0",
3232
"@vercel/ncc": "^0.34.0",
3333
"shx": "^0.3.4",
34-
"typescript": "^5.8.3"
34+
"typescript": "^5.9.2"
3535
},
3636
"scripts": {
3737
"build": "npm run clean && npm run bundle",

src/xcode.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export async function GetProjectDetails(credential: AppleCredential, xcodeVersio
5454
}
5555
core.debug(`Resolved Project path: ${projectPath}`);
5656
await fs.promises.access(projectPath, fs.constants.R_OK);
57+
await patchGameAssemblyRunScriptOutput(projectPath);
5758
const projectDirectory = path.dirname(projectPath);
5859
core.info(`Project directory: ${projectDirectory}`);
5960
const projectName = path.basename(projectPath, '.xcodeproj');
@@ -216,6 +217,41 @@ export async function GetProjectDetails(credential: AppleCredential, xcodeVersio
216217
return projectRef;
217218
}
218219

220+
/**
221+
* Patch the Run Script build phase for GameAssembly to add output paths.
222+
*/
223+
async function patchGameAssemblyRunScriptOutput(projectPath: string): Promise<void> {
224+
const pbxprojPath = `${projectPath}/project.pbxproj`;
225+
let pbxprojContent = await fs.promises.readFile(pbxprojPath, 'utf8');
226+
227+
// Regex to find the Run Script phase for GameAssembly
228+
// This is a simple regex and may need adjustment for edge cases
229+
pbxprojContent = pbxprojContent.replace(
230+
/\/\* Run Script \*\/ = \{\n([\s\S]*?)isa = PBXShellScriptBuildPhase;([\s\S]*?)name = "Run Script";([\s\S]*?)outputPaths = \(([\s\S]*?)\);/g,
231+
(match) => {
232+
// Already has outputPaths, replace with our value
233+
return match.replace(
234+
/outputPaths = \(([\s\S]*?)\);/,
235+
'outputPaths = (\n "${DERIVED_FILE_DIR}/il2cpp_outputs",\n );'
236+
);
237+
}
238+
);
239+
240+
// If outputPaths is missing, add it
241+
pbxprojContent = pbxprojContent.replace(
242+
/\/\* Run Script \*\/ = \{\n([\s\S]*?)isa = PBXShellScriptBuildPhase;([\s\S]*?)name = "Run Script";([\s\S]*?)(?=shellScript = )/g,
243+
(match) => {
244+
if (!/outputPaths = \(/.test(match)) {
245+
return match + ' outputPaths = (\n "${DERIVED_FILE_DIR}/il2cpp_outputs",\n );\n';
246+
}
247+
return match;
248+
}
249+
);
250+
251+
await fs.promises.writeFile(pbxprojPath, pbxprojContent, 'utf8');
252+
core.info('Patched GameAssembly Run Script output path to ${DERIVED_FILE_DIR}/il2cpp_outputs');
253+
}
254+
219255
async function checkSimulatorsAvailable(platform: string): Promise<void> {
220256
const destinationArgs = ['simctl', 'list', 'devices', '--json'];
221257
let output = '';

0 commit comments

Comments
 (0)