cordova-ios icon indicating copy to clipboard operation
cordova-ios copied to clipboard

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

Open leogoesger opened this issue 5 years ago • 47 comments

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

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

leogoesger avatar Jan 10 '20 21:01 leogoesger

Checking in again, if someone has taken a look at this issue yet. OR am I doing something wrong here?

leogoesger avatar Jan 13 '20 20:01 leogoesger

Thanks. I personally don't understand your proposed fix very well since I generally build iOS from Xcode.

A PR with tests would be much easier for us to review and integrate.

Unfortunately maintainers are a bit overloaded. I highly recommend that you follow up with us on Slack or mailing list, find contact from footer of cordova.io or cordova.apache.org.

brody4hire avatar Jan 13 '20 20:01 brody4hire

@brodybits

Basically, after adding extension in xcode, in our case we need OneSignal, so we name it OneSignal. plist_file_entry should return the plist file for the project, but instead it returns the path of OneSignal. For some reason it is not finding the correct folder path.

The error is in here, it does not return what it intends to after you add an extension.

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

leogoesger avatar Jan 13 '20 21:01 leogoesger

I know this error from a pretty complex app with two extensions. I did not investigate that, yet and would love to see this fixed.

If you find something,please create a pull request. I may look at this deeper, later.

NiklasMerz avatar Jan 14 '20 07:01 NiklasMerz

If I run cordova run ios --verbose, I get this stacktrace which might help

Need to update build settings because project is using our launch storyboard.
Could not parse /Users/me/path/platforms/ios/MyApp.xcodeproj/project.pbxproj: Could not find *-Info.plist file, or config.xml file.
CordovaError: Could not parse /Users/me/path/platforms/ios/MyApp.xcodeproj/project.pbxproj: Could not find *-Info.plist file, or config.xml file.
    at handleBuildSettings (/Users/me/path/platforms/ios/cordova/lib/prepare.js:333:25)
    at updateProject (/Users/me/path/platforms/ios/cordova/lib/prepare.js:228:12)
    at /Users/me/path/platforms/ios/cordova/lib/prepare.js:56:21
    at _fulfilled (/Users/me/path/node_modules/q/q.js:854:54)
    at /Users/me/path/node_modules/q/q.js:883:30
    at Promise.promise.promiseDispatch (/Users/me/path/node_modules/q/q.js:816:13)
    at /Users/me/path/node_modules/q/q.js:570:49
    at runSingle (/Users/me/path/node_modules/q/q.js:137:13)
    at flush (/Users/me/path/node_modules/q/q.js:125:13)
    at processTicksAndRejections (internal/process/task_queues.js:76:11)

I am trying the fix and try to understand the history of this bug.

NiklasMerz avatar Jan 14 '20 07:01 NiklasMerz

Your proposed fix works for my app in question! I am checking the PR.

NiklasMerz avatar Jan 14 '20 09:01 NiklasMerz

Sorry for spamming this issue. I was trying this code in our fork.

NiklasMerz avatar Jan 14 '20 15:01 NiklasMerz

https://github.com/apache/cordova-ios/pull/765

leogoesger avatar Jan 16 '20 20:01 leogoesger

@leogoesger thank you, your fix work for me .

jj449 avatar Feb 05 '20 07:02 jj449

@NiklasMerz any update on this?

leogoesger avatar Feb 13 '20 06:02 leogoesger

Plese check the reviews in #765

NiklasMerz avatar Feb 13 '20 07:02 NiklasMerz

@NiklasMerz any update on this?

@leogoesger There are some reviews now. Would you like to address them?

NiklasMerz avatar Feb 14 '20 10:02 NiklasMerz

#795

leogoesger avatar Feb 20 '20 15:02 leogoesger

This isn't merged in 6.0.0?

leogoesger avatar Jun 05 '20 17:06 leogoesger

My apologies, I missed this when 6.0.0 release was discussed on the mailing list. I just moved PR #795 to the 7.0.0 milestone.

brody4hire avatar Jun 05 '20 19:06 brody4hire

I wonder if this may be fixed by apache/cordova-common#148

