3D doesn's work on a real iPad

I’ve turned my project into a native app in xcode by codea runtime,it includes some 3D object.Everything looks well when runs in iOS 5.1 simulator include the 3D texture.But… when i choose to run on my iPad2 in Xcode, after a short building ,the splash screen appears ,but only a black screen after that. what’s wrong?Please help me.

Are you getting any errors in the debug panel of Xcode?

Like @Syeswr my App runs fine in the Simulator but crashes when run on the iPad via Xcode. The error I’m getting is:

“attempt to perform arithmetic on global ‘gridWidth’ (a nil value)”

gridWidth is a global in Main and is only accessed in Main, so I’m not sure how to tackle this. Suggestions welcome.

@Reefwing Have you ever considered establishing it using its nil condition as the initial establishment outside the main?

Im sorry Reef did you mean the main or the main setup? I was thinking you meant the main setup and that was what my solution was for.

After all the main setup is where everything is usually setup. If it was not setup then there should be a nil value unless you wanted the nil value to begin with

Hi @Anonycode - I’m not sure what you mean, gridWidth isn’t used outside the Main Lua class. The code works fine in Codea and in the simulator in Xcode so the variable isn’t nil (usually). It is only a problem when running the code on the iPad via Xcode. I suspect it is a scope issue but hard to see how this can be inside the class, particularly since the variable is a global.

Unfortunately the Lua print function does not map across to NSLog so I can’t track down the problem that way. I am stuck.

I take it back - print does map to NSLog.

Is gridWidth defined as a local in just the function where it is used, or is it defined in main/setup?

.@Mark - it is defined in setup(), gridWidth = 0 to be precise.

Wait they have xcode for Ipad? I thought you could only publish using a macbook.

So basically you’re telling me that even if you were to use

if gridWidth == nil then
gridWidth = 0

right inside the top of your draw function? Does it still draw? What I’ve posted above is what I call a nil condition.

Its really a nil conditionsl statement. Where nil is accepted as a value where it would otherwise not be.

Sounds like setup isn’t being called for some reason. Try printing something in setup to see if it prints.

Hi @Dylan - that could be it. It prints something from setup() when using the simulator but not when running on the iPad (via Xcode) - it crashes first.

Any idea how to fix it?

just a thought, in my earlier experiments with using an external editor on the mac for editing codea stuff, I had this behaviour when I deleted a file but still had a reference to it in the plist.

.@gunnar_z - thanks for the suggestion. I double checked the plist, all files listed are present and accounted for.

I also tried deleting the project and rebuilding it from scratch (I’m getting very quick at this now!). I then tried running it on the iPad first but no joy. Same situation, works in the simulator fine but crashes on the iPad.

I can think of only two options, port the code to Objective C (which kind of defeats the purpose) or try submitting to the App store as is. I’m not sure if I do a build for submission whether I will get the working simulator version or the dud iPad version - for tutorial purposes whether the App gets approved is probably a moot point but still…

.@Reefwing would you be willing to send the project to me so I can test it with the runtime?

simeon [at] twolivesleft.com

.@Simeon - I certainly would be willing!!! It is on its way…

The code has already been published on this forum and in my tute so it isn’t much of a secret.

I have also sent you the custom sprites. I purchased most of these and the associated licence doesn’t permit me to share them freely, so I can’t post them here.

Thanks for the assistance - I appreciate it. I just hope it isn’t a stupid mistake on my part.

Thanks @Reefwing, I’ll test it soon.

Thanks mate.