Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix error parsing plist_file_entry when adding extension in xcode #765

Closed
Closed
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
13 changes: 12 additions & 1 deletion bin/templates/scripts/cordova/lib/projectFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,19 @@ function parseProjectFile (locations) {
const xcodeproj = xcode.project(pbxPath);
xcodeproj.parseSync();

let projectName = '';
const workspaceCollection = fs.readdirSync(project_dir).find(d => d.includes('.xcworkspace'));
if (workspaceCollection) {
projectName = fs.readdirSync(project_dir).find(d => d.includes('.xcworkspace')).replace('.xcworkspace', '');
}
const xcBuildConfiguration = xcodeproj.pbxXCBuildConfigurationSection();
const plist_file_entry = _.find(xcBuildConfiguration, entry => entry.buildSettings && entry.buildSettings.INFOPLIST_FILE);
const plist_file_entry = _.find(xcBuildConfiguration, function (entry) {
return (
entry.buildSettings &&
entry.buildSettings.INFOPLIST_FILE &&
!(projectName && entry.buildSettings.INFOPLIST_FILE.includes(`${projectName}/${projectName}-Info.plist`))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be corrected (I got it wrong in my suggestion):

Suggested change
!(projectName && entry.buildSettings.INFOPLIST_FILE.includes(`${projectName}/${projectName}-Info.plist`))
!(projectName && !entry.buildSettings.INFOPLIST_FILE.includes(`${projectName}/${projectName}-Info.plist`))

or better yet:

Suggested change
!(projectName && entry.buildSettings.INFOPLIST_FILE.includes(`${projectName}/${projectName}-Info.plist`))
(!projectName ||
entry.buildSettings.INFOPLIST_FILE.includes(`${projectName}/${projectName}-Info.plist`))

);
});
const plist_file = path.join(project_dir, plist_file_entry.buildSettings.INFOPLIST_FILE.replace(/^"(.*)"$/g, '$1').replace(/\\&/g, '&'));
const config_file = path.join(path.dirname(plist_file), 'config.xml');

Expand Down
Loading