1
1
import * as path from "path" ;
2
2
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 {
15
4
constructor ( protected $fs : IFileSystem ,
16
- protected $pbxprojDomXcode : IPbxprojDomXcode ,
17
- protected $xcode : IXcode ) {
5
+ protected $pbxprojDomXcode : IPbxprojDomXcode ) {
18
6
}
19
7
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 )
24
12
. 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 ) ;
27
15
project . addBuildPhase ( [ ] , 'PBXSourcesBuildPhase' , 'Sources' , target . uuid ) ;
28
16
project . addBuildPhase ( [ ] , 'PBXResourcesBuildPhase' , 'Resources' , target . uuid ) ;
29
17
project . addBuildPhase ( [ ] , 'PBXFrameworksBuildPhase' , 'Frameworks' , target . uuid ) ;
30
18
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 ) ;
33
21
return target ;
34
22
}
35
23
36
- protected prepareSigning ( targetUuids : string [ ] , projectData :IProjectData , projectPath : string ) {
24
+ public prepareSigning ( targetUuids : string [ ] , projectData : IProjectData , projectPath : string ) : void {
37
25
const xcode = this . $pbxprojDomXcode . Xcode . open ( projectPath ) ;
38
26
const signing = xcode . getSigning ( projectData . projectName ) ;
39
27
if ( signing !== undefined ) {
@@ -52,7 +40,7 @@ export abstract class NativeTargetServiceBase {
52
40
xcode . save ( ) ;
53
41
}
54
42
55
- protected getTargetDirectories ( folderPath : string ) : string [ ] {
43
+ public getTargetDirectories ( folderPath : string ) : string [ ] {
56
44
return this . $fs . readDirectory ( folderPath )
57
45
. filter ( fileName => {
58
46
const filePath = path . join ( folderPath , fileName ) ;
@@ -62,7 +50,7 @@ export abstract class NativeTargetServiceBase {
62
50
} ) ;
63
51
}
64
52
65
- protected setXcodeTargetBuildConfigurationProperties ( properties : IXcodeTargetBuildConfigurationProperty [ ] , targetName : string , project : IXcode . project ) : void {
53
+ public setXcodeTargetBuildConfigurationProperties ( properties : IXcodeTargetBuildConfigurationProperty [ ] , targetName : string , project : IXcode . project ) : void {
66
54
properties . forEach ( property => {
67
55
const buildNames = property . buildNames || [ BuildNames . debug , BuildNames . release ] ;
68
56
buildNames . forEach ( ( buildName ) => {
@@ -71,7 +59,7 @@ export abstract class NativeTargetServiceBase {
71
59
} ) ;
72
60
}
73
61
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 {
75
63
if ( this . $fs . exists ( jsonPath ) ) {
76
64
const configurationJson = this . $fs . readJson ( jsonPath ) || { } ;
77
65
@@ -94,3 +82,5 @@ export abstract class NativeTargetServiceBase {
94
82
}
95
83
}
96
84
}
85
+
86
+ $injector . register ( "iOSNativeTargetService" , IOSNativeTargetService ) ;
0 commit comments