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

v2 working perfectly, v3 branch not working #110

Closed
sinedied opened this issue Apr 10, 2017 · 8 comments
Closed

v2 working perfectly, v3 branch not working #110

sinedied opened this issue Apr 10, 2017 · 8 comments
Labels

Comments

@sinedied
Copy link

sinedied commented Apr 10, 2017

In my config.xml, I have these settings:

    <config-file parent="UIStatusBarStyle" platform="ios" target="*-Info.plist">
      <string>UIStatusBarStyleLightContent</string>
    </config-file>
    <config-file parent="UISupportedInterfaceOrientations" platform="ios" target="*-Info.plist" mode="replace">
      <array>
        <string>UIInterfaceOrientationPortrait</string>
      </array>
    </config-file>
    <config-file parent="UISupportedInterfaceOrientations~ipad" platform="ios" target="*-Info.plist" mode="replace">
      <array>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
      </array>
    </config-file>

When using cordova-custom-config@2, it works perfectly.

When I try to update to cordova-custom-config@3 (any version), nothing works, as if the plugin was not present at all. For instance, all the plugin dependencies are installed correctly, and I can see in the log that the plugin should do its job, but in fact doesn't.

Did I miss something?
Thanks for your help

EDIT: I'm using cordova@6.5.0 on latest OSX version, with npm@3 and node@6.9.4

@dpa99c
Copy link
Owner

dpa99c commented Apr 11, 2017

The block of custom config you've listed should/does work fine with cordova-custom-config@3 - see the console output below.

console output

cordova-custom-config-example$ more config.xml 
<?xml version='1.0' encoding='utf-8'?>
<widget
        id="uk.co.workingedge.phonegap.plugins.example.customconfig"
        version="0.0.1"
        xmlns="http://www.w3.org/ns/widgets"
        xmlns:cdv="http://cordova.apache.org/ns/1.0"
        xmlns:android="http://schemas.android.com/apk/res/android">
    <name>Custom config plugin example</name>
    <content src="index.html" />
    <access origin="*" />
    <preference name="Fullscreen" value="false" />

    <plugin name="cordova-plugin-whitelist" version="1.0.0" />

    <platform name="ios">
        <config-file parent="UIStatusBarStyle" platform="ios" target="*-Info.plist">
          <string>UIStatusBarStyleLightContent</string>
        </config-file>
        <config-file parent="UISupportedInterfaceOrientations" platform="ios" target="*-Info.plist" mode="replace">
          <array>
            <string>UIInterfaceOrientationPortrait</string>
          </array>
        </config-file>
        <config-file parent="UISupportedInterfaceOrientations~ipad" platform="ios" target="*-Info.plist" mode="replace">
          <array>
            <string>UIInterfaceOrientationLandscapeLeft</string>
            <string>UIInterfaceOrientationLandscapeRight</string>
          </array>
        </config-file>
    </platform>
</widget>
cordova-custom-config-example$ cordova -v
6.5.0
cordova-custom-config-example$ cordova platform add ios
Adding ios project...
Creating Cordova project for the iOS platform:
	Path: ../../../../../projects/cordova-custom-config-example/platforms/ios
	Package: uk.co.workingedge.phonegap.plugins.example.customconfig
	Name: Custom config plugin example
