@@ -5,6 +5,7 @@ import * as path from "path";
55import * as shell from "shelljs" ;
66import * as util from "util" ;
77import * as os from "os" ;
8+ import * as semver from "semver" ;
89import * as xcode from "xcode" ;
910import * as constants from "../constants" ;
1011import * as helpers from "../common/helpers" ;
@@ -28,7 +29,8 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
2829 private $logger : ILogger ,
2930 private $iOSEmulatorServices : Mobile . IEmulatorPlatformServices ,
3031 private $options : IOptions ,
31- private $injector : IInjector ) {
32+ private $injector : IInjector ,
33+ private $projectDataService : IProjectDataService ) {
3234 super ( $fs ) ;
3335 }
3436
@@ -39,7 +41,6 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
3941 frameworkPackageName : "tns-ios" ,
4042 normalizedPlatformName : "iOS" ,
4143 appDestinationDirectoryPath : path . join ( projectRoot , this . $projectData . projectName ) ,
42- appResourcesDestinationDirectoryPath : path . join ( projectRoot , this . $projectData . projectName , "Resources" ) ,
4344 platformProjectService : this ,
4445 emulatorServices : this . $iOSEmulatorServices ,
4546 projectRoot : projectRoot ,
@@ -61,6 +62,19 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
6162 } ;
6263 }
6364
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+
6478 public validate ( ) : IFuture < void > {
6579 return ( ( ) => {
6680 try {
@@ -258,25 +272,27 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
258272 this . $logger . trace ( "Images from Xcode project" ) ;
259273 this . $logger . trace ( xcodeProjectImages ) ;
260274
261- let appResourcesImages = this . $fs . readDirectory ( this . platformData . appResourcesDestinationDirectoryPath ) . wait ( ) ;
275+ let appResourcesImages = this . $fs . readDirectory ( this . getAppResourcesDestinationDirectoryPath ( ) . wait ( ) ) . wait ( ) ;
262276 this . $logger . trace ( "Current images from App_Resources" ) ;
263277 this . $logger . trace ( appResourcesImages ) ;
264278
265279 let imagesToAdd = _ . difference ( appResourcesImages , xcodeProjectImages ) ;
266280 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 ) ) ) ) ;
268282
269283 let imagesToRemove = _ . difference ( xcodeProjectImages , appResourcesImages ) ;
270284 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 ) ) ) ;
272286
273287 this . savePbxProj ( project ) . wait ( ) ;
274288 }
275289 } ) . future < void > ( ) ( ) ;
276290 }
277291
278292 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 > ( ) ( ) ;
280296 }
281297
282298 private get projectPodFilePath ( ) : string {
0 commit comments