@@ -2,6 +2,7 @@ import * as path from "path";
2
2
import * as shell from "shelljs" ;
3
3
import * as semver from "semver" ;
4
4
import * as constants from "../constants" ;
5
+ import { Configurations } from "../common/constants" ;
5
6
import * as helpers from "../common/helpers" ;
6
7
import { attachAwaitDetach } from "../common/helpers" ;
7
8
import * as projectServiceBaseLib from "./platform-project-service-base" ;
@@ -21,6 +22,12 @@ interface INativeSourceCodeGroup {
21
22
files : string [ ] ;
22
23
}
23
24
25
+ const DevicePlatformSdkName = "iphoneos" ;
26
+ const SimulatorPlatformSdkName = "iphonesimulator" ;
27
+
28
+ const getPlatformSdkName = ( forDevice : boolean ) : string => forDevice ? DevicePlatformSdkName : SimulatorPlatformSdkName ;
29
+ const getConfigurationName = ( release : boolean ) : string => release ? Configurations . Release : Configurations . Debug ;
30
+
24
31
export class IOSProjectService extends projectServiceBaseLib . PlatformProjectServiceBase implements IPlatformProjectService {
25
32
private static XCODEBUILD_MIN_VERSION = "6.0" ;
26
33
private static IOS_PROJECT_NAME_PLACEHOLDER = "__PROJECT_NAME__" ;
@@ -67,8 +74,10 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
67
74
appDestinationDirectoryPath : path . join ( projectRoot , projectData . projectName ) ,
68
75
platformProjectService : this ,
69
76
projectRoot : projectRoot ,
70
- deviceBuildOutputPath : path . join ( projectRoot , constants . BUILD_DIR , "device" ) ,
71
- emulatorBuildOutputPath : path . join ( projectRoot , constants . BUILD_DIR , "emulator" ) ,
77
+ getBuildOutputPath : ( options : IBuildOutputOptions ) : string => {
78
+ const config = getConfigurationName ( ! options || options . release ) ;
79
+ return path . join ( projectRoot , constants . BUILD_DIR , `${ config } -${ getPlatformSdkName ( ! options || options . buildForDevice ) } ` ) ;
80
+ } ,
72
81
getValidBuildOutputData : ( buildOptions : IBuildOutputOptions ) : IValidBuildOutputData => {
73
82
const forDevice = ! buildOptions || ! ! buildOptions . buildForDevice ;
74
83
if ( forDevice ) {
@@ -206,10 +215,11 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
206
215
* Returns the path to the .xcarchive.
207
216
*/
208
217
public async archive ( projectData : IProjectData , buildConfig ?: IBuildConfig , options ?: { archivePath ?: string , additionalArgs ?: string [ ] } ) : Promise < string > {
218
+ const platformData = this . getPlatformData ( projectData ) ;
209
219
const projectRoot = this . getPlatformData ( projectData ) . projectRoot ;
210
- const archivePath = options && options . archivePath ? path . resolve ( options . archivePath ) : path . join ( projectRoot , "/build/archive/" , projectData . projectName + ".xcarchive" ) ;
220
+ const archivePath = options && options . archivePath ? path . resolve ( options . archivePath ) : path . join ( platformData . getBuildOutputPath ( buildConfig ) , projectData . projectName + ".xcarchive" ) ;
211
221
let args = [ "archive" , "-archivePath" , archivePath , "-configuration" ,
212
- ( ! buildConfig || buildConfig . release ) ? "Release" : "Debug" ]
222
+ getConfigurationName ( ! buildConfig || buildConfig . release ) ]
213
223
. concat ( this . xcbuildProjectArgs ( projectRoot , projectData , "scheme" ) ) ;
214
224
215
225
if ( options && options . additionalArgs ) {
@@ -278,12 +288,11 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
278
288
/**
279
289
* Exports .xcarchive for a development device.
280
290
*/
281
- private async exportDevelopmentArchive ( projectData : IProjectData , buildConfig : IBuildConfig , options : { archivePath : string , exportDir ?: string , teamID ?: string , provision ?: string } ) : Promise < string > {
291
+ private async exportDevelopmentArchive ( projectData : IProjectData , buildConfig : IBuildConfig , options : { archivePath : string , provision ?: string } ) : Promise < string > {
282
292
const platformData = this . getPlatformData ( projectData ) ;
283
293
const projectRoot = platformData . projectRoot ;
284
294
const archivePath = options . archivePath ;
285
- const buildOutputPath = path . join ( projectRoot , "build" , "device" ) ;
286
- const exportOptionsMethod = await this . getExportOptionsMethod ( projectData ) ;
295
+ const exportOptionsMethod = await this . getExportOptionsMethod ( projectData , archivePath ) ;
287
296
let plistTemplate = `<?xml version="1.0" encoding="UTF-8"?>
288
297
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
289
298
<plist version="1.0">
@@ -311,7 +320,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
311
320
this . $fs . writeFile ( exportOptionsPlist , plistTemplate ) ;
312
321
313
322
// The xcodebuild exportPath expects directory and writes the <project-name>.ipa at that directory.
314
- const exportPath = path . resolve ( options . exportDir || buildOutputPath ) ;
323
+ const exportPath = path . resolve ( path . dirname ( archivePath ) ) ;
315
324
const exportFile = path . join ( exportPath , projectData . projectName + ".ipa" ) ;
316
325
317
326
await this . xcodebuild (
@@ -407,8 +416,8 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
407
416
args = args . concat ( ( buildConfig && buildConfig . architectures ) || this . getBuildArchitectures ( projectData , buildConfig , [ "armv7" , "arm64" ] ) ) ;
408
417
409
418
args = args . concat ( [
410
- "-sdk" , "iphoneos" ,
411
- "CONFIGURATION_BUILD_DIR =" + path . join ( projectRoot , "build" , "device" )
419
+ "-sdk" , DevicePlatformSdkName ,
420
+ "BUILD_DIR =" + path . join ( projectRoot , constants . BUILD_DIR )
412
421
] ) ;
413
422
414
423
const xcodeBuildVersion = await this . getXcodeVersion ( ) ;
@@ -574,10 +583,10 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
574
583
. concat ( architectures )
575
584
. concat ( [
576
585
"build" ,
577
- "-configuration" , buildConfig . release ? "Release" : "Debug" ,
578
- "-sdk" , "iphonesimulator" ,
586
+ "-configuration" , getConfigurationName ( buildConfig . release ) ,
587
+ "-sdk" , SimulatorPlatformSdkName ,
579
588
"ONLY_ACTIVE_ARCH=NO" ,
580
- "CONFIGURATION_BUILD_DIR =" + path . join ( projectRoot , "build" , "emulator" ) ,
589
+ "BUILD_DIR =" + path . join ( projectRoot , constants . BUILD_DIR ) ,
581
590
"CODE_SIGN_IDENTITY=" ,
582
591
] )
583
592
. concat ( this . xcbuildProjectArgs ( projectRoot , projectData ) ) ;
@@ -1390,8 +1399,8 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
1390
1399
}
1391
1400
}
1392
1401
1393
- private getExportOptionsMethod ( projectData : IProjectData ) : string {
1394
- const embeddedMobileProvisionPath = path . join ( this . getPlatformData ( projectData ) . projectRoot , "build" , "archive" , ` ${ projectData . projectName } .xcarchive` , 'Products' , 'Applications' , `${ projectData . projectName } .app` , "embedded.mobileprovision" ) ;
1402
+ private getExportOptionsMethod ( projectData : IProjectData , archivePath : string ) : string {
1403
+ const embeddedMobileProvisionPath = path . join ( archivePath , 'Products' , 'Applications' , `${ projectData . projectName } .app` , "embedded.mobileprovision" ) ;
1395
1404
const provision = mobileprovision . provision . readFromFile ( embeddedMobileProvisionPath ) ;
1396
1405
1397
1406
return {
0 commit comments