NativeScript / ios-jsc

NativeScript for iOS using JavaScriptCore
http://docs.nativescript.org/runtimes/ios
Apache License 2.0
299 stars 59 forks source link

How to know if the app is running on debug or release at runtime #669

Open AntonioCuevaUrraco opened 8 years ago

AntonioCuevaUrraco commented 8 years ago

I have a bunch of keys that have to be changes to production keys if the app is on a release build.

If I add something to de main.m like

ifdef DEBUG

will be gone as the platform is removed

NSProcessInfo.processInfo().environment seams to not help much in this task.

Some suggestions from someone with better iOS understanding?

NathanaelA commented 7 years ago

Are you wanting this info a runtime or during build time?

AntonioCuevaUrraco commented 7 years ago

It doesn't matter, build time is fine. I just need to know if the app should use keyDebug or keyRelease to keep our data clean on our 3rd party services. Maybe the solution is to start building with a hook?

@NathanaelA I found your method to see if you have figured out for ios but I couldn't make it work with your suggestions

NathanaelA commented 7 years ago

@AntonioCuevaUrraco Not sure which method you are talking about.

But I was asking to see if you needed this at runtime which my plugin (nativescript-master-technology) has the ability to detect emulator vs real device. On android it can even detect if the app is signed as a non-debug app (which would be release even if running on emulator). However, if you want to do it at build time then you should use the NS-Hooks project and create a hook that modifies the source based on the flag passed into the TNS command line.

jasssonpet commented 7 years ago

We had a PR do a similar thing (https://github.com/NativeScript/ios-runtime/pull/408) but it didn't get merged. You can look at the workaround there.

AntonioCuevaUrraco commented 7 years ago

@NathanaelA yes I was talking about nativescript-master-technology and to detect if app is running on emulator vs real device is not enough as we use real devices to check that everything is fine and track tricky bugs. So far I am setting a flag to true before creating a release app, will check how to ns-hook it or npm hook it.

@jasssonpet is there a good reason why that PR was not merged? some instability or breaking something else?