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

<resource-file /> tag copies a folder and its content when declared in a plugin.xml file, but the folder without its content when declared in a config.xml #213

Open
2 of 3 tasks
guirip opened this issue Mar 31, 2020 · 2 comments

Comments

@guirip
Copy link

guirip commented Mar 31, 2020

Bug Report

Problem

What is expected to happen?

In the cordova project, at the same level as the config.xml file I have a folder named 'ios-resources', which contains a 'en.lproj' folder. This 'en.lproj' folder contains a file InfoPlist.strings.

  • [cordova project name]
    -- ...
    -- config.xml
    -- ios-resources
    --- en.lproj
    ---- InfoPlist.strings

In the config.xml, I have this:

    <platform name="ios">
        <resource-file src="ios-resources/en.lproj" target="en.lproj" />
    </platform>

I expect the 'en.lproj' folder and its content to be added to the XCode project.

What does actually happen?

I notice that the folder en.lproj is created in platforms/ios/[APP NAME]/Resources/en.lproj/ but it is empty.

If I run cordova prepare, this warning appears:

Overwriting existing resource file at platforms/ios/[APP NAME]/Resources/en.lproj

Information

important: If you declare the same thing in the context of a cordova plugin, then the 'en.lproj' folder AND its content are successfully added to the XCode project...

Command or Code

cordova create test-resourcefile-bug
cd test-resourcefile-bug/
mkdir ios-resources
mkdir ios-resources/en.lproj
vim ios-resources/en.lproj/InfoPlist.strings

Write:

"CFBundleDisplayName" = "APP RESOURCE-FILE BUG";
"NSCameraUsageDescription" = "The app would like to access the camera to scan barcodes and QR codes.";

Then:
vim config.xml

Add the following tag to platform tag where attribute name is "ios":

<resource-file src="ios-resources/en.lproj" target="en.lproj" />

Finally:

cordova platform add [email protected]
cordova prepare
ll platforms/ios/HelloCordova/Resources/en.lproj/

The destination folder is still empty, the above cordova platform add command has output a warning message about overwriting the en.lproj folder:

Using cordova-fetch for [email protected]
Adding ios project...
Creating Cordova project for the iOS platform:
Path: platforms/ios
Package: io.cordova.hellocordova
Name: HelloCordova
iOS project created with [email protected]
Installing "cordova-plugin-whitelist" for ios
Overwriting existing resource file at platforms/ios/HelloCordova/Resources/en.lproj
--save flag or autosave detected
Saving ios@~5.1.1 into config.xml file ...

Environment, Platform, Device

Issue noticed on cordova-ios, but I have no idea if cordova android has this problem too.

Version information

cordova -v

8.1.2 ([email protected])

cordova iOS platform version:

[email protected]

cordova plugins:

cordova-android-support-gradle-release
cordova-plugin-androidx
cordova-plugin-androidx-adapter
cordova-plugin-camera
cordova-plugin-cookie-manager
cordova-plugin-device
cordova-plugin-file
cordova-plugin-file-transfer
cordova-plugin-inappbrowser
cordova-plugin-ionic-keyboard
cordova-plugin-ionic-webview
cordova-plugin-splashscreen
cordova-plugin-statusbar
cordova-plugin-urloverride
cordova-plugin-whitelist
cordova-plugin-wkwebview-inject-cookie
phonegap-plugin-barcodescanner
pushwoosh-cordova-plugin

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version - cordova-cli not yet on the brand new version published one week ago
  • I included all the necessary information above
@monurakkaya
Copy link

+1

@dpogue
Copy link
Member

dpogue commented Aug 29, 2024

The root of this issue is actually in cordova-common's FileUpdater, where it will create a directory but not populate it:

if (sourceStats.isDirectory() && !targetStats) {
// The target directory does not exist, so we create it.
log(`mkdir ${targetPath}`);
fs.mkdirSync(targetFullPath, { recursive: true });
return true;
}

Going to move this issue to that repository for followup.

@dpogue dpogue transferred this issue from apache/cordova-ios Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants