Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 6ffa5ff

Browse files
[Tests] Fix generating of IOS test project (#1778)
1 parent fe90097 commit 6ffa5ff

File tree

2 files changed

+10
-41
lines changed

2 files changed

+10
-41
lines changed

code-push-plugin-testing-framework/script/platform.js

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use strict";
22
var Q = require("q");
33
var testUtil_1 = require("./testUtil");
4+
var TestConfig = require("./testConfig");
45
//////////////////////////////////////////////////////////////////////////////////////////
56
// PLATFORMS
67
/**
@@ -344,25 +345,7 @@ var IOSEmulatorManager = (function () {
344345
* Ends a running application given its app id.
345346
*/
346347
IOSEmulatorManager.prototype.endRunningApplication = function (appId) {
347-
return testUtil_1.TestUtil.getProcessOutput("xcrun simctl spawn booted launchctl list", { noLogCommand: true, noLogStdOut: true, noLogStdErr: true })
348-
.then(function (processListOutput) {
349-
// Find the app's process.
350-
var regex = new RegExp("(\\S+" + appId + "\\S+)");
351-
var execResult = regex.exec(processListOutput);
352-
if (execResult) {
353-
return execResult[0];
354-
}
355-
else {
356-
return Q.reject("Could not get the running application label.");
357-
}
358-
})
359-
.then(function (applicationLabel) {
360-
// Kill the app if we found the process.
361-
return testUtil_1.TestUtil.getProcessOutput("xcrun simctl spawn booted launchctl stop " + applicationLabel, undefined).then(function () { return null; });
362-
}, function (error) {
363-
// We couldn't find the app's process so it must not be running.
364-
return Q.resolve(error);
365-
});
348+
return testUtil_1.TestUtil.getProcessOutput("xcrun simctl terminate booted " + appId, undefined).then(function () { return null; })
366349
};
367350
/**
368351
* Restarts an already installed application by app id.
@@ -382,8 +365,8 @@ var IOSEmulatorManager = (function () {
382365
IOSEmulatorManager.prototype.resumeApplication = function (appId, delayBeforeResumingMs) {
383366
var _this = this;
384367
if (delayBeforeResumingMs === void 0) { delayBeforeResumingMs = 1000; }
385-
// Open a default iOS app (for example, camera).
386-
return this.launchInstalledApplication("com.apple.camera")
368+
// Open a default iOS app (for example, settings).
369+
return this.launchInstalledApplication("com.apple.Preferences")
387370
.then(function () {
388371
console.log("Waiting for " + delayBeforeResumingMs + "ms before resuming the test application.");
389372
return Q.delay(delayBeforeResumingMs);

test/test.ts

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -157,35 +157,21 @@ class RNIOS extends Platform.IOS implements RNPlatform {
157157
const iOSProject: string = path.join(projectDirectory, TestConfig.TestAppName, "ios");
158158
const infoPlistPath: string = path.join(iOSProject, TestConfig.TestAppName, "Info.plist");
159159
const appDelegatePath: string = path.join(iOSProject, TestConfig.TestAppName, "AppDelegate.m");
160-
// Create and install the Podfile
161-
return TestUtil.getProcessOutput("pod init", { cwd: iOSProject })
162-
.then(() => {
163-
return fs.writeFileSync(path.join(iOSProject, "Podfile"),
164-
"target '" + TestConfig.TestAppName + "'\n pod 'React', :path => '../node_modules/react-native', :subspecs => [ 'Core', 'RCTImage', 'RCTNetwork', 'RCTText', 'RCTWebSocket', ]\n pod 'CodePush', :path => '../node_modules/react-native-code-push'\n");
165-
})
160+
161+
// Install the Podfile
162+
return TestUtil.getProcessOutput("pod install", { cwd: iOSProject })
166163
// Put the IOS deployment key in the Info.plist
167164
.then(TestUtil.replaceString.bind(undefined, infoPlistPath,
168165
"</dict>\n</plist>",
169166
"<key>CodePushDeploymentKey</key>\n\t<string>" + this.getDefaultDeploymentKey() + "</string>\n\t<key>CodePushServerURL</key>\n\t<string>" + this.getServerUrl() + "</string>\n\t</dict>\n</plist>"))
170-
// Add the correct linker flags to the project.pbxproj
171-
.then(TestUtil.replaceString.bind(undefined, path.join(iOSProject, TestConfig.TestAppName + ".xcodeproj", "project.pbxproj"),
172-
"\"-lc[+][+]\",", "\"-lc++\", \"$(inherited)\""))
173-
// Install the Pod
174-
.then(TestUtil.getProcessOutput.bind(undefined, "pod install", { cwd: iOSProject }))
175-
// Add the correct bundle identifier to the Info.plist
176-
.then(TestUtil.replaceString.bind(undefined, infoPlistPath,
177-
"org[.]reactjs[.]native[.]example[.][$][(]PRODUCT_NAME:rfc1034identifier[)]",
178-
TestConfig.TestNamespace))
179167
// Set the app version to 1.0.0 instead of 1.0 in the Info.plist
180168
.then(TestUtil.replaceString.bind(undefined, infoPlistPath, "1.0", "1.0.0"))
181169
// Fix the linker flag list in project.pbxproj (pod install adds an extra comma)
182170
.then(TestUtil.replaceString.bind(undefined, path.join(iOSProject, TestConfig.TestAppName + ".xcodeproj", "project.pbxproj"),
183171
"\"[$][(]inherited[)]\",\\s*[)];", "\"$(inherited)\"\n\t\t\t\t);"))
184-
// Prevent the packager from starting during builds by replacing the script that starts it with nothing.
185-
.then(TestUtil.replaceString.bind(undefined,
186-
path.join(projectDirectory, TestConfig.TestAppName, "node_modules", "react-native", "React", "React.xcodeproj", "project.pbxproj"),
187-
"shellScript = \".*\";",
188-
"shellScript = \"\";"))
172+
// Add the correct bundle identifier
173+
.then(TestUtil.replaceString.bind(undefined, path.join(iOSProject, TestConfig.TestAppName + ".xcodeproj", "project.pbxproj"),
174+
"PRODUCT_BUNDLE_IDENTIFIER = [^;]*", "PRODUCT_BUNDLE_IDENTIFIER = \"" + TestConfig.TestNamespace + "\""))
189175
// Copy the AppDelegate.m to the project
190176
.then(TestUtil.copyFile.bind(undefined,
191177
path.join(TestConfig.templatePath, "ios", TestConfig.TestAppName, "AppDelegate.m"),

0 commit comments

Comments
 (0)