iOS project created with cordova-ios@4.3.1
Installing "cordova-plugin-whitelist" for ios
cordova-custom-config-example$ cordova prepare ios
cordova-custom-config-example$ cp platforms/ios/
.gitignore                                Custom config plugin example.xcworkspace/ pods-debug.xcconfig
CordovaLib/                               cordova/                                  pods-release.xcconfig
Custom config plugin example/             ios.json                                  www/
Custom config plugin example.xcodeproj/   platform_www/                             
cordova-custom-config-example$ cp platforms/ios/Custom\ config\ plugin\ example/Custom\ config\ plugin\ example-Info.plist original.plist
cordova-custom-config-example$ cordova plugin add cordova-custom-config@latest
Fetching plugin "cordova-custom-config@latest" via npm
Installing "cordova-custom-config" for ios
cordova-custom-config-example$ cordova plugin ls
cordova-custom-config 3.1.3 "cordova-custom-config"
cordova-plugin-whitelist 1.0.0 "Whitelist"
cordova-custom-config-example$ cordova prepare ios
cordova-custom-config: Skipping auto-restore of config file backup(s)
cordova-custom-config: Applied custom config from config.xml to /projects/cordova-custom-config-example/platforms/ios/Custom config plugin example/Custom config plugin example-Info.plist
cordova-custom-config-example$ diff platforms/ios/Custom\ config\ plugin\ example/Custom\ config\ plugin\ example-Info.plist original.plist
37a38,39
>       <string>UIInterfaceOrientationLandscapeLeft</string>
>       <string>UIInterfaceOrientationLandscapeRight</string>
40a43
>       <string>UIInterfaceOrientationPortrait</string>
41a45
>       <string>UIInterfaceOrientationPortraitUpsideDown</string>
51,52d54
<     <key>UIStatusBarStyle</key>
<     <string>UIStatusBarStyleLightContent</string> 


So try the following:

  • Make sure the <config-file> blocks in config.xml are enclosed in <platform name="ios">
  • Delete plugins/cordova-custom-config/backup/ and/or set <preference name="cordova-custom-config-autorestore" value="false" />
  • Run cordova prepare ios --verbose to see additional output from the plugin's operations.
  • Look at the example project for reference.

@sinedied
Copy link
Author

sinedied commented Apr 11, 2017

  • Make sure the blocks in config.xml are enclosed in

