Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-24-2010, 10:51 AM   #1 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 2
47primes is on a distinguished road
Default Files not linking when building to device

Hello,

I am building my first app for the iPhone platform. The app stores read-only text in XML files which the user can search. The XML files are stored in subdirectories within the resources folder and are parsed using TouchXML. Everything works well in the simulator. However the XML files as well as a background image I add to a UIImageView for use as a background in some controllers cannot be found when I built the app on my iPhone device which causes the app to crash. It's running iOS 3.1.3.

Any help would be greatly appreciated.
47primes is offline   Reply With Quote
Old 09-24-2010, 02:18 PM   #2 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 2
47primes is on a distinguished road
Default

Here's further information about the problem:

I am accessing the image for the UIImageView as such:

Code:
UIImage *backgroundImage = [UIImage imageNamed:@"parchment.jpg"];
I loaded the file parchment.jpg in my Resources folder in XCode.

To retrieve the xml files, I have some class methods that use NSHomeDirectory(). Each XML file is located in a subdirectory under the Resources folder in XCode:

Code:
+ (NSString *) directoryPathForVersion:(NSString *)version {
    return [[self applicationPath] stringByAppendingPathComponent:version];
}

+ (NSString *) applicationPath {
    NSFileManager *fileManager = [NSFileManager defaultManager];
    NSString *path = NSHomeDirectory();
    return [path stringByAppendingPathComponent:[[fileManager contentsOfDirectoryAtPath:path error:NULL] lastObject]];
}
So in another method, I try to build a path to an individual file:

Code:
NSString *directoryName = @"esv";
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *path = [self directoryPthForVersion];
if (![fileManager fileExistsAtPath:path]) {
    [NSException raise:InvalidBookException format:@"Invalid path %@", path];
}
This exception is never thrown in the simulator, but it's crashing the device on startup because I implement this logic in applicationDidFinishLaunching:

When I commented out this code in applicationDidFinishLaunching:, I get the error about not being able to access parchment.jpg. If I comment out both of these calls, the app builds on my device, but it of course doesn't work as I had intended.

Last edited by 47primes; 09-24-2010 at 02:21 PM.
47primes is offline   Reply With Quote
Reply

Bookmarks

Tags
build, device, xml

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 351
11 members and 340 guests
2ndSegment, djohnson, Hamad, headkaze, markuschow, mistergreen2011, Objective Zero, pungs, revg, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,655
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, pungs
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:05 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0