Skip to content

Commit 01e8be0

Browse files
Merge pull request #60 from telerik/vladimirov/fix-plist-parsing
Fix parsing of simulator plist files
2 parents 0f9709f + 91370b6 commit 01e8be0

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

lib/iphone-simulator-common.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import * as path from "path";
88
import * as os from "os";
99
import xcode = require("./xcode");
1010
let bplistParser = require("bplist-parser");
11+
let plist = require("plist");
1112
let osenv = require("osenv");
1213
let isDeviceLogOperationStarted = false;
1314
let pid: string;
@@ -26,10 +27,9 @@ export function getInstalledApplications(deviceId: string): IFuture<IApplication
2627
let applicationDirContents = fs.readdirSync(fullApplicationPath);
2728
let applicationName = _.find(applicationDirContents, fileName => path.extname(fileName) === ".app");
2829
let plistFilePath = path.join(fullApplicationPath, applicationName, "Info.plist");
29-
let applicationData = parseFile(plistFilePath).wait();
3030
result.push({
3131
guid: applicationGuid,
32-
appIdentifier: applicationData[0].CFBundleIdentifier,
32+
appIdentifier: getBundleIdentifier(plistFilePath).wait(),
3333
path: path.join(fullApplicationPath, applicationName)
3434
});
3535
}
@@ -96,4 +96,18 @@ function parseFile(plistFilePath: string): IFuture<any> {
9696
}
9797
});
9898
return future;
99+
}
100+
101+
function getBundleIdentifier(plistFilePath: string): IFuture<string> {
102+
return (() => {
103+
let plistData: any;
104+
try {
105+
plistData = parseFile(plistFilePath).wait()[0];
106+
} catch (err) {
107+
let content = fs.readFileSync(plistFilePath).toString();
108+
plistData = plist.parse(content);
109+
}
110+
111+
return plistData && plistData.CFBundleIdentifier;
112+
}).future<string>()();
99113
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ios-sim-portable",
3-
"version": "1.0.22",
3+
"version": "1.0.23",
44
"description": "",
55
"main": "./lib/ios-sim.js",
66
"scripts": {
@@ -32,6 +32,7 @@
3232
"lodash": "3.2.0",
3333
"nodobjc": "https://github.com/telerik/NodObjC/tarball/v2.0.0.1",
3434
"osenv": "0.1.3",
35+
"plist": "1.1.0",
3536
"yargs": "3.15.0"
3637
},
3738
"devDependencies": {

0 commit comments

Comments
 (0)