Skip to content

Commit

Permalink
Merge pull request #247 from NativeScript/fatme/build-for-device
Browse files Browse the repository at this point in the history
Build for emulator by default
  • Loading branch information
Fatme authored and Fatme committed Feb 26, 2015
2 parents fe952b5 + 547f2f1 commit cdb0167
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
2 changes: 2 additions & 0 deletions lib/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ var knownOpts:any = {
"release": Boolean,
"emulator": Boolean,
"symlink": Boolean,
"forDevice": Boolean,
"for-device": Boolean,
"keyStorePath": String,
"keyStorePassword": String,
"keyStoreAlias": String,
Expand Down
19 changes: 10 additions & 9 deletions lib/services/ios-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,26 +132,27 @@ 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",
'ARCHS=armv7 arm64',
'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
Expand Down
9 changes: 6 additions & 3 deletions lib/services/platform-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions resources/help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -278,15 +278,15 @@ 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.

Before building for iOS device, verify that you have configured a valid pair of certificate and provisioning profile on your OS X system.

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.

--[/]--
Expand Down

0 comments on commit cdb0167

Please sign in to comment.