brody4hire avatar Jun 16 '20 15:06 brody4hire

I tested 6.0, not fixed currently.

leogoesger avatar Jun 17 '20 17:06 leogoesger

+1 having the same issue with oneSignal extension, patch would be nice

GalacticWeb avatar Jul 02 '20 12:07 GalacticWeb

Any idea of the merge date ? Is there any workaround, waiting for it ? Thanks for your work ;)

nicozenf avatar Aug 05 '20 09:08 nicozenf

Unfortunately PR #795 did not go as smoothly as I had hoped and expected. When I made PR #795, I was able to start with some test preparations, include the changes directly from contribution in PR #765, and make some more updates. I did request reviews from GitHub but they never happened. There are now some conflicts that would necessitate a bit of rework, and I have very limited time due to some other priorities. My apologies.

brody4hire avatar Aug 05 '20 15:08 brody4hire

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)
  );
});

leogoesger avatar Aug 05 '20 17:08 leogoesger

@brodybits Ok, i understand, thank you for you answer and your work on this project ;)

@leogoesger Your workaround works perfectly, thank you so much !

nicozenf avatar Aug 06 '20 11:08 nicozenf

@leogoesger Thanks. That's the solution. I suggest a stronger condition. To change the:

entry.buildSettings.INFOPLIST_FILE.includes(projectName)

to:

entry.buildSettings.INFOPLIST_FILE.includes(projectName+'-Info.plist')

As the extension name can also includes the project name. Like "MyprojectWidget", it will create the Info.plist file also.

zhangv avatar Oct 28 '20 12:10 zhangv

We are using Cordova 9.0 Cordova iOS: 6.1.0 Xcode: 11.3.1

After adding watch app extension to my existing iOS mobile app. getting below error.

CordovaError: Could not parse /Users/pblrmac/Desktop/Eswar_Watch/watch_With_Notifications/working/myapp_watch_working_Bak/platforms/ios/myapp.xcodeproj/project.pbxproj: CordovaError: *Could not find -Info.plist file, or config.xml file. at handleBuildSettings (/Users/pblrmac/Desktop/Eswar_Watch/watch_With_Notifications/working/myapp_watch_working_Bak/platforms/ios/cordova/lib/prepare.js:279:31) at updateProject (/Users/pblrmac/Desktop/Eswar_Watch/watch_With_Notifications/working/myapp_watch_working_Bak/platforms/ios/cordova/lib/prepare.js:226:12) at updateWww.then (/Users/pblrmac/Desktop/Eswar_Watch/watch_With_Notifications/working/myapp_watch_working_Bak/platforms/ios/cordova/lib/prepare.js:50:21) at process._tickCallback (internal/process/next_tick.js:68:7) at Function.Module.runMain (internal/modules/cjs/loader.js:757:11) at startup (internal/bootstrap/node.js:283:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

To fix this issue, as @leogoesger mentioned I have added following code. This issue got resolved. But I am facing another issue when I run cordova build iOS command (log added below).

Could you help me in resolving following issue?

@leogoesger suggested code:

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) ); });

New issue after adding @leogoesger code:

Running command: xcodebuild -workspace myapp.xcworkspace -scheme myapp-configuration Debug -sdk iphonesimulator -destination platform=iOS Simulator,name=iPhone 11 Pro Max build CONFIGURATION_BUILD_DIR=/Users/pblrmac/Desktop/Eswar_Watch/watch_With_Notifications/myapp_watch_working_Bak/platforms/ios/build/emulator SHARED_PRECOMPS_DIR=/Users/pblrmac/Desktop/Eswar_Watch/watch_With_Notifications/myapp_watch_working_Bak/platforms/ios/build/sharedpch Build settings from command line: CONFIGURATION_BUILD_DIR = /Users/pblrmac/Desktop/Eswar_Watch/watch_With_Notifications/myapp_watch_working_Bak/platforms/ios/build/emulator SDKROOT = iphonesimulator13.2 SHARED_PRECOMPS_DIR = /Users/pblrmac/Desktop/Eswar_Watch/watch_With_Notifications/myapp_watch_working_Bak/platforms/ios/build/sharedpch

