Skip to content

Commit

Permalink
chore(suite-native): enable development client builds on Testflight
Browse files Browse the repository at this point in the history
  • Loading branch information
matejkriz committed Feb 25, 2025
1 parent 49293f9 commit f1ebf48
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions suite-native/app/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ const getPlugins = (): ExpoPlugins => {
organization: 'satoshilabs',
},
],
['./plugins/withTestflightDevDeploy.js', { enabled: buildType === 'preview' }],
];

return [
Expand Down
48 changes: 48 additions & 0 deletions suite-native/app/plugins/withTestflightDevDeploy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* This file is based on the work of Max Bäumle (@343max)
* from the repository: https://github.com/343max/testflight-dev-deploy
*
* Many thanks to Max for sharing this code with the community!
*/
const { withDangerousMod } = require('expo/config-plugins');
const fs = require('fs').promises;
const path = require('path');

const podfilePatch = [
'',
'key_command_path = File.join(__dir__, "../node_modules/react-native/React/Base/RCTKeyCommands.m")',
'file_content = File.read(key_command_path)',
'file_content.sub!(/#if RCT_DEV/, "#if 0")',
'File.write(key_command_path, file_content)',
'puts "Patched RCTKeyCommands.m to disable key commands in dev mode"',
'',
]
.map(s => ` ${s}`)
.join('\n');

// Allow development client on Testflight
const withTestflightDevDeploy = (config, { enabled = false }) => {
withDangerousMod(config, [
'ios',
async config2 => {
if (!enabled) {
return config2;
}

const podfilePath = path.join(config2.modRequest.platformProjectRoot, 'Podfile');

const code = await fs.readFile(podfilePath, { encoding: 'utf-8' });
const patchedCode = code.replace(
/^\s*post_install do \|installer\|/m,
match => `${match}\n${podfilePatch}`,
);
await fs.writeFile(podfilePath, patchedCode);

return config2;
},
]);

return config;
};

module.exports = withTestflightDevDeploy;

0 comments on commit f1ebf48

Please sign in to comment.