cordova-ios: could not find -Info.plist file, or config.xml file after adding extension, cordova build, with FIX

Bug Report

I have included the fix on the bottom. I am pretty new at Cordova, someone else should take a look.

Problem

Cannot find *-info.plist or config.xml error when adding extension in Xcode. In a new cordova repo. After an extension is installed, depends on how you name the extension in Xcode, it will trigger a build error when running cordova build ios

How to reproduce

  1. Start a fresh repo
  2. Run all the cordova install, build commands
  3. Open xcode, add extension, name it OneTwoThree
  4. Run cordova build
  5. Throws here

How did we solve it

In ios/cordova/lib/projectFile.js, we found this.

var xcBuildConfiguration = xcodeproj.pbxXCBuildConfigurationSection();
  var plist_file_entry = _.find(xcBuildConfiguration, function(entry) {
    return entry.buildSettings && entry.buildSettings.INFOPLIST_FILE;
  });

Log plist_file_entry returns the path of the OneTwoThree extension, instead of the project path.

We fixed it by adding one more condition, it basically search through that path, and find your project name by finding a file name ending with .xcworkspace. Not sure how reliable is this.

var projectName = fs
    .readdirSync(project_dir)
    .find(d => d.includes(".xcworkspace"))
    .replace(".xcworkspace", "");

 var xcBuildConfiguration = xcodeproj.pbxXCBuildConfigurationSection();
 var plist_file_entry = _.find(xcBuildConfiguration, function(entry) {
    return (
      entry.buildSettings &&
      entry.buildSettings.INFOPLIST_FILE &&
      entry.buildSettings.INFOPLIST_FILE.includes(projectName)
    );
 });

Environment, Platform, Device

IOS

Version information

Latest

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 5
  • Comments: 46 (13 by maintainers)

Commits related to this issue

Most upvoted comments

If anyone need a quick fix, this is what worked for us. I submitted a PR a long time ago, I think everyone got busy.

ios/cordova/lib/projectFile.js, manually modify those. replace, around 43, after prettier

  var xcBuildConfiguration = xcodeproj.pbxXCBuildConfigurationSection();
  var plist_file_entry = _.find(xcBuildConfiguration, function(entry) {
    return entry.buildSettings && entry.buildSettings.INFOPLIST_FILE;
  });

with

var projectName = fs
    .readdirSync(project_dir)
    .find(d => d.includes(".xcworkspace"))
    .replace(".xcworkspace", "");

var xcBuildConfiguration = xcodeproj.pbxXCBuildConfigurationSection();
var plist_file_entry = _.find(xcBuildConfiguration, function(entry) {
  return (
    entry.buildSettings &&
    entry.buildSettings.INFOPLIST_FILE &&
    entry.buildSettings.INFOPLIST_FILE.includes(projectName)
  );
});

This is still a major nasty BUG. Unable to even add a plugin if we have an extension on the project. The workaround above works ok