Computer/Apple Ecosystem Insights
xcode swift print 디버그 모드일때만 동작하게 하기
생각하는달팽이
2021. 3. 25. 07:58
Under what circumstances?
- Under Xcode 12.2
- With Swift5
How to do?
It's very simple way to be disable print function.
If you are developing using Swift, it doesn't matter which swift file. Please insert the code below. In my case, I inserted it at the top of the AppDelegate.
import UIKit
import CoreData
...
func print(_ items: Any...) {
#if DEBUG
Swift.print(items[0])
#endif
}
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
...
After insert codes, please change build scheme environment debug to release.
follow below image.
If you need print again, changed scheme to debug.
Conclusion
Override function is very useful when i develop application by swift
Stay Hunger, Stay Foolish
반응형