@@ -11,6 +11,7 @@ import * as constants from "../constants";
11
11
import * as helpers from "../common/helpers" ;
12
12
import * as projectServiceBaseLib from "./platform-project-service-base" ;
13
13
import Future = require( "fibers/future" ) ;
14
+ import { PlistSession } from "plist-merge-patch" ;
14
15
15
16
export class IOSProjectService extends projectServiceBaseLib . PlatformProjectServiceBase implements IPlatformProjectService {
16
17
private static XCODE_PROJECT_EXT_NAME = ".xcodeproj" ;
@@ -350,12 +351,75 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
350
351
351
352
public prepareAppResources ( appResourcesDirectoryPath : string ) : IFuture < void > {
352
353
return ( ( ) => {
354
+ let platformFolder = path . join ( appResourcesDirectoryPath , this . platformData . normalizedPlatformName ) ;
355
+ var filterFile = ( filename : string ) => this . $fs . deleteFile ( path . join ( platformFolder , filename ) ) . wait ( ) ;
356
+
357
+ // These got copied but are not actually resources. They should be rather filterd before the copy in the first place but anyway, let's just delete them here.
358
+ filterFile ( "Info.plist" ) ;
359
+ // filterFile("Podfile");
360
+ // filterFile("Entitlements.plist");
361
+
353
362
this . $fs . deleteDirectory ( this . getAppResourcesDestinationDirectoryPath ( ) . wait ( ) ) . wait ( ) ;
354
363
} ) . future < void > ( ) ( ) ;
355
364
}
356
365
357
366
public processConfigurationFilesFromAppResources ( ) : IFuture < void > {
358
- return Future . fromResult ( ) ;
367
+ return ( ( ) => {
368
+ this . mergeInfoPlists ( ) . wait ( ) ;
369
+ } ) . future < void > ( ) ( ) ;
370
+ }
371
+
372
+ private mergeInfoPlists ( ) : IFuture < void > {
373
+ return ( ( ) => {
374
+ let projectDir = this . $projectData . projectDir ;
375
+ let infoPlistPath = path . join ( projectDir , constants . APP_FOLDER_NAME , constants . APP_RESOURCES_FOLDER_NAME , this . platformData . normalizedPlatformName , "Info.plist" ) ;
376
+
377
+ if ( ! this . $fs . exists ( infoPlistPath ) . wait ( ) ) {
378
+ this . $logger . trace ( "Info.plist: No app/App_Resources/iOS/Info.plist found, falling back to pre-1.6.0 Info.plist behavior." ) ;
379
+ return ;
380
+ }
381
+
382
+ let session = new PlistSession ( { log : ( txt : string ) => this . $logger . trace ( "Info.plist: " + txt ) } ) ;
383
+ let makePatch = ( plistPath : string ) => {
384
+ if ( ! this . $fs . exists ( plistPath ) . wait ( ) ) {
385
+ return ;
386
+ }
387
+
388
+ session . patch ( {
389
+ name : path . relative ( projectDir , plistPath ) ,
390
+ read : ( ) => this . $fs . readFile ( plistPath ) . wait ( ) . toString ( )
391
+ } ) ;
392
+ }
393
+
394
+ let allPlugins : IPluginData [ ] = ( < IPluginsService > this . $injector . resolve ( "pluginsService" ) ) . getAllInstalledPlugins ( ) . wait ( ) ;
395
+ for ( let plugin of allPlugins ) {
396
+ let pluginInfoPlistPath = path . join ( plugin . pluginPlatformsFolderPath ( IOSProjectService . IOS_PLATFORM_NAME ) , "Info.plist" ) ;
397
+ makePatch ( pluginInfoPlistPath ) ;
398
+ }
399
+
400
+ makePatch ( infoPlistPath ) ;
401
+
402
+ if ( this . $projectData . projectId ) {
403
+ session . patch ( {
404
+ name : "CFBundleIdentifier from package.json nativescript.id" ,
405
+ read : ( ) =>
406
+ `<?xml version="1.0" encoding="UTF-8"?>
407
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
408
+ <plist version="1.0">
409
+ <dict>
410
+ <key>CFBundleIdentifier</key>
411
+ <string>${ this . $projectData . projectId } </string>
412
+ </dict>
413
+ </plist>`
414
+ } ) ;
415
+ }
416
+
417
+ var plistContent = session . build ( ) ;
418
+
419
+ this . $logger . trace ( "Info.plist: Write to: " + this . platformData . configurationFilePath ) ;
420
+ this . $fs . writeFile ( this . platformData . configurationFilePath , plistContent ) . wait ( ) ;
421
+
422
+ } ) . future < void > ( ) ( ) ;
359
423
}
360
424
361
425
private get projectPodFilePath ( ) : string {
0 commit comments