I am working on submitting my first Swift app on app store and I was just curious on how to handle the print statements that I have in the app. For example
do {
try managedObjectContext.save()
} catch let error as NSError {
print(error)
}
I am working on submitting my first Swift app on app store and I was just curious on how to handle the print statements that I have in the app. For example
do {
try managedObjectContext.save()
} catch let error as NSError {
print(error)
}
You don't want to leave the print staments in for final release. I don't think apple will reject an app with print statements but better to not have them for release.
What you can do is create a global print func (new swift file or above any class) so your whole project can access it.
func print(items: Any..., separator: String = " ", terminator: String = "\n") {
#if DEBUG
Swift.print(items[0], separator:separator, terminator: terminator)
#endif
}
and call your print statements like normal
print("Hello")
You can also ignore the DEBUG flag and simply comment out the print line for release
func print(items: Any..., separator: String = " ", terminator: String = "\n") {
//Swift.print(items[0], separator:separator, terminator: terminator)
}