From f93217c094473daf08e42b07a2fb43a64d37ebc5 Mon Sep 17 00:00:00 2001 From: Dimitar Kerezov Date: Tue, 20 Jan 2015 16:44:52 +0200 Subject: [PATCH] CB-5696 find ios project directory using the xcode project file Add unit tests for future reassurance Fix incorrect name "ChildApp" in .pbxproj files to "SampleApp" Related to https://issues.apache.org/jira/browse/CB-5696 --- .../spec-plugman/platforms/ios.spec.js | 32 +++++++++++++- .../SampleApp.xcodeproj/project.pbxproj | 44 +++++++++---------- .../SampleApp.xcodeproj/project.pbxproj | 44 +++++++++---------- cordova-lib/src/plugman/platforms/ios.js | 31 ++++++------- 4 files changed, 88 insertions(+), 63 deletions(-) diff --git a/cordova-lib/spec-plugman/platforms/ios.spec.js b/cordova-lib/spec-plugman/platforms/ios.spec.js index fd0182fa5..1e94a043b 100644 --- a/cordova-lib/spec-plugman/platforms/ios.spec.js +++ b/cordova-lib/spec-plugman/platforms/ios.spec.js @@ -120,13 +120,41 @@ describe('ios project handler', function() { ios.parseProjectFile(temp); }).toThrow('does not appear to be an xcode project (no xcode project file)'); }); - it('should throw if project does not contain an appropriate PhoneGap/Cordova.plist file or config.xml file', function() { + it('should throw if project does not contain an appropriate config.xml file', function() { shell.cp('-rf', ios_config_xml_project, temp); shell.rm(path.join(temp, 'SampleApp', 'config.xml')); expect(function() { ios.parseProjectFile(temp); - }).toThrow('could not find PhoneGap/Cordova plist file, or config.xml file.'); + }).toThrow('could not find -Info.plist file, or config.xml file.'); + }); + it('should throw if project does not contain an appropriate -Info.plist file', function() { + shell.cp('-rf', ios_config_xml_project, temp); + shell.rm(path.join(temp, 'SampleApp', 'SampleApp-Info.plist')); + + expect(function () { + ios.parseProjectFile(temp); + }).toThrow('could not find -Info.plist file, or config.xml file.'); + }); + it('should return right directory when multiple .plist files are present', function() { + shell.cp('-rf', ios_config_xml_project, temp); + //Create a folder named A with config.xml and .plist files in it + var pathToFolderA = path.join(temp, 'A'); + shell.mkdir(pathToFolderA); + shell.cp('-rf', path.join(temp, 'SampleApp/*'), pathToFolderA); + + var parsedProjectFile = ios.parseProjectFile(temp); + var pluginsDir = parsedProjectFile.plugins_dir, + resourcesDir = parsedProjectFile.resources_dir, + xcodePath = parsedProjectFile.xcode_path; + + var pluginsDirParent = path.dirname(pluginsDir), + resourcesDirParent = path.dirname(resourcesDir), + sampleAppDir = path.join(temp, 'SampleApp'); + + expect(pluginsDirParent).toEqual(sampleAppDir); + expect(resourcesDirParent).toEqual(sampleAppDir); + expect(xcodePath).toEqual(sampleAppDir); }); }); diff --git a/cordova-lib/spec-plugman/projects/ios-config-xml/SampleApp.xcodeproj/project.pbxproj b/cordova-lib/spec-plugman/projects/ios-config-xml/SampleApp.xcodeproj/project.pbxproj index 60f478f92..56304169c 100644 --- a/cordova-lib/spec-plugman/projects/ios-config-xml/SampleApp.xcodeproj/project.pbxproj +++ b/cordova-lib/spec-plugman/projects/ios-config-xml/SampleApp.xcodeproj/project.pbxproj @@ -39,7 +39,7 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 571A463B14DB0A1B007FEAC7 /* ChildApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ChildApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 571A463B14DB0A1B007FEAC7 /* SampleApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SampleApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; 571A463F14DB0A1B007FEAC7 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 571A464114DB0A1B007FEAC7 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 571A464314DB0A1B007FEAC7 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; @@ -53,10 +53,10 @@ 571A465314DB0A1B007FEAC7 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; 571A465514DB0A1B007FEAC7 /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = System/Library/Frameworks/MobileCoreServices.framework; sourceTree = SDKROOT; }; 571A465714DB0A1B007FEAC7 /* CoreMedia.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMedia.framework; path = System/Library/Frameworks/CoreMedia.framework; sourceTree = SDKROOT; }; - 571A465B14DB0A1B007FEAC7 /* ChildApp-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "ChildApp-Info.plist"; sourceTree = ""; }; + 571A465B14DB0A1B007FEAC7 /* SampleApp-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "SampleApp-Info.plist"; sourceTree = ""; }; 571A465D14DB0A1B007FEAC7 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 571A465F14DB0A1B007FEAC7 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; - 571A466114DB0A1B007FEAC7 /* ChildApp-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ChildApp-Prefix.pch"; sourceTree = ""; }; + 571A466114DB0A1B007FEAC7 /* SampleApp-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SampleApp-Prefix.pch"; sourceTree = ""; }; 571A466214DB0A1B007FEAC7 /* PhoneGap.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PhoneGap.framework; path = /Users/Shared/PhoneGap/Frameworks/PhoneGap.framework; sourceTree = ""; }; 571A466714DB0A1B007FEAC7 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = Resources/en.lproj/Localizable.strings; sourceTree = ""; }; 571A466B14DB0A1B007FEAC7 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = Resources/es.lproj/Localizable.strings; sourceTree = ""; }; @@ -112,7 +112,7 @@ isa = PBXGroup; children = ( 577FC36514DB0B620082BA7B /* www */, - 571A465914DB0A1B007FEAC7 /* ChildApp */, + 571A465914DB0A1B007FEAC7 /* SampleApp */, 571A463E14DB0A1B007FEAC7 /* Frameworks */, 571A463C14DB0A1B007FEAC7 /* Products */, ); @@ -121,7 +121,7 @@ 571A463C14DB0A1B007FEAC7 /* Products */ = { isa = PBXGroup; children = ( - 571A463B14DB0A1B007FEAC7 /* ChildApp.app */, + 571A463B14DB0A1B007FEAC7 /* SampleApp.app */, ); name = Products; sourceTree = ""; @@ -146,7 +146,7 @@ name = Frameworks; sourceTree = ""; }; - 571A465914DB0A1B007FEAC7 /* ChildApp */ = { + 571A465914DB0A1B007FEAC7 /* SampleApp */ = { isa = PBXGroup; children = ( 571A466214DB0A1B007FEAC7 /* PhoneGap.framework */, @@ -155,16 +155,16 @@ 571A468614DB0A1B007FEAC7 /* Plugins */, 571A465A14DB0A1B007FEAC7 /* Supporting Files */, ); - path = ChildApp; + path = SampleApp; sourceTree = ""; }; 571A465A14DB0A1B007FEAC7 /* Supporting Files */ = { isa = PBXGroup; children = ( - 571A465B14DB0A1B007FEAC7 /* ChildApp-Info.plist */, + 571A465B14DB0A1B007FEAC7 /* SampleApp-Info.plist */, 571A465C14DB0A1B007FEAC7 /* InfoPlist.strings */, 571A465F14DB0A1B007FEAC7 /* main.m */, - 571A466114DB0A1B007FEAC7 /* ChildApp-Prefix.pch */, + 571A466114DB0A1B007FEAC7 /* SampleApp-Prefix.pch */, 571A467B14DB0A1B007FEAC7 /* PhoneGap.plist */, 571A468414DB0A1B007FEAC7 /* MainViewController.xib */, ); @@ -240,9 +240,9 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ - 571A463A14DB0A1B007FEAC7 /* ChildApp */ = { + 571A463A14DB0A1B007FEAC7 /* SampleApp */ = { isa = PBXNativeTarget; - buildConfigurationList = 571A468A14DB0A1B007FEAC7 /* Build configuration list for PBXNativeTarget "ChildApp" */; + buildConfigurationList = 571A468A14DB0A1B007FEAC7 /* Build configuration list for PBXNativeTarget "SampleApp" */; buildPhases = ( 571A463414DB0A1B007FEAC7 /* Sources */, 571A463514DB0A1B007FEAC7 /* Frameworks */, @@ -255,9 +255,9 @@ ); dependencies = ( ); - name = ChildApp; - productName = ChildApp; - productReference = 571A463B14DB0A1B007FEAC7 /* ChildApp.app */; + name = SampleApp; + productName = SampleApp; + productReference = 571A463B14DB0A1B007FEAC7 /* SampleApp.app */; productType = "com.apple.product-type.application"; }; /* End PBXNativeTarget section */ @@ -268,7 +268,7 @@ attributes = { LastUpgradeCheck = 0420; }; - buildConfigurationList = 571A463214DB0A1A007FEAC7 /* Build configuration list for PBXProject "ChildApp" */; + buildConfigurationList = 571A463214DB0A1A007FEAC7 /* Build configuration list for PBXProject "SampleApp" */; compatibilityVersion = "Xcode 3.2"; developmentRegion = English; hasScannedForEncodings = 0; @@ -281,7 +281,7 @@ projectDirPath = ""; projectRoot = ""; targets = ( - 571A463A14DB0A1B007FEAC7 /* ChildApp */, + 571A463A14DB0A1B007FEAC7 /* SampleApp */, ); }; /* End PBXProject section */ @@ -423,9 +423,9 @@ COPY_PHASE_STRIP = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "ChildApp/ChildApp-Prefix.pch"; + GCC_PREFIX_HEADER = "SampleApp/SampleApp-Prefix.pch"; GCC_PREPROCESSOR_DEFINITIONS = "PHONEGAP_FRAMEWORK=YES"; - INFOPLIST_FILE = "ChildApp/ChildApp-Info.plist"; + INFOPLIST_FILE = "SampleApp/SampleApp-Info.plist"; OTHER_LDFLAGS = ( "-weak_framework", UIKit, @@ -449,9 +449,9 @@ COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "ChildApp/ChildApp-Prefix.pch"; + GCC_PREFIX_HEADER = "SampleApp/SampleApp-Prefix.pch"; GCC_PREPROCESSOR_DEFINITIONS = "PHONEGAP_FRAMEWORK=YES"; - INFOPLIST_FILE = "ChildApp/ChildApp-Info.plist"; + INFOPLIST_FILE = "SampleApp/SampleApp-Info.plist"; OTHER_LDFLAGS = ( "-weak_framework", UIKit, @@ -472,7 +472,7 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - 571A463214DB0A1A007FEAC7 /* Build configuration list for PBXProject "ChildApp" */ = { + 571A463214DB0A1A007FEAC7 /* Build configuration list for PBXProject "SampleApp" */ = { isa = XCConfigurationList; buildConfigurations = ( 571A468814DB0A1B007FEAC7 /* Debug */, @@ -481,7 +481,7 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 571A468A14DB0A1B007FEAC7 /* Build configuration list for PBXNativeTarget "ChildApp" */ = { + 571A468A14DB0A1B007FEAC7 /* Build configuration list for PBXNativeTarget "SampleApp" */ = { isa = XCConfigurationList; buildConfigurations = ( 571A468B14DB0A1B007FEAC7 /* Debug */, diff --git a/cordova-lib/spec-plugman/projects/ios-plist/SampleApp.xcodeproj/project.pbxproj b/cordova-lib/spec-plugman/projects/ios-plist/SampleApp.xcodeproj/project.pbxproj index a4d87f9b4..ebb755c34 100644 --- a/cordova-lib/spec-plugman/projects/ios-plist/SampleApp.xcodeproj/project.pbxproj +++ b/cordova-lib/spec-plugman/projects/ios-plist/SampleApp.xcodeproj/project.pbxproj @@ -39,7 +39,7 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 571A463B14DB0A1B007FEAC7 /* ChildApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ChildApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 571A463B14DB0A1B007FEAC7 /* SampleApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SampleApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; 571A463F14DB0A1B007FEAC7 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 571A464114DB0A1B007FEAC7 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 571A464314DB0A1B007FEAC7 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; @@ -53,10 +53,10 @@ 571A465314DB0A1B007FEAC7 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; 571A465514DB0A1B007FEAC7 /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = System/Library/Frameworks/MobileCoreServices.framework; sourceTree = SDKROOT; }; 571A465714DB0A1B007FEAC7 /* CoreMedia.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMedia.framework; path = System/Library/Frameworks/CoreMedia.framework; sourceTree = SDKROOT; }; - 571A465B14DB0A1B007FEAC7 /* ChildApp-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "ChildApp-Info.plist"; sourceTree = ""; }; + 571A465B14DB0A1B007FEAC7 /* SampleApp-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "SampleApp-Info.plist"; sourceTree = ""; }; 571A465D14DB0A1B007FEAC7 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 571A465F14DB0A1B007FEAC7 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; - 571A466114DB0A1B007FEAC7 /* ChildApp-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ChildApp-Prefix.pch"; sourceTree = ""; }; + 571A466114DB0A1B007FEAC7 /* SampleApp-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SampleApp-Prefix.pch"; sourceTree = ""; }; 571A466214DB0A1B007FEAC7 /* PhoneGap.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PhoneGap.framework; path = /Users/Shared/PhoneGap/Frameworks/PhoneGap.framework; sourceTree = ""; }; 571A466714DB0A1B007FEAC7 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = Resources/en.lproj/Localizable.strings; sourceTree = ""; }; 571A466B14DB0A1B007FEAC7 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = Resources/es.lproj/Localizable.strings; sourceTree = ""; }; @@ -112,7 +112,7 @@ isa = PBXGroup; children = ( 577FC36514DB0B620082BA7B /* www */, - 571A465914DB0A1B007FEAC7 /* ChildApp */, + 571A465914DB0A1B007FEAC7 /* SampleApp */, 571A463E14DB0A1B007FEAC7 /* Frameworks */, 571A463C14DB0A1B007FEAC7 /* Products */, ); @@ -121,7 +121,7 @@ 571A463C14DB0A1B007FEAC7 /* Products */ = { isa = PBXGroup; children = ( - 571A463B14DB0A1B007FEAC7 /* ChildApp.app */, + 571A463B14DB0A1B007FEAC7 /* SampleApp.app */, ); name = Products; sourceTree = ""; @@ -146,7 +146,7 @@ name = Frameworks; sourceTree = ""; }; - 571A465914DB0A1B007FEAC7 /* ChildApp */ = { + 571A465914DB0A1B007FEAC7 /* SampleApp */ = { isa = PBXGroup; children = ( 571A466214DB0A1B007FEAC7 /* PhoneGap.framework */, @@ -155,16 +155,16 @@ 571A468614DB0A1B007FEAC7 /* Plugins */, 571A465A14DB0A1B007FEAC7 /* Supporting Files */, ); - path = ChildApp; + path = SampleApp; sourceTree = ""; }; 571A465A14DB0A1B007FEAC7 /* Supporting Files */ = { isa = PBXGroup; children = ( - 571A465B14DB0A1B007FEAC7 /* ChildApp-Info.plist */, + 571A465B14DB0A1B007FEAC7 /* SampleApp-Info.plist */, 571A465C14DB0A1B007FEAC7 /* InfoPlist.strings */, 571A465F14DB0A1B007FEAC7 /* main.m */, - 571A466114DB0A1B007FEAC7 /* ChildApp-Prefix.pch */, + 571A466114DB0A1B007FEAC7 /* SampleApp-Prefix.pch */, 571A467B14DB0A1B007FEAC7 /* PhoneGap.plist */, 571A468414DB0A1B007FEAC7 /* MainViewController.xib */, ); @@ -240,9 +240,9 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ - 571A463A14DB0A1B007FEAC7 /* ChildApp */ = { + 571A463A14DB0A1B007FEAC7 /* SampleApp */ = { isa = PBXNativeTarget; - buildConfigurationList = 571A468A14DB0A1B007FEAC7 /* Build configuration list for PBXNativeTarget "ChildApp" */; + buildConfigurationList = 571A468A14DB0A1B007FEAC7 /* Build configuration list for PBXNativeTarget "SampleApp" */; buildPhases = ( 571A463414DB0A1B007FEAC7 /* Sources */, 571A463514DB0A1B007FEAC7 /* Frameworks */, @@ -255,9 +255,9 @@ ); dependencies = ( ); - name = ChildApp; - productName = ChildApp; - productReference = 571A463B14DB0A1B007FEAC7 /* ChildApp.app */; + name = SampleApp; + productName = SampleApp; + productReference = 571A463B14DB0A1B007FEAC7 /* SampleApp.app */; productType = "com.apple.product-type.application"; }; /* End PBXNativeTarget section */ @@ -268,7 +268,7 @@ attributes = { LastUpgradeCheck = 0420; }; - buildConfigurationList = 571A463214DB0A1A007FEAC7 /* Build configuration list for PBXProject "ChildApp" */; + buildConfigurationList = 571A463214DB0A1A007FEAC7 /* Build configuration list for PBXProject "SampleApp" */; compatibilityVersion = "Xcode 3.2"; developmentRegion = English; hasScannedForEncodings = 0; @@ -281,7 +281,7 @@ projectDirPath = ""; projectRoot = ""; targets = ( - 571A463A14DB0A1B007FEAC7 /* ChildApp */, + 571A463A14DB0A1B007FEAC7 /* SampleApp */, ); }; /* End PBXProject section */ @@ -424,9 +424,9 @@ FRAMEWORK_SEARCH_PATHS = /Users/Shared/PhoneGap/Frameworks; GCC_DYNAMIC_NO_PIC = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "ChildApp/ChildApp-Prefix.pch"; + GCC_PREFIX_HEADER = "SampleApp/SampleApp-Prefix.pch"; GCC_PREPROCESSOR_DEFINITIONS = "PHONEGAP_FRAMEWORK=YES"; - INFOPLIST_FILE = "ChildApp/ChildApp-Info.plist"; + INFOPLIST_FILE = "SampleApp/SampleApp-Info.plist"; OTHER_LDFLAGS = ( "-weak_framework", UIKit, @@ -451,9 +451,9 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = /Users/Shared/PhoneGap/Frameworks; GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "ChildApp/ChildApp-Prefix.pch"; + GCC_PREFIX_HEADER = "SampleApp/SampleApp-Prefix.pch"; GCC_PREPROCESSOR_DEFINITIONS = "PHONEGAP_FRAMEWORK=YES"; - INFOPLIST_FILE = "ChildApp/ChildApp-Info.plist"; + INFOPLIST_FILE = "SampleApp/SampleApp-Info.plist"; OTHER_LDFLAGS = ( "-weak_framework", UIKit, @@ -474,7 +474,7 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - 571A463214DB0A1A007FEAC7 /* Build configuration list for PBXProject "ChildApp" */ = { + 571A463214DB0A1A007FEAC7 /* Build configuration list for PBXProject "SampleApp" */ = { isa = XCConfigurationList; buildConfigurations = ( 571A468814DB0A1B007FEAC7 /* Debug */, @@ -483,7 +483,7 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 571A468A14DB0A1B007FEAC7 /* Build configuration list for PBXNativeTarget "ChildApp" */ = { + 571A468A14DB0A1B007FEAC7 /* Build configuration list for PBXNativeTarget "SampleApp" */ = { isa = XCConfigurationList; buildConfigurations = ( 571A468B14DB0A1B007FEAC7 /* Debug */, diff --git a/cordova-lib/src/plugman/platforms/ios.js b/cordova-lib/src/plugman/platforms/ios.js index e67c3b345..955ca9e14 100644 --- a/cordova-lib/src/plugman/platforms/ios.js +++ b/cordova-lib/src/plugman/platforms/ios.js @@ -29,6 +29,8 @@ var path = require('path') , plist = require('plist') , shell = require('shelljs') , events = require('../../events') + , _ = require('underscore') + , CordovaError = require('../../CordovaError') , cachedProjectFiles = {} ; @@ -74,7 +76,7 @@ module.exports = { var project_ref = path.join('Plugins', path.relative(project.plugins_dir, destFile)); project_ref = fixPathSep(project_ref); - + project.xcode.removeSourceFile(project_ref); if (is_framework) { var project_relative = path.join(path.basename(project.xcode_path), project_ref); @@ -96,10 +98,10 @@ module.exports = { var destFile = path.resolve(targetDir, path.basename(src)); if (!fs.existsSync(srcFile)) throw new Error('cannot find "' + srcFile + '" ios '); if (fs.existsSync(destFile)) throw new Error('target destination "' + destFile + '" already exists'); - + var project_ref = path.join('Plugins', path.relative(project.plugins_dir, destFile)); project_ref = fixPathSep(project_ref); - + project.xcode.addHeaderFile(project_ref); shell.mkdir('-p', targetDir); shell.cp(srcFile, destFile); @@ -108,10 +110,10 @@ module.exports = { var src = header_el.attrib['src']; var targetDir = path.resolve(project.plugins_dir, plugin_id, getRelativeDir(header_el)); var destFile = path.resolve(targetDir, path.basename(src)); - + var project_ref = path.join('Plugins', path.relative(project.plugins_dir, destFile)); project_ref = fixPathSep(project_ref); - + project.xcode.removeHeaderFile(project_ref); shell.rm('-rf', destFile); if(fs.existsSync(targetDir) && fs.readdirSync(targetDir).length>0){ @@ -184,22 +186,17 @@ module.exports = { var xcodeproj = xcode.project(pbxPath); xcodeproj.parseSync(); - // grab and parse plist file or config.xml - var config_files = (glob.sync(path.join(project_dir, '**', '{PhoneGap,Cordova}.plist')).length === 0 ? - glob.sync(path.join(project_dir, '**', 'config.xml')) : - glob.sync(path.join(project_dir, '**', '{PhoneGap,Cordova}.plist')) - ); - config_files = config_files.filter(function (val) { - return !(/^build\//.test(val)) && !(/\/www\/config.xml$/.test(val)); - }); + var xcBuildConfiguration = xcodeproj.pbxXCBuildConfigurationSection(); + var plist_file_entry = _.find(xcBuildConfiguration, function (entry) { return entry.buildSettings && entry.buildSettings.INFOPLIST_FILE; }); + var plist_file = path.join(project_dir, plist_file_entry.buildSettings.INFOPLIST_FILE.replace(/^"(.*)"$/g, '$1')); + var config_file = path.join(path.dirname(plist_file), 'config.xml'); - if (config_files.length === 0) { - throw new Error('could not find PhoneGap/Cordova plist file, or config.xml file.'); + if (!fs.existsSync(plist_file) || !fs.existsSync(config_file)) { + throw new CordovaError('could not find -Info.plist file, or config.xml file.'); } - var config_file = config_files[0]; - var xcode_dir = path.dirname(config_file); + var xcode_dir = path.dirname(plist_file); var pluginsDir = path.resolve(xcode_dir, 'Plugins'); var resourcesDir = path.resolve(xcode_dir, 'Resources'); var cordovaVersion = fs.readFileSync(path.join(project_dir, 'CordovaLib', 'VERSION'), 'utf8').trim();