@@ -290,13 +290,15 @@ class AndroidProjectService implements IPlatformSpecificProjectService {
290
290
} ) . future < any > ( ) ( ) ;
291
291
}
292
292
293
- public interpolateData ( projectRoot : string ) : void {
294
- // Interpolate the activity name and package
295
- var stringsFilePath = path . join ( projectRoot , 'res' , 'values' , 'strings.xml' ) ;
296
- shell . sed ( '-i' , / _ _ N A M E _ _ / , this . $projectData . projectName , stringsFilePath ) ;
297
- shell . sed ( '-i' , / _ _ T I T L E _ A C T I V I T Y _ _ / , this . $projectData . projectName , stringsFilePath ) ;
298
- shell . sed ( '-i' , / _ _ N A M E _ _ / , this . $projectData . projectName , path . join ( projectRoot , '.project' ) ) ;
299
- shell . sed ( '-i' , / _ _ P A C K A G E _ _ / , this . $projectData . projectId , path . join ( projectRoot , "AndroidManifest.xml" ) ) ;
293
+ public interpolateData ( projectRoot : string ) : IFuture < void > {
294
+ return ( ( ) => {
295
+ // Interpolate the activity name and package
296
+ var stringsFilePath = path . join ( projectRoot , 'res' , 'values' , 'strings.xml' ) ;
297
+ shell . sed ( '-i' , / _ _ N A M E _ _ / , this . $projectData . projectName , stringsFilePath ) ;
298
+ shell . sed ( '-i' , / _ _ T I T L E _ A C T I V I T Y _ _ / , this . $projectData . projectName , stringsFilePath ) ;
299
+ shell . sed ( '-i' , / _ _ N A M E _ _ / , this . $projectData . projectName , path . join ( projectRoot , '.project' ) ) ;
300
+ shell . sed ( '-i' , / _ _ P A C K A G E _ _ / , this . $projectData . projectId , path . join ( projectRoot , "AndroidManifest.xml" ) ) ;
301
+ } ) . future < void > ( ) ( ) ;
300
302
}
301
303
302
304
public executePlatformSpecificAction ( projectRoot : string , frameworkDir : string ) {
@@ -420,32 +422,80 @@ class AndroidProjectService implements IPlatformSpecificProjectService {
420
422
$injector . register ( "androidProjectService" , AndroidProjectService ) ;
421
423
422
424
class IOSProjectService implements IPlatformSpecificProjectService {
423
- public validate ( ) : void {
425
+ private static PROJECT_NAME_PLACEHOLDER = "__PROJECT_NAME__" ;
424
426
425
- }
427
+ constructor ( private $childProcess : IChildProcess ,
428
+ private $projectData : IProjectData ,
429
+ private $fs : IFileSystem ,
430
+ private $errors : IErrors ) { }
431
+
432
+ public validate ( ) : void { }
426
433
427
434
public checkRequirements ( ) : IFuture < void > {
428
435
return ( ( ) => {
436
+ try {
437
+ this . $childProcess . exec ( "which xcodebuild" ) . wait ( ) ;
438
+ } catch ( error ) {
439
+ this . $errors . fail ( "The command 'which xcodebuild' failed. Make sure you have the Xcode installed" ) ;
440
+ }
429
441
} ) . future < void > ( ) ( ) ;
430
442
}
431
443
432
- public interpolateData ( ) : void {
444
+ public interpolateData ( projectRoot : string ) : IFuture < void > {
445
+ return ( ( ) => {
446
+ this . replaceFileName ( "-Info.plist" , projectRoot ) . wait ( ) ;
447
+ this . replaceFileName ( "-Prefix.pch" , projectRoot ) . wait ( ) ;
448
+ this . replaceFileName ( ".xcodeproj" , this . $projectData . platformsDir ) . wait ( ) ;
433
449
434
- }
450
+ /* this.$fs.rename(path.join(this.$projectData.platformsDir, IOSProjectService.PROJECT_NAME_PLACEHOLDER + ".xcodeproj"),
451
+ path.join(this.$projectData.platformsDir, this.$projectData.projectName + ".xcodeproj")).wait(); */
435
452
436
- public executePlatformSpecificAction ( ) : void {
453
+ var pbxprojFilePath = path . join ( this . $projectData . platformsDir , this . $projectData . projectName + ".xcodeproj" , "project.pbxproj" ) ;
454
+ this . replaceFileContent ( pbxprojFilePath ) . wait ( ) ;
455
+ } ) . future < void > ( ) ( ) ;
456
+ }
437
457
458
+ public createProject ( projectRoot : string , frameworkDir : string ) : IFuture < void > {
459
+ return ( ( ) => {
460
+ shell . cp ( "-r" , path . join ( frameworkDir , "*" ) , this . $projectData . platformsDir ) ;
461
+ this . $fs . rename ( path . join ( this . $projectData . platformsDir , IOSProjectService . PROJECT_NAME_PLACEHOLDER ) , projectRoot ) . wait ( ) ;
462
+ } ) . future < void > ( ) ( ) ;
438
463
}
439
464
440
- public createProject ( ) : IFuture < void > {
465
+ public buildProject ( projectRoot : string ) : IFuture < void > {
441
466
return ( ( ) => {
467
+ var args = [
468
+ "-project" , path . join ( this . $projectData . platformsDir , "ios" , this . $projectData . projectName + ".xcodeproj" ) ,
469
+ "-target" , this . $projectData . projectName ,
470
+ "-configuration" , options . release || "Debug" ,
471
+ "-sdk" , "iphonesimulator" ,
472
+ "build" ,
473
+ "ARCHS=\"armv7 armv7s arm64\"" ,
474
+ "VALID_ARCHS=\"armv7 armv7s arm64\"" ,
475
+ "CONFIGURATION_BUILD_DIR=" + path . join ( projectRoot , "build" ) + ""
476
+ ] ;
477
+ this . $childProcess . spawn ( "xcodebuild" , args , { cwd : options , stdio : 'inherit' } ) ;
478
+ } ) . future < void > ( ) ( ) ;
479
+ }
442
480
443
- } ) . future < any > ( ) ( ) ;
481
+ public executePlatformSpecificAction ( projectRoot : string , frameworkDir : string ) : void {
482
+
483
+ }
484
+
485
+ private replaceFileContent ( file : string ) : IFuture < void > {
486
+ return ( ( ) => {
487
+ var fileContent = this . $fs . readText ( file ) . wait ( ) ;
488
+ var replacedContent = helpers . stringReplaceAll ( fileContent , IOSProjectService . PROJECT_NAME_PLACEHOLDER , this . $projectData . projectName ) ;
489
+ this . $fs . writeFile ( file , replacedContent ) . wait ( ) ;
490
+ } ) . future < void > ( ) ( ) ;
444
491
}
445
492
446
- public buildProject ( ) : IFuture < void > {
493
+ private replaceFileName ( fileNamePart : string , projectRoot : string ) : IFuture < void > {
447
494
return ( ( ) => {
495
+ var oldFileName = IOSProjectService . PROJECT_NAME_PLACEHOLDER + fileNamePart ;
496
+ var newFileName = this . $projectData . projectName + fileNamePart ;
448
497
498
+ this . $fs . rename ( path . join ( projectRoot , oldFileName ) , path . join ( projectRoot , newFileName ) ) . wait ( ) ;
449
499
} ) . future < void > ( ) ( ) ;
450
500
}
451
501
}
0 commit comments