11import * as path from "path" ;
22
3- export enum BuildNames {
4- debug = "Debug" ,
5- release = "Release"
6- }
7-
8- export interface IXcodeTargetBuildConfigurationProperty {
9- name : string ;
10- value : any ;
11- buildNames ?: BuildNames [ ] ;
12- }
13-
14- export abstract class NativeTargetServiceBase {
3+ export class IOSNativeTargetService implements IIOSNativeTargetService {
154 constructor ( protected $fs : IFileSystem ,
16- protected $pbxprojDomXcode : IPbxprojDomXcode ,
17- protected $xcode : IXcode ) {
5+ protected $pbxprojDomXcode : IPbxprojDomXcode ) {
186 }
197
20- protected addTargetToProject ( extensionsFolderPath : string , extensionFolder : string , targetType : string , project : IXcode . project , platformData : IPlatformData , parentTarget ?: string ) : IXcode . target {
21- const extensionPath = path . join ( extensionsFolderPath , extensionFolder ) ;
22- const extensionRelativePath = path . relative ( platformData . projectRoot , extensionPath ) ;
23- const files = this . $fs . readDirectory ( extensionPath )
8+ public addTargetToProject ( targetRootPath : string , targetFolder : string , targetType : string , project : IXcode . project , platformData : IPlatformData , parentTarget ?: string ) : IXcode . target {
9+ const targetPath = path . join ( targetRootPath , targetFolder ) ;
10+ const targetRelativePath = path . relative ( platformData . projectRoot , targetPath ) ;
11+ const files = this . $fs . readDirectory ( targetPath )
2412 . filter ( filePath => ! filePath . startsWith ( "." ) )
25- . map ( filePath => path . join ( extensionPath , filePath ) ) ;
26- const target = project . addTarget ( extensionFolder , targetType , extensionRelativePath , parentTarget ) ;
13+ . map ( filePath => path . join ( targetPath , filePath ) ) ;
14+ const target = project . addTarget ( targetFolder , targetType , targetRelativePath , parentTarget ) ;
2715 project . addBuildPhase ( [ ] , 'PBXSourcesBuildPhase' , 'Sources' , target . uuid ) ;
2816 project . addBuildPhase ( [ ] , 'PBXResourcesBuildPhase' , 'Resources' , target . uuid ) ;
2917 project . addBuildPhase ( [ ] , 'PBXFrameworksBuildPhase' , 'Frameworks' , target . uuid ) ;
3018
31- project . addPbxGroup ( files , extensionFolder , extensionPath , null , { isMain : true , target : target . uuid , filesRelativeToProject : true } ) ;
32- project . addToHeaderSearchPaths ( extensionPath , target . pbxNativeTarget . productName ) ;
19+ project . addPbxGroup ( files , targetFolder , targetPath , null , { isMain : true , target : target . uuid , filesRelativeToProject : true } ) ;
20+ project . addToHeaderSearchPaths ( targetPath , target . pbxNativeTarget . productName ) ;
3321 return target ;
3422 }
3523
36- protected prepareSigning ( targetUuids : string [ ] , projectData :IProjectData , projectPath : string ) {
24+ public prepareSigning ( targetUuids : string [ ] , projectData : IProjectData , projectPath : string ) : void {
3725 const xcode = this . $pbxprojDomXcode . Xcode . open ( projectPath ) ;
3826 const signing = xcode . getSigning ( projectData . projectName ) ;
3927 if ( signing !== undefined ) {
@@ -52,7 +40,7 @@ export abstract class NativeTargetServiceBase {
5240 xcode . save ( ) ;
5341 }
5442
55- protected getTargetDirectories ( folderPath : string ) : string [ ] {
43+ public getTargetDirectories ( folderPath : string ) : string [ ] {
5644 return this . $fs . readDirectory ( folderPath )
5745 . filter ( fileName => {
5846 const filePath = path . join ( folderPath , fileName ) ;
@@ -62,7 +50,7 @@ export abstract class NativeTargetServiceBase {
6250 } ) ;
6351 }
6452
65- protected setXcodeTargetBuildConfigurationProperties ( properties : IXcodeTargetBuildConfigurationProperty [ ] , targetName : string , project : IXcode . project ) : void {
53+ public setXcodeTargetBuildConfigurationProperties ( properties : IXcodeTargetBuildConfigurationProperty [ ] , targetName : string , project : IXcode . project ) : void {
6654 properties . forEach ( property => {
6755 const buildNames = property . buildNames || [ BuildNames . debug , BuildNames . release ] ;
6856 buildNames . forEach ( ( buildName ) => {
@@ -71,7 +59,7 @@ export abstract class NativeTargetServiceBase {
7159 } ) ;
7260 }
7361
74- protected setConfigurationsFromJsonFile ( jsonPath : string , targetUuid : string , targetName : string , project : IXcode . project ) {
62+ public setConfigurationsFromJsonFile ( jsonPath : string , targetUuid : string , targetName : string , project : IXcode . project ) : void {
7563 if ( this . $fs . exists ( jsonPath ) ) {
7664 const configurationJson = this . $fs . readJson ( jsonPath ) || { } ;
7765
@@ -94,3 +82,5 @@ export abstract class NativeTargetServiceBase {
9482 }
9583 }
9684}
85+
86+ $injector . register ( "iOSNativeTargetService" , IOSNativeTargetService ) ;
0 commit comments