Linked Questions
42 questions linked to/from #ifdef replacement in the Swift language
4
votes
1
answer
4k
views
Swift: Multiple targets handling: macros not working [duplicate]
from the reference How to handle multiple targets in XCode using swift language? and https://www.appcoda.com/using-xcode-targets/
I have created three targets, each target having different bundle ids ...
2
votes
2
answers
693
views
Objective-C code under #ifdef not visible in Swift [duplicate]
I'm adding some swift classes to Objective-C project.
The problem is that code under #ifdef in Objective-C classes is not visible in Swift classes. I've defined some static properties to reflect #...
1
vote
0
answers
245
views
Access Environment Variables from Swift [duplicate]
In Objective-C often environment variables like DEBUG are used for conditional compilation. Is there a way to do something similar in Swift?
0
votes
0
answers
120
views
How to add developer-specific code in swift? [duplicate]
I want to add a code which will be executed only for me (not for other developers on project) in swift project. In Objective-c it I can achieve this by
adding preprocessor macro
DEVELOPER_NAME=${...
0
votes
0
answers
62
views
how to conditionally compile swift according to the branch [duplicate]
I konw there is a way like this:
#if DEBUG
let a = 2
#else
let a = 3
#endif
but I want ask,
I there a way to fully control the symbol by build step script?
So that I cant test my git branch and ...
290
votes
12
answers
193k
views
How to determine whether code is running in DEBUG / RELEASE build?
I am making an app that processes sensitive credit card data.
If my code is running in debug mode I want to log this data to the console and make some file dumps.
However on the final appstore ...
133
votes
17
answers
57k
views
How to let the app know if it's running Unit tests in a pure Swift project?
One annoying thing when running tests in Xcode 6.1 is that the entire app has to run and launch its storyboard and root view controller. In my app this runs some server calls that fetches API data. ...
184
votes
7
answers
67k
views
In absence of preprocessor macros, is there a way to define practical scheme specific flags at project level in Xcode project
Before swift I would define a set of schemes for alpha, beta, and distribution builds. Each of these schemes would have a set of macros that were defined to gate certain behaviors at the project ...
195
votes
5
answers
49k
views
How to tell at runtime whether an iOS app is running through a TestFlight Beta install
Is it possible to detect at runtime that an application has been installed through TestFlight Beta (submitted through iTunes Connect) vs the App Store? You can submit a single app bundle and have it ...
30
votes
8
answers
13k
views
Disabling NSLog For Production In Swift Project
So this answer Do I need to disable NSLog before release Application? gives a great way to disable NSLog in a production environment, but unfortunately, this solution does not seem to work for Swift ...
11
votes
5
answers
13k
views
Swift: iOS Deployment Target Command Line Flag
How do I check the iOS deployment target in a Swift conditional compilation statement?
I've tried the following:
#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_8_0
// some code here
#else
...
6
votes
2
answers
4k
views
Detect if the iPhone is running a Debug/Distribution build at runtime
Is it possible at runtime to detect if the application that is running was compiled with debug or distribution.
4
votes
3
answers
2k
views
How should I replace these screen size and device type macros in Swift?
Back in Objective-C, I defined the following macros in a constants.h file:
#define IS_IPHONE5 (([[UIScreen mainScreen] bounds].size.height-568)?NO:YES)
#define IS_IPAD (UI_USER_INTERFACE_IDIOM()==...
9
votes
2
answers
9k
views
How to identify if Swift was compiled with Optimization
As some of you may be aware when running in fully Debug-Mode swift can be terribly slow. Is there a way i can print out a message in code or to the GUI to let me know if I somehow forgot to compile ...
5
votes
2
answers
2k
views
How to conditionally compile version-specific Swift (1.2 vs 2.0) code in the same source file?
I have a Swift demo project that comes bundled with my framework. I want to ensure that the Swift code in the demo compiles successfully with both Xcode 6 (Swift 1.2) and Xcode 7 (Swift 2.0) without ...