Here is my complete config.xml:

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.myapp" ios-CFBundleIdentifier="${PRODUCT_BUNDLE_IDENTIFIER}" version="2.1.2"
        xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
  <name>MyApp</name>
  <description>
    My App description...
  </description>
  <author email="you@example.com" href="http://example.com.com/">
    Name Here
  </author>
  <content src="index.html"/>
  <access launch-external="yes" origin="*"/>
  <allow-navigation href="*"/>
  <platform name="ios">
    <feature name="CDVWKWebViewEngine">
      <param name="ios-package" value="CDVWKWebViewEngine"/>
    </feature>
    <preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine"/>
    <preference name="deployment-target" value="8.0"/>
    <preference name="UIWebViewBounce" value="false"/>
    <preference name="BackupWebStorage" value="none"/>
    <preference name="KeyboardDisplayRequiresUserAction" value="false"/>
    <icon height="57" src="resources/ios/icon/icon.png" width="57"/>
    <icon height="114" src="resources/ios/icon/icon@2x.png" width="114"/>
    <icon height="40" src="resources/ios/icon/icon-40.png" width="40"/>
    <icon height="80" src="resources/ios/icon/icon-40@2x.png" width="80"/>
    <icon height="50" src="resources/ios/icon/icon-50.png" width="50"/>
    <icon height="100" src="resources/ios/icon/icon-50@2x.png" width="100"/>
    <icon height="60" src="resources/ios/icon/icon-60.png" width="60"/>
    <icon height="120" src="resources/ios/icon/icon-60@2x.png" width="120"/>
    <icon height="180" src="resources/ios/icon/icon-60@3x.png" width="180"/>
    <icon height="72" src="resources/ios/icon/icon-72.png" width="72"/>
    <icon height="144" src="resources/ios/icon/icon-72@2x.png" width="144"/>
    <icon height="76" src="resources/ios/icon/icon-76.png" width="76"/>
    <icon height="152" src="resources/ios/icon/icon-76@2x.png" width="152"/>
    <icon height="29" src="resources/ios/icon/icon-small.png" width="29"/>
    <icon height="58" src="resources/ios/icon/icon-small@2x.png" width="58"/>
    <icon height="87" src="resources/ios/icon/icon-small@3x.png" width="87"/>
    <splash height="1136" src="resources/ios/splash/Default-568h@2x~iphone.png" width="640"/>
    <splash height="1334" src="resources/ios/splash/Default-667h.png" width="750"/>
    <splash height="2208" src="resources/ios/splash/Default-736h.png" width="1242"/>
    <splash height="2048" src="resources/ios/splash/Default-Portrait@2x~ipad.png" width="1536"/>
    <splash height="1024" src="resources/ios/splash/Default-Portrait~ipad.png" width="768"/>
    <splash height="960" src="resources/ios/splash/Default@2x~iphone.png" width="640"/>
    <splash height="480" src="resources/ios/splash/Default~iphone.png" width="320"/>
    <config-file parent="UIStatusBarStyle" platform="ios" target="*-Info.plist" mode="replace">
      <string>UIStatusBarStyleLightContent</string>
    </config-file>
    <config-file parent="UISupportedInterfaceOrientations" platform="ios" target="*-Info.plist" mode="replace">
      <array>
        <string>UIInterfaceOrientationPortrait</string>
      </array>
    </config-file>
    <config-file parent="UISupportedInterfaceOrientations~ipad" platform="ios" target="*-Info.plist" mode="replace">
      <array>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
      </array>
    </config-file>
    <config-file platform="ios" target="*-Info.plist" parent="NSLocationWhenInUseUsageDescription" mode="replace">
      <string>Allows to get your location to show your position on map.</string>
    </config-file>
    <config-file platform="ios" target="*-Info.plist" parent="NSMicrophoneUsageDescription" mode="replace">
      <string>Allows to attach sound from microphone to a log.</string>
    </config-file>
    <config-file platform="ios" target="*-Info.plist" parent="NSCameraUsageDescription" mode="replace">
      <string>Allows to attach new images from camera to an asset.</string>
    </config-file>
    <config-file platform="ios" target="*-Info.plist" parent="NSPhotoLibraryUsageDescription" mode="replace">
      <string>Allows to attach images from library to an asset.</string>
    </config-file>
  </platform>
  <platform name="android">
    <preference name="android-minSdkVersion" value="16"/>
    <icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png"/>
    <icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png"/>
    <icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png"/>
    <icon density="xhdpi" src="resources/android/icon/drawable-xhdpi-icon.png"/>
    <icon density="xxhdpi" src="resources/android/icon/drawable-xxhdpi-icon.png"/>
    <icon density="xxxhdpi" src="resources/android/icon/drawable-xxxhdpi-icon.png"/>
    <splash density="port-ldpi" src="resources/android/splash/drawable-port-ldpi-screen.png"/>
    <splash density="port-mdpi" src="resources/android/splash/drawable-port-mdpi-screen.png"/>
    <splash density="port-hdpi" src="resources/android/splash/drawable-port-hdpi-screen.png"/>
    <splash density="port-xhdpi" src="resources/android/splash/drawable-port-xhdpi-screen.png"/>
    <splash density="port-xxhdpi" src="resources/android/splash/drawable-port-xxhdpi-screen.png"/>
    <splash density="port-xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png"/>
  </platform>
  <icon src="resources/android/icon/drawable-xhdpi-icon.png"/>
  <feature name="StatusBar">
    <param name="ios-package" onload="true" value="CDVStatusBar"/>
  </feature>
  <preference name="Fullscreen" value="false"/>
  <preference name="webviewbounce" value="false"/>
  <preference name="StatusBarStyle" value="default"/>
  <preference name="AutoHideSplashScreen" value="false"/>
  <preference name="SplashMaintainAspectRatio" value="true"/>
  <preference name="SplashScreen" value="screen"/>
  <preference name="SplashScreenDelay" value="3000"/>
  <preference name="ShowSplashScreenSpinner" value="false"/>
  <preference name="loadUrlTimeoutValue" value="60000"/>
  <preference name="android-manifest/application/activity/@android:theme" value="@android:style/Theme.DeviceDefault"/>
  <preference name="cordova-custom-config-hook" value="before_compile" />
  <plugin name="ionic-plugin-keyboard" spec="~2.2.1"/>
  <plugin name="cordova-plugin-statusbar" spec="~2.2.0"/>
  <plugin name="cordova-plugin-device" spec="~1.1.1"/>
  <plugin name="cordova-plugin-splashscreen" spec="~4.0.0"/>
  <plugin name="cordova-plugin-screen-orientation" spec="~2.0.0"/>
  <plugin name="cordova-plugin-globalization" spec="~1.0.3"/>
  <plugin name="cordova-plugin-whitelist" spec="~1.3.0"/>
  <plugin name="cordova-plugin-network-information" spec="~1.3.0"/>
  <plugin name="cordova-plugin-file" spec="~4.3.0"/>
  <plugin name="cordova-plugin-file-transfer" spec="~1.6.0"/>
  <plugin name="cordova-plugin-geolocation" spec="~2.4.0">
    <variable name="GEOLOCATION_USAGE_DESCRIPTION" value="Needed to display current user position on the map."/>
  </plugin>
  <plugin name="cordova-plugin-media-capture" spec="~1.4.0">
    <variable name="CAMERA_USAGE_DESCRIPTION" value="Allows to attach new images from camera to an asset."/>
    <variable name="MICROPHONE_USAGE_DESCRIPTION" value="Allows to attach new images from camera to an asset."/>
    <variable name="PHOTOLIBRARY_USAGE_DESCRIPTION" value="Allows to attach photos from the library to an asset."/>
  </plugin>
  <plugin name="cordova-plugin-camera" spec="~2.2.0"/>0
  <plugin name="cordova-plugin-image-picker" spec="https://github.com/wymsee/cordova-imagePicker.git#v1.1.3">
    <variable name="PHOTO_LIBRARY_USAGE_DESCRIPTION" value="Allows to attach photos from the library to an asset."/>
  </plugin>
  <plugin name="cordova-plugin-datepicker"
          spec="https://github.com/VitaliiBlagodir/cordova-plugin-datepicker.git#bd87605936b450dc32de0cddfb2ddb4936803fe0"/>
  <plugin name="phonegap-plugin-barcodescanner" spec="./custom-plugins/phonegap-plugin-barcodescanner"/>
  <plugin name="cordova-plugin-inappbrowser" spec="~1.5.0"/>
  <plugin name="cordova-plugin-media" spec="~2.4.0"/>
  <plugin name="cordova-plugin-wkwebview-engine"
          spec="https://github.com/driftyco/cordova-plugin-wkwebview-engine.git#ef65cb6041949210b8e1680d9a2ef1feb3ebc9b1"/>
  <plugin name="phonegap-plugin-push" spec="~1.9.0">
    <variable name="SENDER_ID" value="757839759100"/>
  </plugin>
  <plugin name="cordova-plugin-camera" spec="~2.3.0"/>
  <plugin name="cordova-custom-config" spec="~3.0.14"/>
  <plugin name="cordova-plugin-ignore-lint-translation" spec="~0.0.1"/>
  <engine name="ios" spec="~4.3.0"/>
  <engine name="android" spec="~6.1.0"/>
  <plugin name="cordova-plugin-crosswalk-webview" spec="~2.2.0">
    <variable name="XWALK_VERSION" value="22+"/>
    <variable name="XWALK_LITEVERSION" value="xwalk_core_library_canary:17+"/>
    <variable name="XWALK_COMMANDLINE" value="--disable-pull-to-refresh-effect"/>
    <variable name="XWALK_MODE" value="embedded"/>
    <variable name="XWALK_MULTIPLEAPK" value="true"/>
  </plugin>
  <plugin name="uk.co.workingedge.phonegap.plugin.istablet" spec="~1.1.1"/>
