From f8bc86d4064147aa02a9d06535e9f0ba2a63c12f Mon Sep 17 00:00:00 2001 From: blackdragon Date: Mon, 18 Apr 2016 11:03:04 +0300 Subject: [PATCH] Pass -destination only when on Xcode 7.2 Keep old logic when dealing with Xcode < 7.2 --- lib/common | 2 +- lib/definitions/npm.d.ts | 2 +- lib/npm-installation-manager.ts | 6 ------ lib/services/ios-project-service.ts | 18 ++++++++++++++++-- lib/services/itmstransporter-service.ts | 17 +++++++---------- test/ios-project-service.ts | 1 + 6 files changed, 26 insertions(+), 20 deletions(-) diff --git a/lib/common b/lib/common index e6e3a42247..59f26c5cd1 160000 --- a/lib/common +++ b/lib/common @@ -1 +1 @@ -Subproject commit e6e3a42247f9a052fb2b54c51c928678f0a09c6f +Subproject commit 59f26c5cd1b6bce86d6a2817707d20aa0f66fecc diff --git a/lib/definitions/npm.d.ts b/lib/definitions/npm.d.ts index 4de36a8be6..61d8f3d545 100644 --- a/lib/definitions/npm.d.ts +++ b/lib/definitions/npm.d.ts @@ -9,4 +9,4 @@ declare module "npm" { var cli: { data: Object }; } } -} \ No newline at end of file +} diff --git a/lib/npm-installation-manager.ts b/lib/npm-installation-manager.ts index 9b5acbb950..9599890fd6 100644 --- a/lib/npm-installation-manager.ts +++ b/lib/npm-installation-manager.ts @@ -6,12 +6,6 @@ import * as semver from "semver"; import * as npm from "npm"; import * as constants from "./constants"; -interface IVersionData { - major: string; - minor: string; - patch: string; -} - export class NpmInstallationManager implements INpmInstallationManager { private static NPM_LOAD_FAILED = "Failed to retrieve data from npm. Please try again a little bit later."; private versionsCache: IDictionary; diff --git a/lib/services/ios-project-service.ts b/lib/services/ios-project-service.ts index e6961c7aa9..0063b206c3 100644 --- a/lib/services/ios-project-service.ts +++ b/lib/services/ios-project-service.ts @@ -39,7 +39,8 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants, private $devicesService: Mobile.IDevicesService, private $mobileHelper: Mobile.IMobileHelper, - private $pluginVariablesService: IPluginVariablesService) { + private $pluginVariablesService: IPluginVariablesService, + private $xcodeSelectService: IXcodeSelectService) { super($fs, $projectData, $projectDataService); } @@ -204,10 +205,23 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ let currentSimulator = this.$iOSSimResolver.iOSSim.getRunningSimulator(); args = basicArgs.concat([ "-sdk", "iphonesimulator", - "-destination", `platform=iOS Simulator,name=${this.$iOSSimResolver.iOSSim.getSimulatorName(currentSimulator && currentSimulator.name)}`, "CONFIGURATION_BUILD_DIR=" + path.join(projectRoot, "build", "emulator"), "CODE_SIGN_IDENTITY=" ]); + + let additionalArgs: string[] = [], + xcodeVersion = this.$xcodeSelectService.getXcodeVersion().wait(); + + xcodeVersion.patch = xcodeVersion.patch || "0"; + // passing -destination apparently only works with Xcode 7.2+ + if (xcodeVersion.major && xcodeVersion.minor && + helpers.versionCompare(xcodeVersion, "7.2.0") < 0) { + additionalArgs = ["-arch", "i386", 'VALID_ARCHS="i386"']; + } else { + additionalArgs = ["-destination", `platform=iOS Simulator,name=${this.$iOSSimResolver.iOSSim.getSimulatorName(currentSimulator && currentSimulator.name)}`]; + } + + args = args.concat(additionalArgs); } if (buildConfig && buildConfig.codeSignIdentity) { diff --git a/lib/services/itmstransporter-service.ts b/lib/services/itmstransporter-service.ts index f5199b1900..1152a2ebae 100644 --- a/lib/services/itmstransporter-service.ts +++ b/lib/services/itmstransporter-service.ts @@ -5,7 +5,7 @@ import * as temp from "temp"; import {EOL} from "os"; import {ITMSConstants} from "../constants"; import {ItunesConnectApplicationTypes} from "../constants"; -import {quoteString} from "../common/helpers"; +import {quoteString, versionCompare} from "../common/helpers"; export class ITMSTransporterService implements IITMSTransporterService { private _itmsTransporterPath: string = null; @@ -22,7 +22,6 @@ export class ITMSTransporterService implements IITMSTransporterService { private $injector: IInjector, private $logger: ILogger, private $staticConfig: IStaticConfig, - private $sysInfo: ISysInfo, private $xcodeSelectService: IXcodeSelectService) { } // This property was introduced due to the fact that the $platformService dependency @@ -166,17 +165,15 @@ export class ITMSTransporterService implements IITMSTransporterService { return ((): string => { if (!this._itmsTransporterPath) { let xcodePath = this.$xcodeSelectService.getContentsDirectoryPath().wait(), - sysInfo = this.$sysInfo.getSysInfo(this.$staticConfig.pathToPackageJson).wait(), - xcodeVersionMatch = sysInfo.xcodeVer.match(/Xcode (.*)/), + xcodeVersion = this.$xcodeSelectService.getXcodeVersion().wait(), result = path.join(xcodePath, "Applications", "Application Loader.app", "Contents"); - if (xcodeVersionMatch && xcodeVersionMatch[1]) { - let [major, minor] = xcodeVersionMatch[1].split("."); - // iTMS Transporter's path has been modified in Xcode 6.3 - // https://github.com/nomad/shenzhen/issues/243 - if (+major <= 6 && +minor < 3) { + xcodeVersion.patch = xcodeVersion.patch || "0"; + // iTMS Transporter's path has been modified in Xcode 6.3 + // https://github.com/nomad/shenzhen/issues/243 + if (xcodeVersion.major && xcodeVersion.minor && + versionCompare(xcodeVersion, "6.3.0") < 0) { result = path.join(result, "MacOS"); - } } this._itmsTransporterPath = path.join(result, ITMSConstants.iTMSDirectoryName, "bin", ITMSConstants.iTMSExecutableName); diff --git a/test/ios-project-service.ts b/test/ios-project-service.ts index 0a2af2b586..aabcd23427 100644 --- a/test/ios-project-service.ts +++ b/test/ios-project-service.ts @@ -58,6 +58,7 @@ function createTestInjector(projectPath: string, projectName: string): IInjector projectFilePath: path.join(projectPath, "package.json") }); testInjector.register("projectHelper", {}); + testInjector.register("xcodeSelectService", {}); testInjector.register("staticConfig", ConfigLib.StaticConfig); testInjector.register("projectDataService", {}); testInjector.register("prompter", {});