0

Possible Duplicate:
Debugging iOS/AIR content on the device

I'm porting my Air app to iPad. I compiled it with:

adt -package -target ipa-ad-hoc -storetype pkcs12 -keystore store.p12 -storepass ****** -provisioning-profile profile.mobileprovision app.ipa app.xml app.swf

App was deployed on device through iTunes. When I launch app on iPad I get a black screen. Looks like some exception is thrown or something like that. How can I see that exception? Or if to be more general, how do you guys debug iOS app on Windows?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Eugeny89
  • 3,797
  • 7
  • 51
  • 98

2 Answers2

1

As far as my knowledge goes there is no remote debugging with AIR and iOS possible. So you have to revert to creating a scrolling text field somewhere and show log/debug texts there.

Edit: See Debugging iOS/AIR content on the device.

Edit2: Short tutorial video on debugging on iOS via Flash Prof CS5.5: http://www.youtube.com/watch?v=DanNBN89uhs

You can use the uncaughtErrorEvents property (found in your main documents loaderInfo property) to catch any unhandled error and show it also in the text field (see http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/LoaderInfo.html#uncaughtErrorEvents)

There is also the possibility to define compiler constants to enclose debug log statements within actionscript so you can easily turn them on and off.

I normally also test first the application on my windows before creating an iPad version of it.

Final tip: remember that only your main swf can contain actionscript.

Edit:

Here is a example, try to add this code before any other actionscript is executed:

import flash.events.UncaughtErrorEvent;
import flash.events.Event;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFieldType;

// ...
// textLog contains errors
var textLog: TextField;

// make sure there is a uncaughtErrorEvents property (in case of older player)
if (this.loaderInfo.hasOwnProperty('uncaughtErrorEvents'))
{
  // listen for uncaught error events
  this.loaderInfo['uncaughtErrorEvents'].addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, handleUncaughtError);
  // make sure text field stays on top
  this.addEventListener(Event.ENTER_FRAME, handleEnterFrame);
  // create TextField at bottom using 1/5th of stage height
  textLog = new TextField();
  textLog.width = this.stage.stageWidth;
  textLog.height = Math.floor(0.20 * this.stage.stageHeight);
  textLog.y = this.stage.stageHeight - textLog.height;
  textLog.multiline = true;
  textLog.wordWrap = true;
  textLog.defaultTextFormat = new TextFormat('_sans', 10);
  textLog.type = TextFieldType.DYNAMIC;
  textLog.background = true;
  textLog.backgroundColor = 0xCCCCCC;
  this.addChild(textLog);
  textLog.appendText('Catching errors\n');
}

// show error and scroll to bottom line
function handleUncaughtError(anEvent: UncaughtErrorEvent): void
{
  textLog.appendText(anEvent.error + '\n');
  textLog.scrollV = textLog.maxScrollV;
}

// make sure textLog stays on top of all other children
function handleEnterFrame(anEvent: Event): void
{
  if (this.getChildIndex(this.textLog) != this.numChildren - 1)
  {
    this.addChild(this.textLog);
  }
}
Community
  • 1
  • 1
Josha
  • 579
  • 3
  • 7
  • App works as it should on windows. I can't trace anything, as I see blank screen on startup. – Eugeny89 Oct 26 '11 at 20:17
  • this blank screen is using the background color as set in your AIR/SWF? Only thing I can think off, that there might be an error/exception happening at the start, halting the actionscript. Not sure if with AIR in iOS this means the app stops completly. – Josha Oct 26 '11 at 22:22
  • Of cause it's an exception, the question is that I don't know how to see it – Eugeny89 Oct 27 '11 at 09:57
  • I guess you have to try to create the text box and install the uncaughtErrorEvents before doing anything else. – Josha Oct 27 '11 at 14:41
  • I think there's something with resources or something like that – Eugeny89 Oct 27 '11 at 15:11
  • 1
    does the app use any other files? – Josha Oct 28 '11 at 21:41
  • >>>Final tip: remember that only your main swf can contain actionscript.>>> Are you sure about that? My app uses an wrapper for squiggly spell checking lib – Eugeny89 Nov 01 '11 at 14:44
  • 1
    afraid so :( Various Flash forums mention this. I suspect that with iOS Flash recompiles the whole SWF into iOS app; instead adding a AIR player stub to the SWF. Probably due to one or other form of restriction set by Apple. – Josha Nov 02 '11 at 08:59
  • BTW, I add -connect to build command and all started to work – Eugeny89 Nov 02 '11 at 10:44
0

Are you using Air 2.7 or 3.0? I had this issue when I was using a library built with alchemy. For some reason using the alchemy library caused a blank screen. Remote debugging didn't help me either because it was before everything. I fixed it by not including the alchemy library (the library was for fast JSON parsing)

K2xL
  • 9,730
  • 18
  • 64
  • 101