</widget>

I added the cordova-custom-config-hook preference to try something new, no luck.
The same config with cordova-custom-config@~2.0.0 works perfectly.

  • Delete plugins/cordova-custom-config/backup/ and/or set

I start clean without platform nor plugins folders every time.

  • Run cordova prepare ios --verbose to see additional output from the plugin's operations.

Relevant logs:

Discovered plugin "cordova-custom-config" in config.xml. Adding it to the project
No scripts found for hook "before_plugin_add".
Calling plugman.fetch on plugin "cordova-custom-config@~3.0.14"
Fetching plugin "cordova-custom-config@~3.0.14" via npm
Copying plugin "/Users/noda/.cordova/lib/npm_cache/cordova-custom-config/3.0.14/package" => "/Users/noda/Desktop/facilityhero/fh-app/plugins/cordova-custom-config"
Calling plugman.install on plugin "/Users/noda/Desktop/facilityhero/fh-app/plugins/cordova-custom-config" for platform "ios
Installing "cordova-custom-config" for ios
Running command: /Users/noda/Desktop/facilityhero/fh-app/platforms/ios/cordova/version 
Command finished with error code 0: /Users/noda/Desktop/facilityhero/fh-app/platforms/ios/cordova/version 
Finding scripts for "before_plugin_install" hook from plugin cordova-custom-config on ios platform only.
No scripts found for hook "before_plugin_install".
Install start for "cordova-custom-config" on ios.
Beginning processing of action stack for ios project...
Action stack processing complete.
Install complete for cordova-custom-config on ios.
Finding scripts for "after_plugin_install" hook from plugin cordova-custom-config on ios platform only.
Executing script found in plugin cordova-custom-config for hook "after_plugin_install": plugins/cordova-custom-config/hooks/resolveDependencies.js
Resolving module name for child_process => child_process
Resolving module name for fs => fs
Resolving module name for path => path
Resolving module name for q => q
cordova-custom-config: npm dependencies already installed

