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

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

Closed
3 tasks done
leogoesger opened this issue Jan 10, 2020 · 47 comments · Fixed by #1485
Closed
3 tasks done

Comments

@leogoesger
Copy link

leogoesger commented Jan 10, 2020

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
@leogoesger
Copy link
Author

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

@leogoesger leogoesger changed the title could not find -Info.plist file, or config.xml file after adding extension, cordova build could not find -Info.plist file, or config.xml file after adding extension, cordova build, with FIX Jan 13, 2020
@brodycj brodycj added help wanted info-needed Further information is requested support labels Jan 13, 2020
@brodycj
Copy link
Contributor

brodycj commented Jan 13, 2020

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.

@leogoesger
Copy link
Author

leogoesger commented Jan 13, 2020

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

@NiklasMerz
Copy link
Member

NiklasMerz commented Jan 14, 2020

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
Copy link
Member

NiklasMerz commented Jan 14, 2020

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 added a commit to GEDYSIntraWare/cordova-ios that referenced this issue Jan 14, 2020
Fix "Could not parse *-info.plist or config.xml". Proposed fix, see apache#764

Co-Authored-By: Leo Qiu <leogoesger@users.noreply.github.com>
NiklasMerz added a commit to GEDYSIntraWare/cordova-ios that referenced this issue Jan 14, 2020
Fix "Could not parse *-info.plist or config.xml". Proposed fix, see apache#764

Co-Authored-By: Leo Qiu <leogoesger@users.noreply.github.com>
@NiklasMerz
Copy link
Member

NiklasMerz commented Jan 14, 2020

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

NiklasMerz added a commit to GEDYSIntraWare/cordova-ios that referenced this issue Jan 14, 2020
Fix "Could not parse *-info.plist or config.xml". Proposed fix, see apache#764

Co-Authored-By: Leo Qiu <leogoesger@users.noreply.github.com>
NiklasMerz added a commit to GEDYSIntraWare/cordova-ios that referenced this issue Jan 14, 2020
Fix "Could not parse *-info.plist or config.xml". Proposed fix, see apache#764

Co-Authored-By: Leo Qiu <leogoesger@users.noreply.github.com>
NiklasMerz added a commit to GEDYSIntraWare/cordova-ios that referenced this issue Jan 14, 2020
Fix "Could not parse *-info.plist or config.xml". Proposed fix, see apache#764

Co-Authored-By: Leo Qiu <leogoesger@users.noreply.github.com>
NiklasMerz added a commit to GEDYSIntraWare/cordova-ios that referenced this issue Jan 14, 2020
Fix "Could not parse *-info.plist or config.xml". Proposed fix, see apache#764

Co-Authored-By: Leo Qiu <leogoesger@users.noreply.github.com>
NiklasMerz added a commit to GEDYSIntraWare/cordova-ios that referenced this issue Jan 14, 2020
Fix "Could not parse *-info.plist or config.xml". Proposed fix, see apache#764

Co-Authored-By: Leo Qiu <leogoesger@users.noreply.github.com>
NiklasMerz added a commit to GEDYSIntraWare/cordova-ios that referenced this issue Jan 14, 2020
Fix "Could not parse *-info.plist or config.xml". Proposed fix, see apache#764

Co-Authored-By: Leo Qiu <leogoesger@users.noreply.github.com>
NiklasMerz added a commit to GEDYSIntraWare/cordova-ios that referenced this issue Jan 14, 2020
Fix "Could not parse *-info.plist or config.xml". Proposed fix, see apache#764

Co-Authored-By: Leo Qiu <leogoesger@users.noreply.github.com>
NiklasMerz added a commit to GEDYSIntraWare/cordova-ios that referenced this issue Jan 14, 2020
Fix "Could not parse *-info.plist or config.xml". Proposed fix, see apache#764

Co-Authored-By: Leo Qiu <leogoesger@users.noreply.github.com>
@NiklasMerz
Copy link
Member

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

@leogoesger
Copy link
Author

#765

@jj449
Copy link

jj449 commented Feb 5, 2020

@leogoesger thank you, your fix work for me .

@leogoesger
Copy link
Author

@NiklasMerz any update on this?

@NiklasMerz
Copy link
Member

Plese check the reviews in #765

@NiklasMerz
Copy link
Member

NiklasMerz commented Feb 14, 2020

@NiklasMerz any update on this?

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

@eswarjk
Copy link

eswarjk commented Dec 29, 2020

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)

@ejonnadula
Copy link

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

@nicozenf
Copy link

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.

@ejonnadula
Copy link

@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.

@breautek
Copy link
Contributor

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.

@nicozenf
Copy link

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

@ejonnadula
Copy link

@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
Copy link

