Is there a way to have the app crash and burn at runtime on print()?
Override print() in Swift runtime with an implementation that'd preconditionFailure("STOP using print()").
Basically it's a part of the team Pavlov's dog training in progress: I want people to use debugPrint rather than print to pollute console in debug builds only.
UPD20180525: matt is right: print output does not go to a live console of a real device, it somehow only ends up on lldb console.
NSLog output thought DOES go to the device's console so what needs to be killed at runtime or compile time for non debug builds is NSLog
This is what was actually needed:
#if DEBUG
#else
public func NSLog(_ format: String, _ args: CVarArg...)
{
}
#endif
(cause there is no real need to get rid of print which is harmless in release builds)
print.printwithdebugPrint. Create a logger, and use that (that way you can control where the logs go and put them in reasonable formats). Don't try to break Swift. (There is no wise way to implement what you're describing.) With a logger in place, you can even just grep for "print(" in a git commit hook if it's critical to you. But the right way to address all of this is code review, not tricks to crash the program. When you say "I want people to…" do you mean "my team has agreed we all want…" If not, then you'll need to fix that piece first, and the rest will come naturallyprintwould be, since it does nothing when the release-built app runs off the device.