From 3f117d752832199f53f321ed3c7edadeb564c0cd Mon Sep 17 00:00:00 2001 From: Benoit Lemaire Date: Fri, 10 Apr 2020 15:10:33 -0700 Subject: [PATCH] Update iOS runner for RN61+ support --- ern-orchestrator/src/buildIosRunner.ts | 9 +++++++++ ern-runner-gen-ios/src/IosRunnerGenerator.ts | 18 ++++++++++++++---- .../contents.xcworkspacedata | 13 +++++++++++++ 3 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 ern-runner-gen-ios/src/hull/ErnRunner.xcworkspace/contents.xcworkspacedata diff --git a/ern-orchestrator/src/buildIosRunner.ts b/ern-orchestrator/src/buildIosRunner.ts index 7238d64ad..58bd9acd8 100644 --- a/ern-orchestrator/src/buildIosRunner.ts +++ b/ern-orchestrator/src/buildIosRunner.ts @@ -1,11 +1,20 @@ import { log } from 'ern-core' import { spawn } from 'child_process' +import fs from 'fs-extra' +import path from 'path' export async function buildIosRunner(pathToIosRunner: string, udid: string) { return new Promise((resolve, reject) => { + const extraBuildOptions = fs.existsSync( + path.join(pathToIosRunner, 'ErnRunner.xcworkspace') + ) + ? [`-workspace`, `ErnRunner.xcworkspace`] + : [] + const xcodebuildProc = spawn( 'xcodebuild', [ + ...extraBuildOptions, `-scheme`, 'ErnRunner', 'build', diff --git a/ern-runner-gen-ios/src/IosRunnerGenerator.ts b/ern-runner-gen-ios/src/IosRunnerGenerator.ts index fe26abf65..aeffb08f5 100644 --- a/ern-runner-gen-ios/src/IosRunnerGenerator.ts +++ b/ern-runner-gen-ios/src/IosRunnerGenerator.ts @@ -21,16 +21,26 @@ export default class IosRunerGenerator implements RunnerGenerator { const mustacheView = this.createMustacheView({ config }) shell.cp('-R', path.join(runnerHullPath, '*'), config.outDir) + const filesToMustache = [ - path.join(config.outDir, 'ErnRunner/RunnerConfig.m'), - path.join(config.outDir, 'ErnRunner.xcodeproj/project.pbxproj'), + 'ErnRunner/RunnerConfig.m', + 'ErnRunner.xcodeproj/project.pbxproj', ] + if ((mustacheView as any).RN_VERSION_LT_61) { + // Delete ErnRunner.xcworkspace directory as it is only needed for RN61+ + shell.rm('-rf', path.join(config.outDir, 'ErnRunner.xcworkspace')) + } else { + // Otherwise keep it and include the xcworkspaceedata file for mustached + // processing as it contains some mustache templace placeholders + filesToMustache.push('ErnRunner.xcworkspace/contents.xcworkspacedata') + } + for (const file of filesToMustache) { await mustacheUtils.mustacheRenderToOutputFileUsingTemplateFile( - file, + path.join(config.outDir, file), mustacheView, - file + path.join(config.outDir, file) ) } } diff --git a/ern-runner-gen-ios/src/hull/ErnRunner.xcworkspace/contents.xcworkspacedata b/ern-runner-gen-ios/src/hull/ErnRunner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000..19f1a5de3 --- /dev/null +++ b/ern-runner-gen-ios/src/hull/ErnRunner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,13 @@ + + + + + + + + +