You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2014/10/21 19:22:01 UTC

git commit: CB-7311 Fix xcode project manipulation on Windows host

Repository: cordova-lib
Updated Branches:
  refs/heads/master 64b236af5 -> fef0ee701


CB-7311 Fix xcode project manipulation on Windows host

When adding plugins on Windows, plugman will insert incorrect paths,
which also contain backslashes into the xcode project files. This breaks
builds of the iOS app in Xcode and requires manual editing of the
project file.

On all non-Windows platforms, where the path separator is already `/`,
the performed replace should be a noop, on Windows it fixes the paths in
the project file.

github: close #109


Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/fef0ee70
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/fef0ee70
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/fef0ee70

Branch: refs/heads/master
Commit: fef0ee701581c7dafc55dda207f1ec17e21bd644
Parents: 64b236a
Author: Oliver Salzburg <ol...@gmail.com>
Authored: Tue Oct 21 15:48:29 2014 +0200
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Tue Oct 21 13:20:58 2014 -0400

----------------------------------------------------------------------
 cordova-lib/src/plugman/platforms/ios.js | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/fef0ee70/cordova-lib/src/plugman/platforms/ios.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/platforms/ios.js b/cordova-lib/src/plugman/platforms/ios.js
index 49336fc..1b4a2a0 100644
--- a/cordova-lib/src/plugman/platforms/ios.js
+++ b/cordova-lib/src/plugman/platforms/ios.js
@@ -52,6 +52,7 @@ module.exports = {
             if (!fs.existsSync(srcFile)) throw new Error('cannot find "' + srcFile + '" ios <source-file>');
             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);
 
             if (is_framework) {
                 var weak = source_el.attrib['weak'];
@@ -72,6 +73,8 @@ module.exports = {
             var is_framework = source_el.attrib['framework'] && (source_el.attrib['framework'] == 'true' || source_el.attrib['framework'] === true);
 
             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);
@@ -93,7 +96,11 @@ module.exports = {
             var destFile = path.resolve(targetDir, path.basename(src));
             if (!fs.existsSync(srcFile)) throw new Error('cannot find "' + srcFile + '" ios <header-file>');
             if (fs.existsSync(destFile)) throw new Error('target destination "' + destFile + '" already exists');
-            project.xcode.addHeaderFile(path.join('Plugins', path.relative(project.plugins_dir, destFile)));
+            
+            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);
         },
@@ -101,7 +108,11 @@ 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));
-            project.xcode.removeHeaderFile(path.join('Plugins', path.relative(project.plugins_dir, destFile)));
+            
+            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){
                 shell.rm('-rf', targetDir);
@@ -220,3 +231,8 @@ function getRelativeDir(file) {
         return '';
     }
 }
+
+var pathSepFix = new RegExp(path.sep.replace(/\\/,'\\\\'),'g');
+function fixPathSep(file) {
+    return file.replace(pathSepFix, '/');
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org