views:

146

answers:

3

Hello.

My application is running fine on the simulator, but not on the device. Basically, any documents from the web (PDF, Word, M4P videos) are working great on the simulator (and can be accessed from Safari on the iPhone). However, running on the iPhone, they don't display anything. Here's some sample code:

    // Set up the URL
documentViewController.documentUrl =  [NSURL URLWithString:[NSString stringWithFormat:mobileContentUrl]];
    // mobileContentUrl is something like: http://www.myserver.com/pathitem/Video.mp4" and can be accessed from Safari
[self.navigationController pushViewController:documentViewController animated:YES];

Within documentViewController I have:

- (void)viewDidLoad {
    [super viewDidLoad];
    [webView loadRequest:[NSURLRequest requestWithURL:documentUrl]];
} 

As I said, works like a charm in the Simulator...What could possibly causing this NOT to work on iPhone? How do I debug the issue???

A: 

The most likely cause is that you're trying to load a format that isn't supported by the phone. The Simulator uses many libraries from the Mac, so it often has much greater support than is available on the phone.

Can you access these URLs using MobileSafari on the phone?

Rob Napier
Yes, the URL's are all accessible using MobileSafari on the phone.
Phamer
A: 

PDF should work on the iPhone, as long as it doesn't require too much memory to display. The Simulator has pretty much unlimited memory while the iPhone is limited by the hardware, which I'm not sure but I think you have about 32 MB to play with on the oldest iPhones.

I'm not sure about the other formats. When you wrote M4P, did you mean mp4, or do you really mean M4P, because that is a protected AAC file that the iTunes Music Store uses, and you can't play those except through certain methods that enforce copy protection.

lucius
I meant mp4, that was a typo. None of the documents are displaying in my app, and they are small files (a 2 page PDF, a Word document, a 30 second video). All of them are accessible and play on the phone through Safari on the iPhone when I type in their URL's. Case sensitivity is correct. Any help on how I can go about debugging this?
Phamer
A: 

Okay, I found something else out. When I did my build for Simulator, I selected "Debug". In this case, everything works fine. If I build as "Release", the documents don't show in the Simulator too!! What is going on here so that "Release" breaks my app???

Phamer
I figured it out...I had delete the wrong .xib file. It worked in the Simulator because the compiled code was still there. When I did a "clean" before building for the device, the code for the .xib was gone and thus it didn't work. When I put the .xib back in there and re-build, all is good again.
Phamer