0

I am developing a Nativescript application which makes numerous server calls for various services. The test and production URLs for these calls are different and while switching back and forth between the Debug and Release version I might miss or mess something up (by accidentally using a production URL for debug app). I wanted to know if there are any best practices regarding this aspect of App publishing? I couldn't find any specific answer regarding my question on the internet and the closest thing I found were these article for ReactNative apps:

http://www.multunus.com/blog/2016/06/automated-environment-management-react-native-ios/

http://blog.carbonfive.com/2016/09/29/setting-up-react-native-build-environments-using-nativemodules/

If someone can guide me on this specific to Nativescript application, I would really appreciate it. Thanks.

ssiddh
  • 480
  • 1
  • 6
  • 18

1 Answers1

0

You can try use this https://www.npmjs.com/package/nativescript-hook-debug-production when you are trying to debug build it will do filename.debug.extension or when production then from filename.production.extension to filename.extension so inside code, you can require or link to filename.extension

Marek Maszay
  • 1,537
  • 1
  • 9
  • 11
  • Thanks for the response. I did try using the plugin but it is throwing an error at me. This is what I am getting right now: `Executing after-prepare hook from /Downloads/test/testdrawer/testbuildapp/hooks/after-prepare/nativescript-hook-debug-production.js Cannot read property 'prepareInfo' of undefined` – ssiddh Jan 09 '17 at 16:38
  • The plugin works well and helps you get away with having different versions for Debug and production code. – ssiddh Jan 27 '17 at 20:13
  • You can even let production file as `filename.extension` and debug as `filename.debug.extension` and it will delete `filename.extension` and debug version will be rename to `filename.extension` – Marek Maszay Jan 28 '17 at 11:03
  • what about if you have another env? not debug neither prod? – Carlos.V Mar 08 '19 at 04:09