17

This answer addresses how to show the console log in Xcode, but output printed with the print function in Swift that appear in the development build of the app do not appear in the release build.

To be clear, the app was downloaded from the App Store and then Xcode was opened with the console log showing as described by the SO answer.

This answer suggests the print function continues to send output to the console even for release builds.

However, lines that printed to the console for the development build no longer appear for the App Store version.

How do you view the same console output that appears for the development build?

Community
  • 1
  • 1
Crashalot
  • 33,605
  • 61
  • 269
  • 439

4 Answers4

12

The print function continues to send output even for release build, but it won't appear at the console. To see the output, go to Window -> Devices (or press cmd+shift+2). Connect your device to the Mac and you'll see all the output.

(By the way - it's good practice to remove the logs for the release versions, so you might want to consider it)

Witterquick
  • 6,048
  • 3
  • 26
  • 50
  • This is for an app downloaded from the App Store? Or are you talking about an Ad Hoc distribution? – Crashalot Jul 03 '16 at 20:41
  • Hmm, didn't seem to work on the Ad Hoc distribution. The console printed stuff, but it wasn't output from our app's `print` calls. – Crashalot Jul 04 '16 at 07:38
  • And did it worked on the App Store version? any chance someone else in the project has overridden print function for #release versions? – Witterquick Jul 05 '16 at 08:49
  • Sorry for the confusion. It didn't work for the App Store one. It worked for the Ad Hoc distribution. – Crashalot Jul 05 '16 at 09:29
  • Weird, Ad Hoc distribution and AppStore should be exactly the same. so no one override the print func for release? – Witterquick Jul 05 '16 at 10:15
  • Are you sure App Store builds should show print output? I read somewhere afterward (will need to find where if you want to see it) saying this isn't the case: it should only work for Ad Hoc (which this experience supports as well). – Crashalot Jul 05 '16 at 18:40
  • Well, the print function will still be called in release versions (as you saw in the links you provided, where people try to override it so it would print nothing). At the Ad Hoc version, did you see the print logs ? or just the NSLogs ? – Witterquick Jul 05 '16 at 21:11
  • For the Ad Hoc versions the console displayed print output just like the developer builds. The App Store version did not. By NSLogs, do you mean the console output? Those links provided do not state whether the release builds are App Store versions or Ad Hoc versions, hence the confusion. – Crashalot Jul 05 '16 at 22:08
  • Have to say that I never checked it, because I always remove the print at the store version. by NSLog, I mean that if you use the NSLog("print this") you will see the log for sure, but for print("print this"), well, never tried it on the store version. – Witterquick Jul 06 '16 at 06:57
  • 2
    OK, up voted for all the detailed responses even though the answer didn't quite work so you should still win the bounty. Thanks for the help! – Crashalot Jul 06 '16 at 16:52
  • Is this also works for iOS 10 devices? Because it is not working in my case but it is working for iOS 9 devices. – Zuhair Hussain May 05 '17 at 13:24
  • Try viewing the logs at the Console app (not xcode console, but the Mac Console - Connect your device and select it at the Console). – Witterquick May 06 '17 at 15:44
5

If you want to see the same logs from the release build, you need to use NSLog as before.

Hank Liang
  • 71
  • 5
  • the `print` function doesn't work? this answer (http://stackoverflow.com/a/32893825/144088) suggests it continues to print to the console even for release builds. is it wrong? – Crashalot Jul 03 '16 at 01:02
  • As I tested with my app store build, the "print" function won't print the log. – Hank Liang Aug 10 '16 at 02:51
2

1) Connect your device to your mac machine

2) Open Xcode

3) Go to Window -> Device (select your device)

You can see console log as output

Sachin Nikumbh
  • 911
  • 11
  • 11
0

The log should appear in console normally for development version. Make sure you use -D DEBUG flag only for other linker flags of Debug, and not on release. Expand "Other linker flags" first to notice multiple values.

Krešimir Prcela
  • 4,257
  • 33
  • 46