Game Development Community

*SOLVED* iTGB freezing at splash screen in the iPhone Simulator

by Richard Skala · in iTorque 2D · 12/29/2009 (1:24 am) · 16 replies

I'm trying to run any iTGB game on the iPhone Simulator, but I have not been able to get anything to run. The only thing that happens is that the "Powered By iTGB" screen shows up and just sits there.

I followed the "Simulator Test" tutorial in the documentation. Any ideas what I could be doing wrong?

#1
12/29/2009 (1:52 am)
I am using the following versions:

TGB: 1.7.4
iTGB 1.2
XCode: 3.1.4
MacOSX: 10.5.8
iPhoneSDK: Not sure, but most likely 3.1
#2
12/29/2009 (8:45 am)
I was looking through the iTGB target info, and I see:

Under Architectures->Base SDK:
iPhone Device 2.0 (missing)

I can change this value, but the same thing happens -- the iPhone Simulator just hangs at the "Powered By iTGB" screen. Also, what should the "C/C++ Compiler Version" be set to?

Does the 'Base SDK' have to be a certain value?

What should the other Build settings be?
#3
12/29/2009 (1:41 pm)
Hi,
i had the same problem and iv fixed it.
try to do the following steps:

1.open the project in xcode /application/T2d_iphone_beta/engine/compilers/xcode_iphone/torque2d.xcodeproj

2.go to Group&file and right click on Torque2D.
click on "Get Info".
in Build tab change Base Sdk to simulator 3.0 then close that window.
3. go to Targets and expand.
right click on iTGB then "get info"
change Base sdk to simulator 3 and also change the Product Name to your project name.
4. repeat this step ( step 3 ) with iTgb_script_Optimize
5. expand your Resource folder then add your project folders/file(s)
they are: Game,Common and Main.cs
6. from Build menu select clean all targets
then build your project but dont run yet.
** IMPORTANT THING:
Open your iphone simulator manualy then select Reset Contents and Settings.
this action did the magic for me,i hope it will do also 4 u.
now run your project from xcode.
#4
12/29/2009 (3:13 pm)
Thanks for your quick reply. I noticed that your directory says "T2d_iphone_beta". Are you using the 1.3 Beta?
#5
12/29/2009 (9:05 pm)
ok, I've had it working for a short while, and then it stopped working (the game would hang at the iTGB splash screen).

This is what I did to get it WORKING:
- I started from a fresh install of iTGB.
- Created my TGB Project, and ran it to compile the .cs files.
- Opened Torque2D.xcodeproj located in Xcode_iPhone folder.
- In XCode, under 'Groups and Files', right click on "Torque2D"->Get Info->Base SDK->iPhone Simulator 3.0.
- Under Targets, right click iTGB->Get Info->Base SDK->iPhone Simulator 3.0
- Removed the old Resources (common, game, main.cs)
- Added new Resources (common, game, main.cs from my project).
- Settings in drop down menu:
--> Active SDK -> Use Base SDK
--> Active Configuration -> Debug
--> Active Target -> iTGB
--> Active Executable ->iTGB - iPhone Simulator (3.0)
--> Active Architecture -> i386 (the only option)

- After that, I selected "Build and Go", and my project successfully ran on the iPhone Simulator.

#6
12/29/2009 (9:25 pm)
HOWEVER, after a while, the project STOPPED working, even though I made NO changes to the project settings.

This is all I did when it stopped working and started freezing at the "Powered By iTGB" screen:

- Made some script changes, so I played the project in TGB to compile the scripts.
- I ran the iPhone Simulator to see my changes. There was no difference, so (according to the tutorial) I probably needed to rebuild the project.
- In XCode, I did Build->Clean All Targets.
- AFTER DOING THE CLEAN, THE PROJECT STOPPED WORKING. That is, at this point, the game consistently hangs at the splash screen.

#7
12/29/2009 (9:37 pm)
I found that someone had a similar problem:
http://www.torquepowered.com/community/forums/viewthread/102023

I will investigate and report my findings here.
#8
12/30/2009 (7:42 am)

The problem you describe here are behind my skill for a moment,
but i suggest you to work with iTGB 1.3 Beta.

one more thing i do is to Reset Contents and Settings on the simulator
for every test i do.

