본문 바로가기
Programming/Swift

xcode swift print 디버그 모드일때만 동작하게 하기

by 생각하는달팽이 2021. 3. 25.

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.

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

반응형

'Programming > Swift' 카테고리의 다른 글

iOS Not found device  (0) 2022.12.25
SwiftUI 하면서 생긴 오류 정리  (0) 2019.10.20
[Swift] Classes  (0) 2016.02.10
[Swift] Enumerations  (0) 2016.02.10
[Swift] Optional  (0) 2016.02.10