Skip to content

Commit cdb0167

Browse files
FatmeFatme
Fatme
authored and
Fatme
committed
Merge pull request #247 from NativeScript/fatme/build-for-device
Build for emulator by default
2 parents fe952b5 + 547f2f1 commit cdb0167

File tree

4 files changed

+20
-14
lines changed

4 files changed

+20
-14
lines changed

lib/options.ts

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ var knownOpts:any = {
1515
"release": Boolean,
1616
"emulator": Boolean,
1717
"symlink": Boolean,
18+
"forDevice": Boolean,
19+
"for-device": Boolean,
1820
"keyStorePath": String,
1921
"keyStorePassword": String,
2022
"keyStoreAlias": String,

lib/services/ios-project-service.ts

+10-9
Original file line numberDiff line numberDiff line change
@@ -132,26 +132,27 @@ class IOSProjectService implements IPlatformProjectService {
132132
];
133133
var args: string[] = [];
134134

135-
if(options.emulator) {
136-
args = basicArgs.concat([
137-
"-sdk", "iphonesimulator",
138-
"-arch", "i386",
139-
"VALID_ARCHS=\"i386\"",
140-
"CONFIGURATION_BUILD_DIR=" + path.join(projectRoot, "build", "emulator")
141-
]);
142-
} else {
135+
if(options.forDevice) {
143136
args = basicArgs.concat([
144137
"-xcconfig", path.join(projectRoot, this.$projectData.projectName, "build.xcconfig"),
145138
"-sdk", "iphoneos",
146139
'ARCHS=armv7 arm64',
147140
'VALID_ARCHS=armv7 arm64',
148141
"CONFIGURATION_BUILD_DIR=" + path.join(projectRoot, "build", "device")
149142
]);
143+
} else {
144+
args = basicArgs.concat([
145+
"-sdk", "iphonesimulator",
146+
"-arch", "i386",
147+
"VALID_ARCHS=\"i386\"",
148+
"CONFIGURATION_BUILD_DIR=" + path.join(projectRoot, "build", "emulator")
149+
]);
150+
150151
}
151152

152153
this.$childProcess.spawnFromEvent("xcodebuild", args, "exit", {cwd: options, stdio: 'inherit'}).wait();
153154

154-
if(!options.emulator) {
155+
if(options.forDevice) {
155156
var buildOutputPath = path.join(projectRoot, "build", "device");
156157

157158
// Produce ipa file

lib/services/platform-service.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,10 @@ export class PlatformService implements IPlatformService {
218218

219219
var platformData = this.$platformsData.getPlatformData(platform);
220220

221+
var cachedDeviceOption = options.forDevice;
222+
options.forDevice = true;
221223
this.buildPlatform(platform).wait();
224+
options.forDevice = cachedDeviceOption;
222225

223226
packageFile = this.getLatestApplicationPackageForDevice(platformData).wait().packageName;
224227
this.$logger.out("Using ", packageFile);
@@ -262,7 +265,10 @@ export class PlatformService implements IPlatformService {
262265

263266
var platformData = this.$platformsData.getPlatformData(platform);
264267

268+
var cachedDeviceOption = options.forDevice;
269+
options.forDevice = true;
265270
this.buildPlatform(platform).wait();
271+
options.forDevice = cachedDeviceOption;
266272

267273
// Get latest package that is produced from build
268274
var packageFile = this.getLatestApplicationPackageForDevice(platformData).wait().packageName;
@@ -287,10 +293,7 @@ export class PlatformService implements IPlatformService {
287293
emulatorServices.checkDependencies().wait();
288294

289295
if(!options.availableDevices) {
290-
var cachedEmulatorOption = options.emulator;
291-
options.emulator = true;
292296
this.buildPlatform(platform).wait();
293-
options.emulator = cachedEmulatorOption;
294297

295298
var packageFile = this.getLatestApplicationPackageForEmulator(platformData).wait().packageName;
296299
this.$logger.out("Using ", packageFile);

resources/help.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -278,15 +278,15 @@ Options:
278278
--[build|ios]--
279279

280280
Usage:
281-
$ tns build ios [--device] [--release]
281+
$ tns build ios [--forDevice] [--release]
282282

283283
Builds the project for iOS and produces an APP or IPA that you can manually deploy in the iOS Simulator or on device, respectively.
284284

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

287287
Options:
288288
--release - If set, produces a release build. Otherwise, produces a debug build.
289-
--device - If set, produces an application package that you can deploy on device.
289+
--forDevice - If set, produces an application package that you can deploy on device.
290290
Otherwise, produces a build that you can run only in the native iOS Simulator.
291291

292292
--[/]--

0 commit comments

Comments
 (0)