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

using custom-config-file removes empty string objects in .plist #136

Closed
chrismowbraylit opened this issue Dec 13, 2017 · 9 comments
Closed
Labels

Comments

@chrismowbraylit
Copy link

Running a standard config update:

<custom-config-file platform="ios" target="*-Info.plist" parent="MyCustomnode" mode="replace"> 
        <string>test</string> 
 </custom-config-file>

This removes any empty string objects from the .plist.

This...

<key>NSMainNibFile</key>
<string/>
<key>NSMainNibFile~ipad</key>
<string/>
<key>NSLocationWhenInUseUsageDescription</key>
<string/>

becomes this...

<key>NSMainNibFile</key>
<key>NSMainNibFile~ipad</key>
<key>NSLocationWhenInUseUsageDescription</key>

The .plist in now in an unreadable format and cant be used.

@dpa99c
Copy link
Owner

dpa99c commented Dec 15, 2017

I'm not able to reproduce this behaviour (see console output below).

This plugin uses the plist module to read and write the plist contents, so any issue in formatting the plist file is likely to be caused by that.

  • Is it possible you have a different version of plist installed locally or globally than that specified by this plugin?
  • Is is possible you have another plugin installed in the project which is conflicting with this one?
  • Are you able to reproduce the issue if you repeat the steps in the console output below?
console output

$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.13.2
BuildVersion:	17C88

$ node -v
v6.11.0

$ npm -v
3.10.10

$ cordova -v
7.1.0

$ git clone https://github.com/dpa99c/cordova-custom-config-example && cd cordova-custom-config-example
Cloning into 'cordova-custom-config-example'...
remote: Counting objects: 612, done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 612 (delta 4), reused 5 (delta 2), pack-reused 602
Receiving objects: 100% (612/612), 3.86 MiB | 669.00 KiB/s, done.
Resolving deltas: 100% (256/256), done.

$ cordova plugin add cordova-custom-config && cordova plugin rm cordova-custom-config
Adding cordova-custom-config to package.json
Saved plugin info for "cordova-custom-config" to config.xml
Removing "cordova-custom-config"
Removing plugin cordova-custom-config from config.xml file...
Removing cordova-custom-config from package.json

$ cordova platform add ios@latest
Using cordova-fetch for cordova-ios@latest
Adding ios project...
Creating Cordova project for the iOS platform:
	Path: platforms/ios
	Package: uk.co.workingedge.phonegap.plugins.example.customconfig
	Name: Custom config plugin example
iOS project created with [email protected]
Discovered plugin "cordova-plugin-whitelist" in config.xml. Adding it to the project
Installing "cordova-plugin-whitelist" for ios
Adding cordova-plugin-whitelist to package.json
Saved plugin info for "cordova-plugin-whitelist" to config.xml
--save flag or autosave detected
Saving ios@latest into config.xml file ...

$ more platforms/ios/Custom\ config\ plugin\ example/Custom\ config\ plugin\ example-Info.plist 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>English</string>
    <key>CFBundleDisplayName</key>
    <string>Custom config plugin example</string>
    <key>CFBundleExecutable</key>
    <string>${EXECUTABLE_NAME}</string>
    <key>CFBundleIcons</key>
    <dict/>
    <key>CFBundleIcons~ipad</key>
    <dict/>
    <key>CFBundleIdentifier</key>
    <string>uk.co.workingedge.phonegap.plugins.example.customconfig</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>${PRODUCT_NAME}</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>5.0.0</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>5.0.0</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>NSMainNibFile</key>
    <string/>
    <key>NSMainNibFile~ipad</key>
    <string/>
    <key>UISupportedInterfaceOrientations</key>
    <array>
      <string>UIInterfaceOrientationPortrait</string>
      <string>UIInterfaceOrientationLandscapeLeft</string>
      <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
      <string>UIInterfaceOrientationPortrait</string>
      <string>UIInterfaceOrientationLandscapeLeft</string>
      <string>UIInterfaceOrientationPortraitUpsideDown</string>
      <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UIRequiresFullScreen</key>
    <true/>
    <key>NSAppTransportSecurity</key>
    <dict>
      <key>NSAllowsArbitraryLoads</key>
      <true/>
    </dict>
  </dict>
</plist>

$ cordova plugin add cordova-custom-config@latest
Installing "cordova-custom-config" for ios
Adding cordova-custom-config to package.json
Saved plugin info for "cordova-custom-config" to config.xml

$ cordova prepare ios
cordova-custom-config: Skipping auto-restore of config file backup(s)
cordova-custom-config: Applied custom config from config.xml to /Users/dave/Documents/projects/@scratch/cordova-custom-config-example/platforms/ios/Custom config plugin example.xcodeproj/project.pbxproj
cordova-custom-config: Applied custom config from config.xml to /Users/dave/Documents/projects/@scratch/cordova-custom-config-example/platforms/ios/cordova/build.xcconfig
cordova-custom-config: Applied custom config from config.xml to /Users/dave/Documents/projects/@scratch/cordova-custom-config-example/platforms/ios/cordova/build-extras.xcconfig
cordova-custom-config: Applied custom config from config.xml to /Users/dave/Documents/projects/@scratch/cordova-custom-config-example/platforms/ios/cordova/build-debug.xcconfig
cordova-custom-config: Applied custom config from config.xml to /Users/dave/Documents/projects/@scratch/cordova-custom-config-example/platforms/ios/cordova/build-release.xcconfig
cordova-custom-config: Applied custom config from config.xml to /Users/dave/Documents/projects/@scratch/cordova-custom-config-example/platforms/ios/Custom config plugin example/Custom config plugin example-Info.plist

