17c10e2d9SEvan Baconconst { withDangerousMod, IOSConfig } = require('@expo/config-plugins'); 27c10e2d9SEvan Baconconst fs = require('fs-extra'); 37c10e2d9SEvan Bacon 47c10e2d9SEvan Bacon// Append this block to the AppDelegate to fix https://stackoverflow.com/a/56160671/4047926 57c10e2d9SEvan Baconconst customBlockObjc = `// [Custom]: Fixes \`Unable to find module for DevMenu\` 67c10e2d9SEvan Bacon#if RCT_DEV 77c10e2d9SEvan Bacon- (BOOL)bridge:(RCTBridge *)bridge didNotFindModule:(NSString *)moduleName { 87c10e2d9SEvan Bacon return YES; 97c10e2d9SEvan Bacon} 107c10e2d9SEvan Bacon#endif 117c10e2d9SEvan Bacon 127c10e2d9SEvan Bacon`; 137c10e2d9SEvan Bacon 14*35f78160SBartosz Kaszubowskimodule.exports = (config) => { 157c10e2d9SEvan Bacon return withDangerousMod(config, [ 167c10e2d9SEvan Bacon 'ios', 17*35f78160SBartosz Kaszubowski async (config) => { 187c10e2d9SEvan Bacon const fileInfo = IOSConfig.Paths.getAppDelegate(config.modRequest.projectRoot); 197c10e2d9SEvan Bacon let contents = await fs.readFile(fileInfo.path, 'utf-8'); 207c10e2d9SEvan Bacon if (fileInfo.language === 'objc') { 217c10e2d9SEvan Bacon if (!contents.match(/didNotFindModule:\(NSString\s?\*\)moduleName/)) { 227c10e2d9SEvan Bacon const sections = contents.split('@end'); 237c10e2d9SEvan Bacon sections[sections.length - 2] += customBlockObjc; 247c10e2d9SEvan Bacon contents = sections.join('@end'); 257c10e2d9SEvan Bacon } 267c10e2d9SEvan Bacon } else { 277c10e2d9SEvan Bacon throw new Error( 287c10e2d9SEvan Bacon `Cannot append didNotFindModule method to AppDelegate of language "${fileInfo.language}"` 297c10e2d9SEvan Bacon ); 307c10e2d9SEvan Bacon } 317c10e2d9SEvan Bacon await fs.writeFile(fileInfo.path, contents); 327c10e2d9SEvan Bacon 337c10e2d9SEvan Bacon return config; 347c10e2d9SEvan Bacon }, 357c10e2d9SEvan Bacon ]); 367c10e2d9SEvan Bacon}; 37