From ff5fdde1e08b76312998677a3da547b67231ebdb 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 | 15 ++++++--------- test/ios-project-service.ts | 1 + 6 files changed, 25 insertions(+), 19 deletions(-) diff --git a/lib/common b/lib/common index a2e731bafc..5d187875e5 160000 --- a/lib/common +++ b/lib/common @@ -1 +1 @@ -Subproject commit a2e731bafcc2304e20540180eb49b7ccb4ff556f +Subproject commit 5d187875e59ee60c771e005f1e17eadc2d92039d 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..2b5e8f33bc 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(); + + // passing -destination apparently only works with Xcode 7.2+ + if (xcodeVersion.major && xcodeVersion.minor && + (+xcodeVersion.major < 7 || + (+xcodeVersion.major === 7 && +xcodeVersion.minor < 2))) { + 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..74d708bce4 100644 --- a/lib/services/itmstransporter-service.ts +++ b/lib/services/itmstransporter-service.ts @@ -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) { + // iTMS Transporter's path has been modified in Xcode 6.3 + // https://github.com/nomad/shenzhen/issues/243 + if (xcodeVersion.major && xcodeVersion.minor && + (+xcodeVersion.major < 6 || + (+xcodeVersion.major === 6 && +xcodeVersion.minor < 3))) { 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", {});