$ more platforms/ios/Custom\ config\ plugin\ example/Custom\ config\ plugin\ example-Info.plist 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>English</string>
    <key>CFBundleDisplayName</key>
    <string>Custom config plugin example</string>
    <key>CFBundleExecutable</key>
    <string>${EXECUTABLE_NAME}</string>
    <key>CFBundleIcons</key>
    <dict/>
    <key>CFBundleIcons~ipad</key>
    <dict/>
    <key>CFBundleIdentifier</key>
    <string>uk.co.workingedge.phonegap.plugins.example.customconfig</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>${PRODUCT_NAME}</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>5.0.0</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>5.0.0</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>NSMainNibFile</key>
    <string/>
    <key>NSMainNibFile~ipad</key>
    <string/>
    <key>UISupportedInterfaceOrientations</key>
    <array>
      <string>UIInterfaceOrientationPortrait</string>
      <string>UIInterfaceOrientationLandscapeLeft</string>
      <string>UIInterfaceOrientationLandscapeRight</string>
      <string>UIInterfaceOrientationPortraitUpsideDown</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
      <string>UIInterfaceOrientationPortrait</string>
      <string>UIInterfaceOrientationPortraitUpsideDown</string>
    </array>
    <key>UIRequiresFullScreen</key>
    <true/>
    <key>NSAppTransportSecurity</key>
    <dict>
      <key>NSAllowsArbitraryLoads</key>
      <true/>
    </dict>
    <key>LSApplicationQueriesSchemes</key>
    <array>
      <string>myapp</string>
      <string>myapp2</string>
      <string>myapp3</string>
    </array>
    <key>UIBackgroundModes</key>
    <array>
      <string>location</string>
    </array>
    <key>NSLocationAlwaysUsageDescription</key>
    <string>This app requires constant access to your location in order to track your position, even when the screen is off.</string>
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>This app will now only track your location when the screen is on and the app is displayed.</string>
  </dict>
</plist>



@chrismowbraylit
Copy link
Author

I cannot replicate the issue with the above setup. Although I cannot see any other plugin changing the plist in my repo.

@dpa99c
Copy link
Owner

dpa99c commented Dec 18, 2017

Aha! I think I've found the cause of it.

This issue originally cropped up in #90. The cause was a bug in plist@2 (outlined in plist.js#79) and the solution was to keep the version pinned at [email protected]. However, going through the commit history, it seems I inadvertently accepted PR #119 and forgot about #90. That PR bumps the versions to [email protected] and [email protected] (which indirectly depends on [email protected] via [email protected]). The PR had good intentions, but has re-introduced this bug.

In the meantime, the ownership of xcode has moved from alunny to apache/cordova. The new cordova-node-xcode still depends on [email protected] and hence on [email protected].

However, I don't think the problem encountered with this plugin is the indirect use of [email protected] via xcode, I think it's the now-explicit dependency thanks to PR #119.

plist.js#79 is still open and it seems no more recent versions have been released which fix that issue, however there's an open PR to fix it. I'm thinking that if I directly reference the fork which contains the fix in the package.json of this plugin, then not only will this plugin make direct use of that fixed version of [email protected], but the version is the same as that depended on by xcode hence it should hopefully also use the fixed version from the fork, rather than the buggy master version from npm.

dpa99c added a commit that referenced this issue Dec 18, 2017
Set plist dependency to use fork which fixes bug causing #136 and #90.
Set xcode to @1.0.0 which is published from the new apache/cordova repo.
@chrismowbraylit
Copy link
Author

Hey @dpa99c thanks for the quick response. Are you going to push this into a release?

@dpa99c
Copy link
Owner

dpa99c commented Dec 18, 2017

@chrismowbray I've just published v5.0.1 of this plugin, which references the forked plist dependency.

Give it a go in your project and let me know if it works OK. You may need to first remove node_modules to make sure it installs fresh dependencies.

@chrismowbraylit
Copy link
Author

@dpa99c im not seeing the 5.0.1 in https://github.com/dpa99c/cordova-custom-config/releases or npm. Maybe it takes a while

@dpa99c
Copy link
Owner

dpa99c commented Dec 18, 2017

@chrismowbraylit
Copy link
Author

Yep and now I see it! ill post back when I test it out

@chrismowbraylit
Copy link
Author

@dpa99c All looks good now. Thanks for the quick response. This issue can be closed

@dpa99c dpa99c mentioned this issue May 2, 2018
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants