Game Development Community

dev|Pro Game Development Curriculum

iecho (echo output from iOS Devices)

by Edward F. Maurina III · 12/29/2010 (7:45 am) · 3 comments

** Alternative to enableDebugOutput() as discussed here. **

If you're like me, you have probably been stuck debugging a script (or other) error on your iOS device (iPod, iPhone, or iPad) and wished that you had the ability to echo to a console.

This resource will give you that ability.

Note: Right now, this resource requires that you have a PC running window to see the log output. Alternately, if you are running an editor on OSX that can display echo in a console, that will work too. However, since I'm mostly a PC guy, my 'steps' below will be for PC users. Just remember, the server is the place where the output will be printed to the console.

Note 2:I apologize if this resource is a little hard to follow, but I assume you know a little about writing games with iT2D if you intend to use this resource.

Steps

1. Download this script: iecho.cs.

2. Add the script to your game.

3. Get the IP address of your PC (where the output will be printed) and modify this line in iecho.cs to contain that address =>
$TCPServerMachineAddress = "192.168.123.2";

4a. Run your game on a Windows machine (or on OSX if you have a way to see the console output) and have that image call this function: initTCPServer(); // This must be done before the client is started.

4b. Run your game on an iOS device (or in the simulator and have that image run this function: initTCPClient();

5. Use the console function iecho() instead of echo().


If you followed the above steps correctly, the iecho() output from your iOS device (or simulator) will be redirected to the Windows copy and will be printed in the console window.

Note 3: An easy way to get a console window on Windows machines is by adding this code to "/main.cs":
enableWinConsole(true);

Alternately, if you use Torsion, you can run the windows version from Torsion and get the console output there.

Note 4: You may need to enable networking in your project settings for this to work. I already had it on when testing the code so I'm not 100% sure.

Note 5: An easy way to start the server and client (as discussed in steps 4a and 4b. is to create two buttons or click-able objects on the screen. One button for "initTCPServer();" and one button for "initTCPClient();" Then, simply click the server button on the PC copy first and the client button on the iOS device second and you're in business.

Note 6:This could probably also be done with "commandToClient()" and "commandToServer()", but I already had the TCPObject code in place so I used it.

#1
12/29/2010 (7:51 am)
In case it isn't clear from the resource code, what this resource does is the following:
1. Creates a TCPObject server on the machine where the output will be directed (printed out).
2. Creates a TCPObject client on the iOS device (or simulator).
3. iecho() then sends a string from the client to server and the server echos it to the console.


#2
04/30/2011 (10:38 am)
So this will send echos from the device to the computer?



#3
04/30/2011 (4:43 pm)
Yes, it is a round-about way to get echo output from your idevice. It basically mirrors the echo output from the idevice to a running copy of the app on your PC.

There is a more elegant way to get echo output directly from XCode, but I haven't worked it out. (Admittedly, I'm better on the PC than the Mac).