Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: Exclude empty entries from the list of system bundle identifiers #369

Merged
merged 1 commit into from
Jul 28, 2023
Merged
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
29 changes: 16 additions & 13 deletions lib/simulator-xcode-15.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,27 @@ class SimulatorXcode15 extends SimulatorXcode14 {
return this._systemAppBundleIds;
}

const appsRoot = path.resolve(_.trim(await this.simctl.getEnv('IPHONE_SIMULATOR_ROOT')), 'Applications');
const appsRoot = path.resolve(
_.trim(await this.simctl.getEnv('IPHONE_SIMULATOR_ROOT')),
mykola-mokhnach marked this conversation as resolved.
Show resolved Hide resolved
'Applications'
);
const fetchBundleId = async (appRoot) => {
const infoPlistPath = path.resolve(appRoot, 'Info.plist');
if (!(await fs.exists(infoPlistPath))) {
return '';
try {
const {stdout} = await exec('/usr/libexec/PlistBuddy', [
'-c', 'print CFBundleIdentifier', infoPlistPath
]);
return _.trim(stdout);
} catch (ign) {
return null;
}
const {stdout} = await exec('/usr/libexec/PlistBuddy', [
'-c', 'print CFBundleIdentifier', infoPlistPath
]);
return _.trim(stdout);
};
const allApps = (await fs.readdir(appsRoot))
.filter((x) => x.endsWith('.app'))
.map((x) => path.join(appsRoot, x));
this._systemAppBundleIds = new Set(await B.all(allApps.map(fetchBundleId)));
this._systemAppBundleIds = new Set(await B.all(
allApps.map(fetchBundleId).filter(Boolean)
));
return this._systemAppBundleIds;
}

Expand All @@ -44,11 +50,8 @@ class SimulatorXcode15 extends SimulatorXcode14 {
async isAppInstalled (bundleId) {
try {
const appContainer = await this.simctl.getAppContainer(bundleId);
if (!appContainer.endsWith('.app')) {
return false;
}
return await fs.exists(appContainer);
} catch (err) {
return appContainer.endsWith('.app') && await fs.exists(appContainer);
} catch (ign) {
// get_app_container subcommand fails for system applications,
// as well as the hidden appinfo command
return (await this._fetchSystemAppBundleIds()).has(bundleId);
Expand Down