@@ -244,7 +244,6 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
244
244
"build" ,
245
245
'SHARED_PRECOMPS_DIR=' + path . join ( projectRoot , 'build' , 'sharedpch' )
246
246
] ;
247
-
248
247
basicArgs = basicArgs . concat ( this . xcbuildProjectArgs ( projectRoot ) ) ;
249
248
250
249
// Starting from tns-ios 1.4 the xcconfig file is referenced in the project template
@@ -253,37 +252,58 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
253
252
basicArgs . push ( "-xcconfig" , path . join ( projectRoot , this . $projectData . projectName , "build.xcconfig" ) ) ;
254
253
}
255
254
256
- let args : string [ ] = [ ] ;
257
255
let buildForDevice = this . $options . forDevice || ( buildConfig && buildConfig . buildForDevice ) ;
258
256
if ( buildForDevice ) {
259
- let defaultArchitectures = [
260
- 'ARCHS=armv7 arm64' ,
261
- 'VALID_ARCHS=armv7 arm64'
262
- ] ;
263
-
264
- args = basicArgs . concat ( [
265
- "-sdk" , "iphoneos" ,
266
- "CONFIGURATION_BUILD_DIR=" + path . join ( projectRoot , "build" , "device" )
267
- ] ) ;
257
+ this . buildForDevice ( projectRoot , basicArgs , buildConfig ) . wait ( ) ;
258
+ } else {
259
+ this . buildForSimulator ( projectRoot , basicArgs , buildConfig ) . wait ( ) ;
260
+ }
261
+ } ) . future < void > ( ) ( ) ;
262
+ }
268
263
269
- args = args . concat ( ( buildConfig && buildConfig . architectures ) || defaultArchitectures ) ;
264
+ private buildForDevice ( projectRoot : string , args : string [ ] , buildConfig ?: IiOSBuildConfig ) : IFuture < void > {
265
+ return ( ( ) => {
266
+ let defaultArchitectures = [
267
+ 'ARCHS=armv7 arm64' ,
268
+ 'VALID_ARCHS=armv7 arm64'
269
+ ] ;
270
270
271
- let xcodeBuildVersion = this . getXcodeVersion ( ) ;
272
- if ( helpers . versionCompare ( xcodeBuildVersion , "8.0" ) >= 0 ) {
273
- let teamId = this . getDevelopmentTeam ( ) ;
274
- if ( teamId ) {
275
- args = args . concat ( "DEVELOPMENT_TEAM=" + teamId ) ;
271
+ // build only for device specific architecture
272
+ if ( ! this . $options . release && ! ( buildConfig && buildConfig . architectures ) ) {
273
+ this . $devicesService . initialize ( { platform : this . $devicePlatformsConstants . iOS . toLowerCase ( ) , deviceId : this . $options . device } ) . wait ( ) ;
274
+ let instances = this . $devicesService . getDeviceInstances ( ) ;
275
+ let devicesArchitectures = _ ( instances )
276
+ . filter ( d => this . $mobileHelper . isiOSPlatform ( d . deviceInfo . platform ) && d . deviceInfo . activeArchitecture )
277
+ . map ( d => d . deviceInfo . activeArchitecture )
278
+ . uniq ( )
279
+ . value ( ) ;
280
+ if ( devicesArchitectures . length > 0 ) {
281
+ let architectures = [
282
+ `ARCHS=${ devicesArchitectures . join ( " " ) } ` ,
283
+ `VALID_ARCHS=${ devicesArchitectures . join ( " " ) } `
284
+ ] ;
285
+ if ( devicesArchitectures . length > 1 ) {
286
+ architectures . push ( 'ONLY_ACTIVE_ARCH=NO' ) ;
287
+ }
288
+ if ( ! buildConfig ) {
289
+ buildConfig = { } ;
276
290
}
291
+ buildConfig . architectures = architectures ;
292
+ }
293
+ }
294
+ args = args . concat ( ( buildConfig && buildConfig . architectures ) || defaultArchitectures ) ;
295
+
296
+ args = args . concat ( [
297
+ "-sdk" , "iphoneos" ,
298
+ "CONFIGURATION_BUILD_DIR=" + path . join ( projectRoot , "build" , "device" )
299
+ ] ) ;
300
+
301
+ let xcodeBuildVersion = this . getXcodeVersion ( ) ;
302
+ if ( helpers . versionCompare ( xcodeBuildVersion , "8.0" ) >= 0 ) {
303
+ let teamId = this . getDevelopmentTeam ( ) ;
304
+ if ( teamId ) {
305
+ args = args . concat ( "DEVELOPMENT_TEAM=" + teamId ) ;
277
306
}
278
- } else {
279
- args = basicArgs . concat ( [
280
- "-sdk" , "iphonesimulator" ,
281
- "ARCHS=i386 x86_64" ,
282
- "VALID_ARCHS=i386 x86_64" ,
283
- "ONLY_ACTIVE_ARCH=NO" ,
284
- "CONFIGURATION_BUILD_DIR=" + path . join ( projectRoot , "build" , "emulator" ) ,
285
- "CODE_SIGN_IDENTITY="
286
- ] ) ;
287
307
}
288
308
289
309
if ( buildConfig && buildConfig . codeSignIdentity ) {
@@ -295,47 +315,38 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
295
315
}
296
316
297
317
this . $childProcess . spawnFromEvent ( "xcodebuild" , args , "exit" , { cwd : this . $options , stdio : 'inherit' } ) . wait ( ) ;
318
+ this . createIpa ( projectRoot ) . wait ( ) ;
298
319
299
- if ( buildForDevice ) {
300
- let buildOutputPath = path . join ( projectRoot , "build" , "device" ) ;
301
-
302
- // Produce ipa file
303
- let xcrunArgs = [
304
- "-sdk" , "iphoneos" ,
305
- "PackageApplication" ,
306
- "-v" , path . join ( buildOutputPath , this . $projectData . projectName + ".app" ) ,
307
- "-o" , path . join ( buildOutputPath , this . $projectData . projectName + ".ipa" )
308
- ] ;
309
-
310
- this . $childProcess . spawnFromEvent ( "xcrun" , xcrunArgs , "exit" , { cwd : this . $options , stdio : 'inherit' } ) . wait ( ) ;
311
- }
312
320
} ) . future < void > ( ) ( ) ;
313
321
}
314
322
315
- public buildForDeploy ( platform : string , buildConfig ?: IBuildConfig ) : IFuture < void > {
316
- if ( this . $options . release ) {
317
- return this . buildProject ( this . platformData . projectRoot , buildConfig ) ;
318
- }
319
-
320
- let devicesArchitectures = _ ( this . $devicesService . getDeviceInstances ( ) )
321
- . filter ( d => this . $mobileHelper . isiOSPlatform ( d . deviceInfo . platform ) )
322
- . map ( d => d . deviceInfo . activeArchitecture )
323
- . uniq ( )
324
- . value ( ) ;
325
-
326
- let architectures = [
327
- `ARCHS=${ devicesArchitectures . join ( " " ) } ` ,
328
- `VALID_ARCHS=${ devicesArchitectures . join ( " " ) } `
329
- ] ;
323
+ private buildForSimulator ( projectRoot : string , args : string [ ] , buildConfig ?: IiOSBuildConfig ) : IFuture < void > {
324
+ return ( ( ) => {
325
+ args = args . concat ( [
326
+ "-sdk" , "iphonesimulator" ,
327
+ "ARCHS=i386 x86_64" ,
328
+ "VALID_ARCHS=i386 x86_64" ,
329
+ "ONLY_ACTIVE_ARCH=NO" ,
330
+ "CONFIGURATION_BUILD_DIR=" + path . join ( projectRoot , "build" , "emulator" ) ,
331
+ "CODE_SIGN_IDENTITY="
332
+ ] ) ;
330
333
331
- if ( devicesArchitectures . length > 1 ) {
332
- architectures . push ( 'ONLY_ACTIVE_ARCH=NO' ) ;
333
- }
334
+ this . $childProcess . spawnFromEvent ( "xcodebuild" , args , "exit" , { cwd : this . $options , stdio : 'inherit' } ) . wait ( ) ;
334
335
335
- buildConfig = buildConfig || { } ;
336
- buildConfig . architectures = architectures ;
336
+ } ) . future < void > ( ) ( ) ;
337
+ }
337
338
338
- return this . buildProject ( this . platformData . projectRoot , buildConfig ) ;
339
+ private createIpa ( projectRoot : string ) : IFuture < void > {
340
+ return ( ( ) => {
341
+ let buildOutputPath = path . join ( projectRoot , "build" , "device" ) ;
342
+ let xcrunArgs = [
343
+ "-sdk" , "iphoneos" ,
344
+ "PackageApplication" ,
345
+ "-v" , path . join ( buildOutputPath , this . $projectData . projectName + ".app" ) ,
346
+ "-o" , path . join ( buildOutputPath , this . $projectData . projectName + ".ipa" )
347
+ ] ;
348
+ this . $childProcess . spawnFromEvent ( "xcrun" , xcrunArgs , "exit" , { cwd : this . $options , stdio : 'inherit' } ) . wait ( ) ;
349
+ } ) . future < void > ( ) ( ) ;
339
350
}
340
351
341
352
public isPlatformPrepared ( projectRoot : string ) : IFuture < boolean > {
0 commit comments