Skip to content

Commit db0ea50

Browse files
committed
Merge pull request #1688 from NativeScript/kerezov/destination-to-xcode-7.3
Pass -destination only when on Xcode 7.2
2 parents 33eb315 + f8bc86d commit db0ea50

File tree

6 files changed

+26
-20
lines changed

6 files changed

+26
-20
lines changed

lib/definitions/npm.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ declare module "npm" {
99
var cli: { data: Object };
1010
}
1111
}
12-
}
12+
}

lib/npm-installation-manager.ts

-6
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ import * as semver from "semver";
66
import * as npm from "npm";
77
import * as constants from "./constants";
88

9-
interface IVersionData {
10-
major: string;
11-
minor: string;
12-
patch: string;
13-
}
14-
159
export class NpmInstallationManager implements INpmInstallationManager {
1610
private static NPM_LOAD_FAILED = "Failed to retrieve data from npm. Please try again a little bit later.";
1711
private versionsCache: IDictionary<string[]>;

lib/services/ios-project-service.ts

+16-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
3939
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
4040
private $devicesService: Mobile.IDevicesService,
4141
private $mobileHelper: Mobile.IMobileHelper,
42-
private $pluginVariablesService: IPluginVariablesService) {
42+
private $pluginVariablesService: IPluginVariablesService,
43+
private $xcodeSelectService: IXcodeSelectService) {
4344
super($fs, $projectData, $projectDataService);
4445
}
4546

@@ -204,10 +205,23 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
204205
let currentSimulator = this.$iOSSimResolver.iOSSim.getRunningSimulator();
205206
args = basicArgs.concat([
206207
"-sdk", "iphonesimulator",
207-
"-destination", `platform=iOS Simulator,name=${this.$iOSSimResolver.iOSSim.getSimulatorName(currentSimulator && currentSimulator.name)}`,
208208
"CONFIGURATION_BUILD_DIR=" + path.join(projectRoot, "build", "emulator"),
209209
"CODE_SIGN_IDENTITY="
210210
]);
211+
212+
let additionalArgs: string[] = [],
213+
xcodeVersion = this.$xcodeSelectService.getXcodeVersion().wait();
214+
215+
xcodeVersion.patch = xcodeVersion.patch || "0";
216+
// passing -destination apparently only works with Xcode 7.2+
217+
if (xcodeVersion.major && xcodeVersion.minor &&
218+
helpers.versionCompare(xcodeVersion, "7.2.0") < 0) {
219+
additionalArgs = ["-arch", "i386", 'VALID_ARCHS="i386"'];
220+
} else {
221+
additionalArgs = ["-destination", `platform=iOS Simulator,name=${this.$iOSSimResolver.iOSSim.getSimulatorName(currentSimulator && currentSimulator.name)}`];
222+
}
223+
224+
args = args.concat(additionalArgs);
211225
}
212226

213227
if (buildConfig && buildConfig.codeSignIdentity) {

lib/services/itmstransporter-service.ts

+7-10
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as temp from "temp";
55
import {EOL} from "os";
66
import {ITMSConstants} from "../constants";
77
import {ItunesConnectApplicationTypes} from "../constants";
8-
import {quoteString} from "../common/helpers";
8+
import {quoteString, versionCompare} from "../common/helpers";
99

1010
export class ITMSTransporterService implements IITMSTransporterService {
1111
private _itmsTransporterPath: string = null;
@@ -22,7 +22,6 @@ export class ITMSTransporterService implements IITMSTransporterService {
2222
private $injector: IInjector,
2323
private $logger: ILogger,
2424
private $staticConfig: IStaticConfig,
25-
private $sysInfo: ISysInfo,
2625
private $xcodeSelectService: IXcodeSelectService) { }
2726

2827
// This property was introduced due to the fact that the $platformService dependency
@@ -166,17 +165,15 @@ export class ITMSTransporterService implements IITMSTransporterService {
166165
return ((): string => {
167166
if (!this._itmsTransporterPath) {
168167
let xcodePath = this.$xcodeSelectService.getContentsDirectoryPath().wait(),
169-
sysInfo = this.$sysInfo.getSysInfo(this.$staticConfig.pathToPackageJson).wait(),
170-
xcodeVersionMatch = sysInfo.xcodeVer.match(/Xcode (.*)/),
168+
xcodeVersion = this.$xcodeSelectService.getXcodeVersion().wait(),
171169
result = path.join(xcodePath, "Applications", "Application Loader.app", "Contents");
172170

173-
if (xcodeVersionMatch && xcodeVersionMatch[1]) {
174-
let [major, minor] = xcodeVersionMatch[1].split(".");
175-
// iTMS Transporter's path has been modified in Xcode 6.3
176-
// https://github.com/nomad/shenzhen/issues/243
177-
if (+major <= 6 && +minor < 3) {
171+
xcodeVersion.patch = xcodeVersion.patch || "0";
172+
// iTMS Transporter's path has been modified in Xcode 6.3
173+
// https://github.com/nomad/shenzhen/issues/243
174+
if (xcodeVersion.major && xcodeVersion.minor &&
175+
versionCompare(xcodeVersion, "6.3.0") < 0) {
178176
result = path.join(result, "MacOS");
179-
}
180177
}
181178

182179
this._itmsTransporterPath = path.join(result, ITMSConstants.iTMSDirectoryName, "bin", ITMSConstants.iTMSExecutableName);

test/ios-project-service.ts

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ function createTestInjector(projectPath: string, projectName: string): IInjector
5858
projectFilePath: path.join(projectPath, "package.json")
5959
});
6060
testInjector.register("projectHelper", {});
61+
testInjector.register("xcodeSelectService", {});
6162
testInjector.register("staticConfig", ConfigLib.StaticConfig);
6263
testInjector.register("projectDataService", {});
6364
testInjector.register("prompter", {});

0 commit comments

Comments
 (0)