29

I'm having a pretty strange issue I haven't encountered before in Unity - I'm unable to get my Debug.Log() calls, or my NSLog() calls from Unity and Xcode to display to the console when I build the application to my device.

Here's what I've been trying so far:

  1. Build to Xcode from Unity with the Development Build and Script Debugging options enabled (tried using both 'Build' and 'Build and Run', no difference).
  2. From Xcode, I've tried just building by using Product->Run (CMD+R) with my device plugged in via USB. I've also tried Product->Archive and installing the .ipa file manually, neither have worked.
  3. Plugged in Device and attempted to retrieve logs from Xcode's default console, the Organizer window by selecting 'Console' under my Device, and using the iPhone Configuration Utility.

The only output I get from my application is this line in the main.mm file generated by Unity in the Xcode project:

NSLog(@"-> registered mono modules %p\n", &constsection);

I don't see the other default logs and prints that are in the project by default either, such as the following line in UnityAppController.mm:

printf_console("-> applicationDidFinishLaunching()\n");

The odd thing is, I saw all of these logs and my own at one point very early on the in the project, but now I no longer do. I've tried stepping back and reverting to an earlier build, but I'm still not seeing any logs. I've also tried building to a new Xcode project and building that to my device, but with no luck either.

What are some things I could be missing? I've looked over as many other topics as I could and tried several suggestions, but haven't been able to find anything so far. Is there any reason I would receive the first debug log from Unity about registering mono modules but none of the others? I can't find a good reason, and its making my debugging on the device a living pain without them.

For reference, I'm using Unity 4.5.1 and Xcode 5.1.1.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Retribution
  • 323
  • 4
  • 8
  • I've noticed a similar similar issue some time ago after an iOS upgrade (iOS 7.1?). But then the only time the logs were readable was when it was in product->run mode - not in ipa or the second run Just on the first one, and sometimes not even then. Perhaps this is related. What iOS are you using? Also, take a look at the console in the [iphone configuration utility](http://support.apple.com/downloads/#iphone%20configuration%20utility), back then it worked more often then the xcode one. Also this might have been a placebo, but disconnecting and connecting the device again seemed to help. – Krzysztof Bociurko Aug 07 '14 at 10:25
  • I believe thats when my issues started as well - I upgraded to iOS 7.1.2 a few weeks ago and realized thats around the time that I wasn't able to retrieve logs anymore. Unfortunately, I have already tried using the iPhone Configuration Utility to check the console, and I restarted my machine as well as the phone to see if that would help, but no dice. – Retribution Aug 07 '14 at 12:50
  • Maybe a stupid guess, but did you check the logging boolean in player settings? – Smileynator Mar 29 '16 at 12:44
  • Best solution I can offer is one of the [asset store](https://www.assetstore.unity3d.com/en/#!/content/13550) options that allows for logging to the screen. I recall one of them hooks on `Debug.Log()` but I've forgotten which one. – Draco18s no longer trusts SE Apr 14 '17 at 17:23
  • Use Lunarconsole by spacemadeness –  Jul 19 '17 at 10:21

1 Answers1

1

Have you tried attaching to the Unity log message event?

public Text logText; //someRandomUnityUITextThatIsShownOnScreen 

void Start(){
Application.logMessageReceived += HandleLog;        //can disable logging with Application.logMessageReceived -= HandleLog; 
}

void HandleLog(string logString, string stackTrace, LogType type)
{
  logText.text += "\n | " + logString; 
//of course you can use the logstring and stacktrace to do whatever you want, write into a debug txt file or smth.
}

if that doesn't work either, it is probably an iOS bug right now

Aryan
  • 3,338
  • 4
  • 18
  • 43