Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS - How to determine if app was built as Debug or Release

Tags:

Yes, I know that this question has already been asked and answered three times here at Stack Overflow.

Xcode / iOS: How to determine whether code is running in DEBUG / RELEASE build?

Checking if the app is build as release

How can know Debug or Release in iOS App?

But I have two problems with all of these answers.

All of the answers, except the last answer to the third question, are based on testing preprocessor definitions at build time. I would prefer some technique that makes the determination at runtime, just to be completely sure there is no divergence between the preprocessor definitions and how the actual build ended up getting done. (OK, that's probably not possible.)

But another point is that I would prefer to have the code that makes the determination in a library module, but that the test is based on how the main app module was built. So if (by accident?) the library module is a Debug build but the main app module is a Release build, then I'd like the test to say the app is a Release build.

Maybe this doesn't make much sense (I'm totally new to iOS), but for my Android app this is possible - see the first answer here: How to check if APK is signed or "debug build"?

So I'm wondering if some similar technique exists for iOS apps. Preferably something that can be done from Swift.

like image 303
RenniePet Avatar asked Dec 26 '16 07:12

RenniePet


1 Answers

You have the following entry in your Info.plist file:

<key>Configuration</key>
<string>${CONFIGURATION}</string>

which you can access via:

var config = Bundle.main.infoDictionary?["Configuration"]
like image 50
Vishnu gondlekar Avatar answered Sep 22 '22 16:09

Vishnu gondlekar