diff --git a/detox/src/devices/ios/AppleSimUtils.js b/detox/src/devices/ios/AppleSimUtils.js index 810c6f91f6..40224191f2 100644 --- a/detox/src/devices/ios/AppleSimUtils.js +++ b/detox/src/devices/ios/AppleSimUtils.js @@ -257,10 +257,15 @@ class AppleSimUtils { ` tail -F ${logsInfo.absJoined}` }; + let dylibs = `${frameworkPath}/Detox`; + if (process.env.SIMCTL_CHILD_DYLD_INSERT_LIBRARIES) { + dylibs = `${process.env.SIMCTL_CHILD_DYLD_INSERT_LIBRARIES}:${dylibs}`; + } + let launchBin = `/bin/cat /dev/null >${logsInfo.absStdout} 2>${logsInfo.absStderr} && ` + - `SIMCTL_CHILD_DYLD_INSERT_LIBRARIES="${frameworkPath}/Detox" ` + + `SIMCTL_CHILD_DYLD_INSERT_LIBRARIES="${dylibs}" ` + `/usr/bin/xcrun simctl launch --stdout=${logsInfo.simStdout} --stderr=${logsInfo.simStderr} ` + - `${udid} ${bundleId} --args ${args}`;; + `${udid} ${bundleId} --args ${args}`; if (!!languageAndLocale && !!languageAndLocale.language) { launchBin += ` -AppleLanguages "(${languageAndLocale.language})"`; diff --git a/detox/src/devices/ios/AppleSimUtils.test.js b/detox/src/devices/ios/AppleSimUtils.test.js index 6f436125a3..5329aea7e5 100644 --- a/detox/src/devices/ios/AppleSimUtils.test.js +++ b/detox/src/devices/ios/AppleSimUtils.test.js @@ -348,6 +348,26 @@ describe('AppleSimUtils', () => { } }); + it('should append framework path to existing dyld path if present', async () => { + const origEnvVar = process.env.SIMCTL_CHILD_DYLD_INSERT_LIBRARIES; + process.env.SIMCTL_CHILD_DYLD_INSERT_LIBRARIES = '/tmp'; + environment.getFrameworkPath.mockReturnValueOnce(Promise.resolve('thePathToFrameworks')); + try { + await uut.launch('udid', 'theBundleId'); + expect(exec.execWithRetriesAndLogs.mock.calls).toMatchSnapshot(); + } catch (e) { + fail(`should throw`); + } finally { + if (origEnvVar){ + // set the env var back to what it used to be + process.env.SIMCTL_CHILD_DYLD_INSERT_LIBRARIES = origEnvVar; + } else { + // env var was never set to begin with, delete it + delete process.env.SIMCTL_CHILD_DYLD_INSERT_LIBRARIES; + } + } + }); + it('returns the parsed id', async () => { exec.execWithRetriesAndLogs.mockReturnValueOnce(Promise.resolve({ stdout: 'appId: 12345 \n' })); const result = await uut.launch('udid', 'theBundleId'); diff --git a/detox/src/devices/ios/__snapshots__/AppleSimUtils.test.js.snap b/detox/src/devices/ios/__snapshots__/AppleSimUtils.test.js.snap index 3291f4da7e..409b562360 100644 --- a/detox/src/devices/ios/__snapshots__/AppleSimUtils.test.js.snap +++ b/detox/src/devices/ios/__snapshots__/AppleSimUtils.test.js.snap @@ -192,6 +192,21 @@ Array [ ] `; +exports[`AppleSimUtils launch should append framework path to existing dyld path if present 1`] = ` +Array [ + Array [ + "/bin/cat /dev/null >/Users/detox/Library/Developer/CoreSimulator/Devices/udid/data/tmp/detox.last_launch_app_log.out 2>/Users/detox/Library/Developer/CoreSimulator/Devices/udid/data/tmp/detox.last_launch_app_log.err && SIMCTL_CHILD_DYLD_INSERT_LIBRARIES=\\"/tmp:thePathToFrameworks/Detox\\" /usr/bin/xcrun simctl launch --stdout=/tmp/detox.last_launch_app_log.out --stderr=/tmp/detox.last_launch_app_log.err udid theBundleId --args ", + undefined, + Object { + "successful": "theBundleId launched. The stdout and stderr logs were recreated, you can watch them with: + tail -F /Users/detox/Library/Developer/CoreSimulator/Devices/udid/data/tmp/detox.last_launch_app_log.{out,err}", + "trying": "Launching theBundleId...", + }, + 1, + ], +] +`; + exports[`AppleSimUtils openUrl calls xcrun simctl 1`] = ` Array [ Array [