Good Luck
#9
12/30/2009 (8:42 am)
After running through the debugger for a while, I found some things of interest:

-> main.cs is failing to load.
-> Any call to Platform::AlertOK() seems to completely freeze the simulator.


--------------------------
'main.cs' Failing to Load
--------------------------
In the first call to runEntryScript() (called from initGame()), this line fails:

success = str.open(defaultScriptName, FileStream::Read);

'defaultScriptName' is "main.cs", which of course means that iTGB failed to open main.cs. The obvious question is WHY is this file failing to load, even though it has been added to the project? I am going to look into this more.

-----------------------------------
Platform::AlertOK Freezing the Game
-----------------------------------
I used some ghetto printf debugging and found that any call to Platform::AlertOK when failing to load main.cs never completes. That is, the code never steps past those calls. I am also going to investigate this further.

**************************************************
*UPDATE: Platform::AlertOK(), simply calls iPhoneButtonBox(). Inside the call to iPhoneButtonBox(), there is an infinite while-loop at this line:

while (Alert.visible) {
[[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode beforeDate: [NSDate dateWithTimeIntervalSinceNow: 0.100]];
}

I'm not really that familiar with Objective-C as of yet, so I'm not certain what that does or how to fix it.
*
***************************************************


If anyone has any insight into these problems, please post them here. Have these specific issues been addressed in iTGB 1.3? I'd rather not move to a beta version, if at all possible.



#10
12/31/2009 (7:05 pm)
ok, when I change the following line in runEntryScript() from:

const char *defaultScriptName = "main.cs";

to

const char* defaultScriptName = "/Applications/TorqueGameBuilder/games/<MyGameFolder>/main.cs";

the game runs in the iPhone Simulator every time.

When running the game, what folder does it first look in?
#11
12/31/2009 (8:13 pm)
I used 'getcwd' and the value returned was:

/Users/<MyUserName>/Library/Application Support/iPhone Simulator/User/Applications/B508ABC4-BBCA-4CAD-8251-375AF6C4C5A8/MyGame.app
#12
12/31/2009 (10:59 pm)
SOLUTION:

While browsing through XCode, I figured out the solution.

Under Targets->iTGB->Copy Bundle Resources, I noticed that 'common' and 'game' were there, but main.cs was not.

So, I navigated to Groups&Files->Resources and dragged the 'main.cs' from there to Targets->iTGB->Copy Bundle Resources, and now it appears to be working every time I run the iPhone Simulator.
#13
01/04/2010 (2:09 am)
RS, before you had this problem did you add the syntax highlighting for Xcode found here www.torquepowered.com/community/forums/viewthread/102649?
#14
01/04/2010 (4:43 am)
You know, I think I did actually. I remember installing some sort of TorqueScript Syntax highlighting thing a while back, but I can't remember exactly what it was or where I grabbed it, but I think I got it from this forum thread, and it looks to be the same thing:

http://www.torquepowered.com/community/blogs/view/11193

How do I know if it is indeed installed?
#15
01/07/2010 (2:33 am)
Wow, I its been a while since I been on. To know if you installed it, there are two test. First in xcode if your script code (cs files) are colored then you have syntax highlighted text. :)

The other method is on your system see if the "~/Library/Application Support/Developer/Shared/XCode/Specifications/ " exist and it has three TorqueScript files.

The reason I bring this up is because, I had the same issue you stated here, and the problem looks like the TorqueScripts addition to Xcode caused the problem for me. I would like to see if this is the same for you also.

When you build Xcode check your debug console and see if you get an error like this "warning: no rule to process file '$(PROJECT_DIR)/../../../games/THV1.2/main.cs' of type sourcecode.torque for architecture armv6"
#16
01/07/2010 (4:05 am)
Yeah, all my .cs scripts are colored in XCode, so it makes sense that some kind syntax coloring is installed :) I just can't really remember doing it.

Anyways, I don't have the Specifications folder in that location, but I definitely get the "no rule to process warning" in the build output.

It is a possibility that the TorqueScript syntax highlighting thing is the cause of our problem, but either way, any time I have to add Resources, I always have to manually drag that main.cs file into the "Copy Bundle Resources" area.