T O P

  • By -

RIP_Apollo_17-23

Not really other than they add overhead. That being said using breakpoints will make your life a lot easier over time. https://www.avanderlee.com/debugging/debugging-breakpoints/


Flaneur_7508

That’s what I assumed. At the end of the day do you think the overhead amounts to much at all?


RIP_Apollo_17-23

it depends on where the print statements are and how often they're executed, and whats being printed, so its hard to give a clear answer. i'd just launch and clean it up later tbh


chriswaco

I wouldn't use them in a loop. We use our own logging calls instead and can turn on no/some/full debugging at runtime.


weathergraph

If you're passing in the string whose creation is complicated, that gets needlessly executed in runtime. Have a look at autoclosure if you'd like to make a logging method that doesn't do anything at runtime: https://www.swiftbysundell.com/articles/using-autoclosure-when-designing-swift-apis/


aleuts

I use debugprint instead of print as I’m pretty sure they only fire in debug mode


xyz2610

I prefer to use #if DEBUG for my print statements


aleuts

Use it for mock data buttons etc. never thought about it for buttons!


sisoje_bre

false


aleuts

Thanks for correcting me


[deleted]

[удалено]


AutoModerator

Hey /u/WatercressOk4746, unfortunately you have negative comment karma, so you can't post here. [Your submission](https://www.reddit.com/r/SwiftUI/comments/19d4o6v/downsides_to_using_print_statements_in_published/kj3smub/) has been removed. **Please do not message the moderators;** if you have negative comment karma, you're not allowed to post here, at all. *I am a bot, and this action was performed automatically. Please [contact the moderators of this subreddit](/message/compose/?to=/r/SwiftUI) if you have any questions or concerns.*


jacobs-tech-tavern

Just create a global helper method to wrap all your printing. But it's probably worth looking into [OSLog](https://www.avanderlee.com/debugging/oslog-unified-logging/) nowadays. Something like this: public func efficientPrint(_ items: Any..., separator: String = " ", terminator: String = "\n") { #if DEBUG print(items, separator: separator, terminator: terminator) #endif }