From 547f2f15c01ea2bb21055845f8e61537c09ba0f9 Mon Sep 17 00:00:00 2001 From: Fatme Havaluova Date: Thu, 26 Feb 2015 09:58:09 +0200 Subject: [PATCH] Build for emulator by default --- lib/options.ts | 2 ++ lib/services/ios-project-service.ts | 19 ++++++++++--------- lib/services/platform-service.ts | 9 ++++++--- resources/help.txt | 4 ++-- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/lib/options.ts b/lib/options.ts index 29549bddfb..867a6226ce 100644 --- a/lib/options.ts +++ b/lib/options.ts @@ -15,6 +15,8 @@ var knownOpts:any = { "release": Boolean, "emulator": Boolean, "symlink": Boolean, + "forDevice": Boolean, + "for-device": Boolean, "keyStorePath": String, "keyStorePassword": String, "keyStoreAlias": String, diff --git a/lib/services/ios-project-service.ts b/lib/services/ios-project-service.ts index ee3834946d..70b0ccb0f1 100644 --- a/lib/services/ios-project-service.ts +++ b/lib/services/ios-project-service.ts @@ -132,14 +132,7 @@ class IOSProjectService implements IPlatformProjectService { ]; var args: string[] = []; - if(options.emulator) { - args = basicArgs.concat([ - "-sdk", "iphonesimulator", - "-arch", "i386", - "VALID_ARCHS=\"i386\"", - "CONFIGURATION_BUILD_DIR=" + path.join(projectRoot, "build", "emulator") - ]); - } else { + if(options.forDevice) { args = basicArgs.concat([ "-xcconfig", path.join(projectRoot, this.$projectData.projectName, "build.xcconfig"), "-sdk", "iphoneos", @@ -147,11 +140,19 @@ class IOSProjectService implements IPlatformProjectService { 'VALID_ARCHS=armv7 arm64', "CONFIGURATION_BUILD_DIR=" + path.join(projectRoot, "build", "device") ]); + } else { + args = basicArgs.concat([ + "-sdk", "iphonesimulator", + "-arch", "i386", + "VALID_ARCHS=\"i386\"", + "CONFIGURATION_BUILD_DIR=" + path.join(projectRoot, "build", "emulator") + ]); + } this.$childProcess.spawnFromEvent("xcodebuild", args, "exit", {cwd: options, stdio: 'inherit'}).wait(); - if(!options.emulator) { + if(options.forDevice) { var buildOutputPath = path.join(projectRoot, "build", "device"); // Produce ipa file diff --git a/lib/services/platform-service.ts b/lib/services/platform-service.ts index 1cafc61518..1652ea14f9 100644 --- a/lib/services/platform-service.ts +++ b/lib/services/platform-service.ts @@ -218,7 +218,10 @@ export class PlatformService implements IPlatformService { var platformData = this.$platformsData.getPlatformData(platform); + var cachedDeviceOption = options.forDevice; + options.forDevice = true; this.buildPlatform(platform).wait(); + options.forDevice = cachedDeviceOption; packageFile = this.getLatestApplicationPackageForDevice(platformData).wait().packageName; this.$logger.out("Using ", packageFile); @@ -262,7 +265,10 @@ export class PlatformService implements IPlatformService { var platformData = this.$platformsData.getPlatformData(platform); + var cachedDeviceOption = options.forDevice; + options.forDevice = true; this.buildPlatform(platform).wait(); + options.forDevice = cachedDeviceOption; // Get latest package that is produced from build var packageFile = this.getLatestApplicationPackageForDevice(platformData).wait().packageName; @@ -287,10 +293,7 @@ export class PlatformService implements IPlatformService { emulatorServices.checkDependencies().wait(); if(!options.availableDevices) { - var cachedEmulatorOption = options.emulator; - options.emulator = true; this.buildPlatform(platform).wait(); - options.emulator = cachedEmulatorOption; var packageFile = this.getLatestApplicationPackageForEmulator(platformData).wait().packageName; this.$logger.out("Using ", packageFile); diff --git a/resources/help.txt b/resources/help.txt index 3b8e716063..b136156cee 100644 --- a/resources/help.txt +++ b/resources/help.txt @@ -278,7 +278,7 @@ Options: --[build|ios]-- Usage: - $ tns build ios [--device] [--release] + $ tns build ios [--forDevice] [--release] Builds the project for iOS and produces an APP or IPA that you can manually deploy in the iOS Simulator or on device, respectively. @@ -286,7 +286,7 @@ Before building for iOS device, verify that you have configured a valid pair of Options: --release - If set, produces a release build. Otherwise, produces a debug build. - --device - If set, produces an application package that you can deploy on device. + --forDevice - If set, produces an application package that you can deploy on device. Otherwise, produces a build that you can run only in the native iOS Simulator. --[/]--