Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ Currently support the August 16 revision, more or less.

## License

Apache
Apache
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
31 changes: 27 additions & 4 deletions platforms/ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand All @@ -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<len; i++) {
if (buf[i] > 127) { return false; }
}
return true;
}

function getRelativeDir(file) {
Expand Down