From d22d362c312f3c0de686135c5e218b9c8a96ed1a Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Mon, 27 Nov 2023 04:55:05 -0800 Subject: [PATCH] Codesign capabilities Summary: Add codesign capabilities to Flipper Server Cocoa app. Also, push the version to the build step instead of overriding once built. Otherwise, the Info.plist will be marked as 'being tampered with'. Note: we are still not using the signing, but the capability is there. Reviewed By: antonk52 Differential Revision: D51547008 fbshipit-source-id: 33abcd2fce33a7daf2ae8941b54989dba82fc0e3 --- .../scripts/build-flipper-server-release.tsx | 76 ++++++++++--------- 1 file changed, 40 insertions(+), 36 deletions(-) diff --git a/desktop/scripts/build-flipper-server-release.tsx b/desktop/scripts/build-flipper-server-release.tsx index a6d2f07b7..4f6744432 100644 --- a/desktop/scripts/build-flipper-server-release.tsx +++ b/desktop/scripts/build-flipper-server-release.tsx @@ -754,7 +754,11 @@ async function setUpMacBundle( platform === BuildPlatform.MAC_AARCH64 ? BuildArchitecture.MAC_AARCH64 : BuildArchitecture.MAC_X64; - const outputPath = await buildFlipperServer(architecture); + const outputPath = await buildFlipperServer( + architecture, + versionNumber, + false, + ); console.log( `⚙️ Successfully built platform: ${platform}, output: ${outputPath}`, ); @@ -766,47 +770,47 @@ async function setUpMacBundle( } else { const template = path.join(staticDir, 'flipper-server-app-template'); await fs.copy(template, outputDir); - } - function replacePropertyValue( - obj: any, - targetValue: string, - replacementValue: string, - ): any { - if (typeof obj === 'object' && !Array.isArray(obj) && obj !== null) { - for (const key in obj) { - if (obj.hasOwnProperty(key)) { - obj[key] = replacePropertyValue( - obj[key], - targetValue, - replacementValue, - ); + function replacePropertyValue( + obj: any, + targetValue: string, + replacementValue: string, + ): any { + if (typeof obj === 'object' && !Array.isArray(obj) && obj !== null) { + for (const key in obj) { + if (obj.hasOwnProperty(key)) { + obj[key] = replacePropertyValue( + obj[key], + targetValue, + replacementValue, + ); + } } + } else if (typeof obj === 'string' && obj === targetValue) { + obj = replacementValue; } - } else if (typeof obj === 'string' && obj === targetValue) { - obj = replacementValue; + return obj; } - return obj; + + console.log(`⚙️ Writing plist`); + const plistPath = path.join( + outputDir, + 'Flipper.app', + 'Contents', + 'Info.plist', + ); + + /* eslint-disable node/no-sync*/ + const pListContents: Record = plist.readFileSync(plistPath); + replacePropertyValue( + pListContents, + '{flipper-server-version}', + versionNumber, + ); + plist.writeBinaryFileSync(plistPath, pListContents); + /* eslint-enable node/no-sync*/ } - console.log(`⚙️ Writing plist`); - const plistPath = path.join( - outputDir, - 'Flipper.app', - 'Contents', - 'Info.plist', - ); - - /* eslint-disable node/no-sync*/ - const pListContents: Record = plist.readFileSync(plistPath); - replacePropertyValue( - pListContents, - '{flipper-server-version}', - versionNumber, - ); - plist.writeBinaryFileSync(plistPath, pListContents); - /* eslint-enable node/no-sync*/ - const resourcesOutputDir = path.join( outputDir, 'Flipper.app',