note: Using new build system note: Planning build note: Constructing build description error: unable to resolve product type 'com.apple.product-type.watchkit2-extension' for platform 'iphonesimulator' (in target 'myapp Extension' from project 'myapp') error: unable to resolve product type 'com.apple.product-type.watchkit2-extension' for platform 'iphonesimulator' (in target 'myapp Extension' from project 'myapp') error: unable to resolve product type 'com.apple.product-type.application.watchapp2' for platform 'iphonesimulator' (in target 'myapp' from project 'myapp') error: unable to resolve product type 'com.apple.product-type.application.watchapp2' for platform 'iphonesimulator' (in target 'myapp' from project 'myapp')

** BUILD FAILED **

Command finished with error code 65: xcodebuild -workspace,myapp.xcworkspace,-scheme,myapp,-configuration,Debug,-sdk,iphonesimulator,-destination,platform=iOS Simulator,name=iPhone 11 Pro Max,build,CONFIGURATION_BUILD_DIR=/Users/pblrmac/Desktop/Eswar_Watch/watch_With_Notifications/myapp_watch_working_Bak/platforms/ios/build/emulator,SHARED_PRECOMPS_DIR=/Users/pblrmac/Desktop/Eswar_Watch/watch_With_Notifications/myapp_watch_working_Bak/platforms/ios/build/sharedpch xcodebuild: Command failed with exit code 65 Error: xcodebuild: Command failed with exit code 65 at ChildProcess.whenDone (/Users/pblrmac/Desktop/Eswar_Watch/watch_With_Notifications/myapp_watch_working_Bak/node_modules/cordova-common/src/superspawn.js:136:25) at ChildProcess.emit (events.js:189:13) at maybeClose (internal/child_process.js:970:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)

eswarjk avatar Dec 29 '20 13:12 eswarjk

I am struggling to over come this issue. Any help on this issue is very much appreciated.

ejonnadula avatar Jan 12 '21 11:01 ejonnadula

I got this error in august after adding a today extension, and the workaround by @leogoesger worked for me. I had to stop this project for a while, and when i resumed it, iOS 14 was released and i decided to eventually make a widget extension instead. I updated cordova-ios, i'm currently in 6.1.1. I don't have this problem anymore so don't need workaround anymore either. I guess it was fix by cordova-ios update, but i'm can't be sure, and may be someone can confirm that. Hope this help.

nicozenf avatar Jan 12 '21 12:01 nicozenf

@nicozenf thanks for your response. i have tried with cordova ios 6.1.1 as well but faced same issue. I am building watch app on macOS: Mojave (version:10.14.4) , Cordova 9.0 Cordova iOS: 6.1.0 and Xcode: 11.3.1. Do you think upgrading mac system ios to 14 will fix this issue.

ejonnadula avatar Jan 12 '21 13:01 ejonnadula

I am building watch app

I don't believe WatchOS supports the webkit sdk, so I don't think Cordova is going to work for you.

breautek avatar Jan 12 '21 13:01 breautek

My stack is the following : cordova 10.0 cordova-ios 6.1.1 xcode 12.3 Don't know if different cordova or xcode version can fix the problem but i assume the most up to date the better. I never tried to build watch app. As it's a build issue, i don't think update os can provide any help. @breautek if it's possible to make build a swift widget extension by the cordova build as i do, i guess it's possible to do the same for watch app, but it's a slightly different problem ;)

nicozenf avatar Jan 12 '21 13:01 nicozenf

@breautek Thanks for your quick reply, we already have a watch app which is included in existing ios app (built on cordova ios 4.5.5) now we have upgraded cordova ios from 4.5.5 to 6.1.0. After upgradation when we try to run cordova build ios command its throwing below error. error: unable to resolve product type 'com.apple.product-type.watchkit2-extension' for platform 'iphonesimulator' (in target 'myapp Extension' from project 'myapp').

after cordova ios 6.1.0 upgrade ios app and Watch app are working fine and able to share information in ios simulator. But when I run cordova build ios command its failing with above error.

ejonnadula avatar Jan 12 '21 13:01 ejonnadula