10

The thing is that I set some defaults before I run the app under specific target:

enter image description here

This is how I check if my target runs or not:

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

or

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

but they works only after I compile the app on device. Once I close the app, and run again from the icon app on device, it doesn't work any more. Why?

1 Answer 1

22

Those arguments are only passed to the app when it is launched by Xcode using your scheme. When the app is launched by the user tapping the the icon, the arguments will not be passed.

Documentation for Specify Launch Arguments and Environment Variables

Sign up to request clarification or add additional context in comments.

7 Comments

I need to make it working every time. What should I do then?
It depends on what your goal is. You could just remove your if statement if you want the code to always run.
No, I have two targets. This code need to be executed everytime FOR THAT TARGET, even when I run the app from the app icon.
@CleverError Is there a documentation or reference on this? -Thanks
@benrudhart I added a link to the documentation I could find.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.