Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

iVidCam Free
(free)

Kid Art
($0.99)

iPUBQUIZ
(£1.19)

ArtStudio
($3.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 07-09-2009, 11:18 AM   #1 (permalink)
Registered Member
 
Join Date: Dec 2008
Posts: 52
Default Loading local .js file into uiwebview problem

I have a local .html, .js and images files in my bundle.

using this code
Code:
	NSBundle *bundle = [NSBundle mainBundle]; 
	NSString *path = [bundle bundlePath];
	NSString *fullPath = [NSBundle pathForResource:@"filename" ofType:@"html" inDirectory:path];
	[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:fullPath]]];
I am loading html file into uiwebview. Local pictures are showing but .js files are not being loaded so i can't use functions inside them..

tried to insert <a href="file.js">show js file</a> into html. link leads to nothing.

Any help?

10x
romeos28 is offline   Reply With Quote
Old 07-09-2009, 11:28 AM   #2 (permalink)
Registered Member
 
Join Date: Dec 2008
Posts: 52
Default

I just noticed that i am getting warnings about .js files

warning: no rule to process file '$(PROJECT_DIR)/CanvasGraph.js' of type sourcecode.javascript for architecture i386

Maybe I need set some rule in Xcode for js files??
If yes, what should i do?


Quote:
Originally Posted by romeos28 View Post
I have a local .html, .js and images files in my bundle.

using this code
Code:
	NSBundle *bundle = [NSBundle mainBundle]; 
	NSString *path = [bundle bundlePath];
	NSString *fullPath = [NSBundle pathForResource:@"filename" ofType:@"html" inDirectory:path];
	[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:fullPath]]];
I am loading html file into uiwebview. Local pictures are showing but .js files are not being loaded so i can't use functions inside them..

tried to insert <a href="file.js">show js file</a> into html. link leads to nothing.

Any help?

10x
romeos28 is offline   Reply With Quote
Old 07-09-2009, 11:33 AM   #3 (permalink)
Registered Member
 
Join Date: Dec 2008
Posts: 52
Default solution

The problem is solved.

Solution is here

10x

Quote:
Originally Posted by romeos28 View Post
I just noticed that i am getting warnings about .js files

warning: no rule to process file '$(PROJECT_DIR)/CanvasGraph.js' of type sourcecode.javascript for architecture i386

Maybe I need set some rule in Xcode for js files??
If yes, what should i do?
romeos28 is offline   Reply With Quote
Old 07-09-2009, 11:43 AM   #4 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 2,569
Default

Quote:
Originally Posted by romeos28 View Post
I just noticed that i am getting warnings about .js files

warning: no rule to process file '$(PROJECT_DIR)/CanvasGraph.js' of type sourcecode.javascript for architecture i386

Maybe I need set some rule in Xcode for js files??
If yes, what should i do?
It means XCODE doesn't know what to do with a .js file - compile it? link it? include it in the bundle unchanged? You want to include it in the bundle unchanged.

Look inside "Targets" in the the left pane, expand your target, and drag your file into "copy bundle resources." It should be added to the bundle the next time you build.

Maybe someone else knows how to add .js files to the list of files that get copied automatically?
__________________
smasher is offline   Reply With Quote
Old 11-08-2009, 07:53 AM   #5 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 2
Default

Quote:
Originally Posted by smasher View Post
It means XCODE doesn't know what to do with a .js file - compile it? link it? include it in the bundle unchanged? You want to include it in the bundle unchanged.

Look inside "Targets" in the the left pane, expand your target, and drag your file into "copy bundle resources." It should be added to the bundle the next time you build.

Maybe someone else knows how to add .js files to the list of files that get copied automatically?
Hello I have the same problem and this doesn't work. Same error though.
johncoles is offline   Reply With Quote
Old 11-08-2009, 10:26 AM   #6 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 2,569
Default

Quote:
Originally Posted by johncoles View Post
Hello I have the same problem and this doesn't work. Same error though.
Go the your build folder, right-click the built app, and choose "view contents" - you'll be able to tell if your .js file is being included in the bundle or not.

If the .js file is not in the bundle, it's still a build/target problem.

If the .js file is in the bundle, then either you're not including it properly in the html (notices it's not in a subfolder) or there's an error in your javascript - try dropping your html into safari and checking for errors.

PS - are you loading this javascript into a webview, or into mobile safari (openURL?)
__________________
smasher is offline   Reply With Quote
Old 11-08-2009, 05:12 PM   #7 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 2
Default

All sorted now
johncoles is offline   Reply With Quote
Old 11-08-2009, 08:06 PM   #8 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 2,569
Default

Quote:
Originally Posted by johncoles View Post
All sorted now
What was it? Inquiring minds and all that.
__________________
smasher is offline   Reply With Quote
Reply

Bookmarks

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


Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Stats
Members: 24,208
Threads: 38,991
Posts: 171,023
Top Poster: smasher (2,569)
Welcome to our newest member, JDBurgie
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:12 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0