MonoTouch - better console output in XCode's o

2019-08-04 14:04发布

问题:

We've been playing around with the new MonoTouch NUnit test project, which is quite nice.

Several of these tests we already run on Windows in CI software, and we print alot of stuff on the console to see what went wrong during the tests.

If we build and run these tests for MonoTouch, and view the console in XCode's organizer they look pretty ugly:

Feb 20 10:34:57 unknown UIKitApplication:com.ourcompany.ourapp[0xab78][8329] <Notice>: [Our usually pretty rainbows and unicorn console output here]

Is there a way to cleanup this output in iOS? It would be nice to at least replace "unknown" with something more meaningful, or remove it and UIKitApplication altogether.

Also, we don't mind to somehow call NSLog instead of Console.WriteLine if it will fix this.

回答1:

I think the easiest way, that would not require changes to your existing tests, is to:

  • Use the optional network logger. That will send every test results to a socket server, separating them from other logs coming from iOS devices; and

  • Call Console.SetOut with TouchRunner.Writer as a parameter (in AppDelegate.cs). This should (untested right now ;-) log every existing write you have to the console into the network logger.



回答2:

As far as I know there is no way to modify what is written to Xcode's console, since the stuff at the beginning of each line is written automatically by the system.

You can do some magic in a terminal with mtouch, grep and sed though:

/Developer/MonoTouch/usr/bin/mtouch --logdev | grep com.yourcompany.yourapp | sed 's/.*<.*>: //'