diff --git a/README.md b/README.md index 02614db..3c68f81 100644 --- a/README.md +++ b/README.md @@ -33,4 +33,4 @@ Currently support the August 16 revision, more or less. ## License -Apache +Apache \ No newline at end of file diff --git a/package.json b/package.json index 7212103..8e1dd6e 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "ncp":"0.2.6", "mkdirp":"0.2.2", "xcode":"0.4.1", + "bplist-parser": "0.0.4", "plist":"git+https://github.com/joshfire/node-plist.git", "glob":"3.0.1" }, diff --git a/platforms/ios.js b/platforms/ios.js index 1b0fc7a..6f8da65 100644 --- a/platforms/ios.js +++ b/platforms/ios.js @@ -4,6 +4,7 @@ var path = require('path'), glob = require('glob'), xcode = require('xcode'), plist = require('plist'), + bplist = require('bplist-parser'), nCallbacks = require('../util/ncallbacks'), asyncCopy = require('../util/asyncCopy'), assetsDir = 'www'; // relative path to project's web assets @@ -30,6 +31,8 @@ exports.installPlugin = function (config, plugin, callback) { // grab and parse plist file glob(config.projectPath + '/**/{PhoneGap,Cordova}.plist', function (err, files) { + var pl; + if (!files.length) throw "does not appear to be a PhoneGap project"; files = files.filter(function (val) { @@ -39,11 +42,31 @@ exports.installPlugin = function (config, plugin, callback) { store.plistPath = files[0]; store.pluginsDir = path.resolve(files[0], '..', 'Plugins'); - plist.parseFile(store.plistPath, function (err, obj) { - store.plist = obj; - end(); + // determine if this is a binary or ascii plist and choose the parser + // NOTE: this is hopefully temporary, until TooTallNate can integrate + // binary plist parsing into his library + if(fileIsAscii( store.plistPath )) { + pl = plist; + } else { + pl = bplist; + } + + pl.parseFile(store.plistPath, function (err, obj) { + store.plist = obj; + end(); + }); }); - }); + } + + // detect if a file is ascii by looking for an octet with a val > 127 + function fileIsAscii(filename) { + // Read the file with no encoding for raw buffer access. + var buf = fs.readFileSync(filename); + // as soon as we hit an octet > 127, we prob have binary + for (var i=0, len=buf.length; i 127) { return false; } + } + return true; } function getRelativeDir(file) {