Reputation: 1502
Can I know if a piece of code like print
, assert
, log_os
etc compiles on DEBUG only besides looking at documentation, as it is often incomplete and the implementation is not public?
If not, is my only solution to call every code that is for debug purposes between compiler preprocessors like this:
#if DEBUG
assert(true)
print("Hello")
#endif
I want to make sure that the code is not present at all for safety and performance reasons.
Will a code like this be optimised by the compiler and removed completely on release, or will it have some assembly left like a jump to a function that is empty:
func DebugOnlyPrint(message: String) {
#if DEBUG
print(message)
#endif
}
Upvotes: 3
Views: 80
Reputation: 6547
To see the outputs run the release version and then in Xcode go to Window -> Devices
(or press cmd+shift+2).
Now connect an iOS device to the Mac and do > View Device Logs
and you'll see all the output.
Upvotes: 2