@@ -3706,58 +3706,60 @@ var xcode = __webpack_require__(/*! xcode */ 5),
37063706 path = __webpack_require__ ( /*! path */ 0 ) ,
37073707 pjson = eval ( 'require(\'../../package.json\')' ) ,
37083708 iosFolder = path . join ( 'platforms' , 'ios' ) ,
3709- data = fs . readdirSync ( iosFolder ) ,
3709+ data = fs . existsSync ( iosFolder ) && fs . readdirSync ( iosFolder ) ,
37103710 projFolder ,
37113711 projName ;
37123712
37133713// Find the project folder by looking for *.xcodeproj
3714- if ( data && data . length ) {
3714+ if ( ! ( data && data . length ) ) {
3715+ console . log ( "platforms/ios does not exist, skip copying entitlements." ) ;
3716+ } else {
37153717 data . forEach ( function ( folder ) {
37163718 if ( folder . match ( / \. x c o d e p r o j $ / ) ) {
37173719 projFolder = path . join ( iosFolder , folder ) ;
37183720 projName = path . basename ( folder , '.xcodeproj' ) ;
37193721 }
37203722 } ) ;
3721- }
37223723
3723- if ( ! projFolder || ! projName ) {
3724- throw new Error ( "Could not find an .xcodeproj folder in: " + iosFolder ) ;
3725- }
3724+ if ( ! projFolder || ! projName ) {
3725+ throw new Error ( "Could not find an .xcodeproj folder in: " + iosFolder ) ;
3726+ }
37263727
3727- var destFolder = path . join ( iosFolder , projName , 'Resources' ) ;
3728- if ( ! fs . existsSync ( destFolder ) ) {
3729- fs . mkdirSync ( destFolder ) ;
3730- }
3728+ var destFolder = path . join ( iosFolder , projName , 'Resources' ) ;
3729+ if ( ! fs . existsSync ( destFolder ) ) {
3730+ fs . mkdirSync ( destFolder ) ;
3731+ }
37313732
3732- var destFile = path . join ( destFolder , projName + '.entitlements' ) ;
3733+ var destFile = path . join ( destFolder , projName + '.entitlements' ) ;
37333734
3734- if ( ! fs . existsSync ( destFile ) ) {
3735- var bundleID = pjson . nativescript . id ;
3735+ if ( ! fs . existsSync ( destFile ) ) {
3736+ var bundleID = pjson . nativescript . id ;
37363737
3737- // create a new entitlements plist file
3738- var sourceFile = path . join ( 'node_modules' , 'nativescript-plugin-firebase' , 'scripts' , 'resources' , 'KeychainSharing.entitlements' ) ;
3738+ // create a new entitlements plist file
3739+ var sourceFile = path . join ( 'node_modules' , 'nativescript-plugin-firebase' , 'scripts' , 'resources' , 'KeychainSharing.entitlements' ) ;
37393740
3740- var fileData = fs . readFileSync ( sourceFile ) . toString ( ) ;
3741- fileData = fileData . replace ( / _ _ K E Y C H A I N _ A C C E S S _ G R O U P _ _ / g, bundleID ) ;
3742- fs . writeFileSync ( destFile , fileData ) ;
3741+ var fileData = fs . readFileSync ( sourceFile ) . toString ( ) ;
3742+ fileData = fileData . replace ( / _ _ K E Y C H A I N _ A C C E S S _ G R O U P _ _ / g, bundleID ) ;
3743+ fs . writeFileSync ( destFile , fileData ) ;
37433744
3744- var projectPath = path . join ( projFolder , 'project.pbxproj' ) ,
3745- pbxProject = xcode . project ( projectPath ) ;
3745+ var projectPath = path . join ( projFolder , 'project.pbxproj' ) ,
3746+ pbxProject = xcode . project ( projectPath ) ;
37463747
3747- pbxProject . parseSync ( ) ;
3748- pbxProject . addResourceFile ( path . join ( projName , "Resources" , projName + ".entitlements" ) ) ;
3748+ pbxProject . parseSync ( ) ;
3749+ pbxProject . addResourceFile ( path . join ( projName , "Resources" , projName + ".entitlements" ) ) ;
37493750
37503751
3751- var configGroups = pbxProject . hash . project . objects [ 'XCBuildConfiguration' ] ;
3752- for ( var key in configGroups ) {
3753- var config = configGroups [ key ] ;
3754- if ( config . buildSettings !== undefined ) {
3755- config . buildSettings . CODE_SIGN_ENTITLEMENTS = '"' + projName + '/Resources/' + projName + '.entitlements"' ;
3752+ var configGroups = pbxProject . hash . project . objects [ 'XCBuildConfiguration' ] ;
3753+ for ( var key in configGroups ) {
3754+ var config = configGroups [ key ] ;
3755+ if ( config . buildSettings !== undefined ) {
3756+ config . buildSettings . CODE_SIGN_ENTITLEMENTS = '"' + projName + '/Resources/' + projName + '.entitlements"' ;
3757+ }
37563758 }
3757- }
37583759
3759- // write the updated project file
3760- fs . writeFileSync ( projectPath , pbxProject . writeSync ( ) ) ;
3760+ // write the updated project file
3761+ fs . writeFileSync ( projectPath , pbxProject . writeSync ( ) ) ;
3762+ }
37613763}
37623764
37633765
0 commit comments