@@ -5,6 +5,7 @@ import * as path from "path";
5
5
import * as shell from "shelljs" ;
6
6
import * as util from "util" ;
7
7
import * as os from "os" ;
8
+ import * as semver from "semver" ;
8
9
import * as xcode from "xcode" ;
9
10
import * as constants from "../constants" ;
10
11
import * as helpers from "../common/helpers" ;
@@ -28,7 +29,8 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
28
29
private $logger : ILogger ,
29
30
private $iOSEmulatorServices : Mobile . IEmulatorPlatformServices ,
30
31
private $options : IOptions ,
31
- private $injector : IInjector ) {
32
+ private $injector : IInjector ,
33
+ private $projectDataService : IProjectDataService ) {
32
34
super ( $fs ) ;
33
35
}
34
36
@@ -39,7 +41,6 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
39
41
frameworkPackageName : "tns-ios" ,
40
42
normalizedPlatformName : "iOS" ,
41
43
appDestinationDirectoryPath : path . join ( projectRoot , this . $projectData . projectName ) ,
42
- appResourcesDestinationDirectoryPath : path . join ( projectRoot , this . $projectData . projectName , "Resources" ) ,
43
44
platformProjectService : this ,
44
45
emulatorServices : this . $iOSEmulatorServices ,
45
46
projectRoot : projectRoot ,
@@ -61,6 +62,19 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
61
62
} ;
62
63
}
63
64
65
+ public getAppResourcesDestinationDirectoryPath ( ) : IFuture < string > {
66
+ return ( ( ) => {
67
+ this . $projectDataService . initialize ( this . $projectData . projectDir ) ;
68
+ let frameworkVersion = this . $projectDataService . getValue ( this . platformData . frameworkPackageName ) . wait ( ) [ "version" ] ;
69
+
70
+ if ( semver . lt ( frameworkVersion , "1.3.0" ) ) {
71
+ return path . join ( this . platformData . projectRoot , this . $projectData . projectName , "Resources" , "icons" ) ;
72
+ }
73
+
74
+ return path . join ( this . platformData . projectRoot , this . $projectData . projectName , "Resources" ) ;
75
+ } ) . future < string > ( ) ( ) ;
76
+ }
77
+
64
78
public validate ( ) : IFuture < void > {
65
79
return ( ( ) => {
66
80
try {
@@ -258,25 +272,27 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
258
272
this . $logger . trace ( "Images from Xcode project" ) ;
259
273
this . $logger . trace ( xcodeProjectImages ) ;
260
274
261
- let appResourcesImages = this . $fs . readDirectory ( this . platformData . appResourcesDestinationDirectoryPath ) . wait ( ) ;
275
+ let appResourcesImages = this . $fs . readDirectory ( this . getAppResourcesDestinationDirectoryPath ( ) . wait ( ) ) . wait ( ) ;
262
276
this . $logger . trace ( "Current images from App_Resources" ) ;
263
277
this . $logger . trace ( appResourcesImages ) ;
264
278
265
279
let imagesToAdd = _ . difference ( appResourcesImages , xcodeProjectImages ) ;
266
280
this . $logger . trace ( `New images to add into xcode project: ${ imagesToAdd . join ( ", " ) } ` ) ;
267
- _ . each ( imagesToAdd , image => project . addResourceFile ( path . relative ( this . platformData . projectRoot , path . join ( this . platformData . appResourcesDestinationDirectoryPath , image ) ) ) ) ;
281
+ _ . each ( imagesToAdd , image => project . addResourceFile ( path . relative ( this . platformData . projectRoot , path . join ( this . getAppResourcesDestinationDirectoryPath ( ) . wait ( ) , image ) ) ) ) ;
268
282
269
283
let imagesToRemove = _ . difference ( xcodeProjectImages , appResourcesImages ) ;
270
284
this . $logger . trace ( `Images to remove from xcode project: ${ imagesToRemove . join ( ", " ) } ` ) ;
271
- _ . each ( imagesToRemove , image => project . removeResourceFile ( path . join ( this . platformData . appResourcesDestinationDirectoryPath , image ) ) ) ;
285
+ _ . each ( imagesToRemove , image => project . removeResourceFile ( path . join ( this . getAppResourcesDestinationDirectoryPath ( ) . wait ( ) , image ) ) ) ;
272
286
273
287
this . savePbxProj ( project ) . wait ( ) ;
274
288
}
275
289
} ) . future < void > ( ) ( ) ;
276
290
}
277
291
278
292
public prepareAppResources ( appResourcesDirectoryPath : string ) : IFuture < void > {
279
- return this . $fs . deleteDirectory ( this . platformData . appResourcesDestinationDirectoryPath ) ;
293
+ return ( ( ) => {
294
+ this . $fs . deleteDirectory ( this . getAppResourcesDestinationDirectoryPath ( ) . wait ( ) ) . wait ( ) ;
295
+ } ) . future < void > ( ) ( ) ;
280
296
}
281
297
282
298
private get projectPodFilePath ( ) : string {
0 commit comments