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

XML elements are reordered, corrupting config.xml #684

Open
jkronborg opened this issue Jun 10, 2024 · 3 comments
Open

XML elements are reordered, corrupting config.xml #684

jkronborg opened this issue Jun 10, 2024 · 3 comments

Comments

@jkronborg
Copy link

Package version: 15.0.6


Steps to reproduce:

  1. Create a Cordova project.
  2. Add a privacy manifest to config.xml, e.g.:
    <?xml version='1.0' encoding='utf-8'?>
    <widget id="com.example.reproapp" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
        <name>ReproApp</name>
        <description>Sample Apache Cordova App</description>
        <author email="[email protected]" href="https://cordova.apache.org">
            Apache Cordova Team
        </author>
        <content src="index.html" />
        <allow-intent href="http://*/*" />
        <allow-intent href="https://*/*" />
        <platform name="ios">
            <privacy-manifest>
                <key>NSPrivacyTracking</key>
                <false />
                <key>NSPrivacyCollectedDataTypes</key>
                <array />
                <key>NSPrivacyAccessedAPITypes</key>
                <array />
                <key>NSPrivacyTrackingDomains</key>
                <array />
            </privacy-manifest>
        </platform>
    </widget>
  3. Invoke cordova-set-version:
    cordova-set-version -b 123 config.xml
  4. Observe that the privacy manifest has been corrupted, resulting in the app being rejected when submitted to App Store review:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <widget id="com.example.reproapp" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" android-versionCode="123" ios-CFBundleVersion="123" osx-CFBundleVersion="123">
      <name>ReproApp</name>
      <description>Sample Apache Cordova App</description>
      <author email="[email protected]" href="https://cordova.apache.org">
            Apache Cordova Team
        </author>
      <content src="index.html"/>
      <allow-intent href="http://*/*"/>
      <allow-intent href="https://*/*"/>
      <platform name="ios">
        <privacy-manifest>
          <key>NSPrivacyTracking</key>
          <key>NSPrivacyCollectedDataTypes</key>
          <key>NSPrivacyAccessedAPITypes</key>
          <key>NSPrivacyTrackingDomains</key>
          <false/>
          <array/>
          <array/>
          <array/>
        </privacy-manifest>
      </platform>
    </widget>
@SunboX
Copy link

SunboX commented Nov 27, 2024

Came across the same issue just now. :( @jkronborg could you figure out a work around?

@jkronborg
Copy link
Author

Came across the same issue just now. :( @jkronborg could you figure out a work around?

@SunboX For the privacy manifest I created the PrivacyInfo.xcprivacy file separately and wrote a script that puts it in the right place, run as an after_prepare hook:

const fs = require('fs');
const path = require('path');

module.exports = function(context) {
    const projectRoot = context.opts.projectRoot;

    const manifestFilename = 'PrivacyInfo.xcprivacy';

    const manifestPathSrc = path.join(projectRoot, manifestFilename);

    const manifestPathDest = path.join(
        projectRoot,
        'platforms',
        'ios',
        '<AppName>',
        manifestFilename,
    );

    fs.copyFileSync(manifestPathSrc, manifestPathDest);
};

But that only helps if the privacy manifest is the only thing that the plugin corrupts.

@SunboX
Copy link

SunboX commented Nov 27, 2024

That's great! Thanks a lot!

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

2 participants