Running cordova build ios --verbose:

Executing script found in plugin cordova-custom-config for hook "after_prepare": plugins/cordova-custom-config/hooks/applyCustomConfig.js
Resolving module name for q => q
Resolving module name for path => path
cordova-custom-config: Running applyCustomConfig.js
cordova-custom-config: Loaded module dependencies
cordova-custom-config: Finished applying platform config

My plist should then be updated correctly, but it is not.

  • Look at the example project for reference.

Done, but I can't see anything I haven't done or tried :(

@dpa99c
Copy link
Owner

dpa99c commented Apr 11, 2017

<plugin name="cordova-custom-config" spec="~3.0.14"/>

You have an old version of the plugin pinned in your config.xml. The current version is cordova-custom-config@3.1.3.

Please update to the latest version and re-test.

@sinedied
Copy link
Author

Just tried with 3.1.3, same thing.

@dpa99c
Copy link
Owner

dpa99c commented Apr 11, 2017

I've gone through your config.xml in detail and I think you've found a bug.
Apologies for being sceptical and asking for proof, but 95% of the issues raised are user error rather than an actual bug.

So the reason that the config changes are not getting applied is this preference in your config.xml:

<preference name="cordova-custom-config-hook" value="before_compile" />

If seems that this git merge inadvertently wiped out the support for using after_prepare and before_compile as alternative plugin hooks from the default before_prepare.
Although that merge was made in Oct 2016, I guess no-one has spotted it because changing the default plugin hook is not done very often.
In fact, the regression tests don't currently cover that scenario, though I will now augment them to do so.

I'll commit a fix and push it out in a patch release as cordova-custom-config@3.1.4, then you should be able to confirm it resolves this issue.

@dpa99c dpa99c closed this as completed in 2145743 Apr 11, 2017
@dpa99c dpa99c reopened this Apr 11, 2017
@dpa99c
Copy link
Owner

dpa99c commented Apr 11, 2017

Oops, didn't mean for that commit to close it quite yet.

@dpa99c
Copy link
Owner

dpa99c commented Apr 11, 2017

But cordova-custom-config@3.1.4 is now published to npm and running it against your config in a test project with cordova compile ios --verbose, the hook script is now applying changes as it should be.

If you can confirm this resolves the issue at your end, then this issue can be closed.

@sinedied
Copy link
Author

Just tested your new version, it works perfectly 👍
Thanks a lot for the fix and the great reactivity.

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