Environment variables and arguments passed at startup do not work after compiling the application

The fact is that I set some default values ​​before starting the application for a specific purpose:

enter image description here

Here's how I check if my goal works or not:

if NSProcessInfo.processInfo().arguments.contains("DIFF") {}

or

if NSProcessInfo.processInfo().environment["DIFF"] != nil {}

but they only work after I compiled the application on the device. As soon as I close the application and run the icon application on the device again, it no longer works. Why?

+4
source share
1 answer

These arguments are only passed to the application when it is launched by Xcode using your schema. When the application is launched by the user by clicking on the icon, the arguments will not be passed.

+7

Source: https://habr.com/ru/post/1629461/


All Articles