Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to print a message only in Debug mode.
iOS Swift
#if [1] print("This is Debug mode") #endif
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using RELEASE instead of DEBUG causes the code to run only in Release builds.
Forgetting the #if directive syntax.
✗ Incorrect
In Swift, the DEBUG flag is set for Debug builds, so checking #if DEBUG allows code to run only in Debug mode.
2fill in blank
mediumComplete the code to print a message only in Release mode.
iOS Swift
#if [1] print("This is Release mode") #endif
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using RELEASE directly is not a default flag in Swift builds.
Forgetting the #if and #endif directives.
✗ Incorrect
The condition #if !DEBUG means the code runs when DEBUG is not set, which is typically the Release build.
3fill in blank
hardFix the error in the code to print a debug message only in Debug builds.
iOS Swift
#if [1] print("Debug build active") #endif
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using RELEASE or other undefined flags causes the code not to compile or run as expected.
✗ Incorrect
The correct flag to check for Debug builds is DEBUG, not RELEASE or other names.
4fill in blank
hardFill both blanks to define a variable only in Debug mode and assign it a value.
iOS Swift
#if [1] let mode = [2] #endif
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning the string "Release" inside the Debug block.
Using RELEASE flag instead of DEBUG.
✗ Incorrect
The variable should be defined only in Debug mode using #if DEBUG and assigned the string "Debug".
5fill in blank
hardFill all three blanks to print different messages for Debug and Release modes.
iOS Swift
#if [1] print([2]) #else print([3]) #endif
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using RELEASE flag which is not predefined.
Mixing up the print messages.
✗ Incorrect
Use #if DEBUG to check Debug mode, print "Debug mode active" there, else print "Release mode active".