View Full Version : Simulator 2.0/2.1 vs 2.2

Mar 4, 2009, 10:53 AM
Ive been developing my app under the assumption that Im using the 2.2 simulator because it says so in the drop-down-box in the top right of xcode. It says "Simulator - 2.2 Debug". under "Active sdk".

Under "Active Executable", however, there is another choice, and here I apparently have had the "MyAppsName - iPhone Simulator (2.0)" checked.

Now I tried selecting the "MyAppsName - iPhone Simulator (2.2)" instead, but that makes my app unresponsive in some of my views. (2.1 works fine though).

Since all my views are mainly uiwebviews that are loaded with local html-files, I can quickly assess that the pages that becomes unresponsive are the ones with embedded sound.

This is the js/html-code that I use to load sound:

<script type="text/javascript">
function EvalSound(soundobj) {
var thissound= eval("document."+soundobj);

<img src="icon_sound.png" onClick="EvalSound('L1')">

<embed src="L1.mp3" name="L1" autostart="false" width="100" height="100" hidden="true" />

This is the obc-code that I use to load the webview and enable it to load local content:

// --------------------------
// --------------------------

// Gets Url from outline.plist
NSString *tempUrlString = leafViewController.savedUrlString;// [item objectForKey:@"itemUrl"];

// Gets local file
NSString *htmlFile = [[NSBundle mainBundle] pathForResource:tempUrlString ofType:@"html"];
NSData *htmlData = [NSData dataWithContentsOfFile:htmlFile];

// --------------------------
// --------------------------

// 1. Gets the path to the main bundle root folder
NSString *imagePath = [[NSBundle mainBundle] resourcePath];

// 2. Need to be double-slashes to work correctly with UIWebView, so change all "/" to "//"
imagePath = [imagePath stringByReplacingOccurrencesOfString:@"/" withString:@"//"];

// 3. Also need to replace all spaces with "%20"
imagePath = [imagePath stringByReplacingOccurrencesOfString:@" " withString:@"%20"];

// 4. Loads the local html-page
[leafViewController.webView loadData:htmlData MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:[NSURL URLWithString:[NSString stringWithFormat:@"file:/%@//",imagePath]]];

And this is what the debugger reports when the app becomes unresponsive:

int main(int argc, char *argv[])
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

int retVal = UIApplicationMain(argc, argv, nil, nil);

[pool release];
return retVal;

Here I get a path as an Argument -> argv -> *argv with something highlighted in red (supposing this is the error)
/User/myName/Library/Application Support/iPhone Simulator/User/Applications/F0340A73-XXXX-XXXX-XXXX

There is both a folder and a .sb-file in that directory whichs names start with Applications/F0340A73-XXXX-XXXX-XXXX. However, they have an additional -XXXXXXXXXXXX (ie. 12 extra characters) added.

Is this a known issue between versions? Will my app not function on iphones with version 2.2? Do you know of a solution? Im thankful for any help.

Mar 4, 2009, 11:29 AM
UIWebView (as a side effect of Safari) got much better between 2.0 and 2.1. If your app requires 2.1 or higher then build for 2.1. Anyone with a greater or equal version should be able to run your app. If this is not the case then file a bug report with Apple.

Mar 4, 2009, 11:56 AM
So even though the sdk's iPhone simulator 2.2 will crash when running my app, if I develop for the iPhone sdk 2.0 (which is stable) instead of 2.2 it will run on any iPhone/iPod higher or equal to 2.0 because even if it has 2.2 installed it will actually use the 2.0 sdk instead of the newer version (since that was the sdk the app was developed for)?

Did I understand things correctly?

Mar 4, 2009, 04:47 PM
It appears to have to do with one single line of code:

<embed src="L1.mp3" name="L1" autostart="false" width="100" height="100" hidden="true" />

Apparently this is what makes it crash - embedding sound.
I tried removing it, and the page loads fine.
I even tried setting the src to a fake mp3 (ie one that doesnt exist), and then the page loads fine, and the player even tries loading it.

Whats the delio!?