@nicozenf our watch app code is in Objective-C. I have tried with sample "HelloWorld" app also like below.

Information
For testing purpose I have created HelloWorld sample cordova app and added cordova ios 6.1.0 (I have tried with cordova ios 6.1.1 as well but facing same issue) after installing ios 6.1.0, I have run the build "cordova build ios" command successfully. I opened the HelloWorld app in xcode 11.3.1 and added ios watch app (In XCODE, File--> New--> Target--> select watchOS tab--> under applications select Watch App for iOS App --> click on Next button--> fill in the details and select Objective-C, select NotificationScene --> Click Finish--> Click on Activate button
Then when I run "cordova build ios" in Mac Terminal getting:

error: unable to resolve product type 'com.apple.product-type.watchkit2-extension' for platform 'iphonesimulator' (in target 'myapp Extension' from project 'myapp').

@nicozenf
Copy link

nicozenf commented Jan 12, 2021

Sorry, I can't help you further, but it look like a different problem to the one describe in the thread. Good luck ;)

@ejonnadula
Copy link

As @nicozenf mentioned I will update xcode from 11.3.1 to 12 and try once.

@leogoesger
Copy link
Author

Can someone verify this is fixed? I will close the issue.

@brodycj
Copy link
Contributor

brodycj commented Jan 15, 2021

I think this is not fixed, people have just been discussing workarounds.

@ejonnadula
Copy link

As @nicozenf suggested, I have upgraded XCODE from 11.3.1 to 12.3. Facing same issue after xcode upgrade also.
Any help on this issue is very much appreciated.

Again giving log for your reference:

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)

@ejonnadula
Copy link

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

@ejonnadula
Copy link

Dear Cordova team, any help on this issue is very much appreciated.

@brodycj
Copy link
Contributor

brodycj commented Feb 24, 2021

I already submitted the bugfix with testing included in PR #795 but it was never reviewed and there are now many conflicts. I think we will have to do this in 2 parts:

  • add some more tests with test fixtures
  • apply the solution with updated testing

Unfortunately I cannot promise when I will get a chance to work on this due to some other priorities. I would recommend following up through the dev email forum or through slack, follow the links in the footer of cordova.io or cordova.apache.org for the contact information.

@ejonnadula
Copy link

Dear team, any help on this issue is very much appreciated.

@leogoesger
Copy link
Author

leogoesger commented Apr 30, 2021

@ejonnadula I created a fix that worked for my org, by forking the branch. You could just use @bradfol 's fork? It seems to me this project is not actively being maintained, so not sure waiting is the best thing to do here.

@ejonnadula
Copy link

ejonnadula commented Jun 7, 2021

Our organization doesn't want to take code from anyone's personal branch.
We are looking for fix release from cordova. Any help on this issue from cordova team (release) is very much appreciated

@petermeester
Copy link

Your solution works also for me. Great! Thank you.

@abhishek-2102
Copy link

Hey @petermeester, can you mention the soultion you have followed. I see multiple solutions down the thread.

@petermeester
Copy link

Hey @petermeester, can you mention the soultion you have followed. I see multiple solutions down the thread.

Hey @abhishek-2102, the solution of @leogoesger worked for me. Changing the projectFile.js file in the ios/cordova/lib directory. See #764 (comment).

mashfiqui-rabbi added a commit to StatisticalReinforcementLearningLab/SARAv2 that referenced this issue Feb 4, 2022
Solution was found in: apache/cordova-ios#764

Had to change the "projectFile.js"


Former-commit-id: a26f459
@uareurapid
Copy link

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

kntrs added a commit to dejiren/cordova-ios that referenced this issue Mar 8, 2023
@expcapitaldev
Copy link

Root issue with quotes and INFOPLIST_FILE should be linked to Main target

const xcBuildConfiguration = xcodeproj.pbxXCBuildConfigurationSection();
const plist_file_entry = Object.values(xcBuildConfiguration).find(entry => entry.buildSettings && entry.buildSettings.INFOPLIST_FILE);
const plist_file = path.join(project_dir, plist_file_entry.buildSettings.INFOPLIST_FILE.replace(/^"(.*)"$/g, '$1').replace(/\\&/g, '&'));

to

function unquote(str) {
    if (str) return str.replace(/^"(.*)"$/, "$1");
}
// todo https://github.com/apache/cordova-ios/issues/764
const firstTargetName = xcodeproj.getFirstTarget().firstTarget.name;
const plist_file_value = xcodeproj.getBuildProperty("INFOPLIST_FILE", undefined, unquote(firstTargetName));
const plist_file = path.join(project_dir, plist_file_value.replace(/^"(.*)"$/g, '$1').replace(/\\&/g, '&'));
const config_file = path.join(path.dirname(plist_file), 'config.xml');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment