How to add js file to my xcode project?
Asked Answered
G

3

32

I add some js and css files in my xcode left project tree. but when I build this project , I got the warning : no rule to process file '$(PROJECT_DIR)/js/builder.js' of type sourcecode.javascript for architecture i386

I think if I lost some setting with my project in xcode , but How to add some like js and css files? Thank you very much!

Guglielmo answered 7/1, 2010 at 2:58 Comment(1)
What do you want it to do with the JS and CSS files?Sanatorium
G
80

When you add the JavaScript file, Xcode detects that the file is a source code file, assumes you want to compile it and automatically adds it to the Compile Sources build phase.

To stop Xcode trying to compile it and make it copy the file instead, expand your target in the Groups and Files list, remove the JavaScript file from the Compile Sources build phase and add it to the Copy Bundle Resources build phase.

Gogetter answered 7/1, 2010 at 6:34 Comment(1)
If yo need to make multiple update to your js files, see my work around there: #4431286Gormless
W
19

For Xcode 4, click on the main project, click on Build Phases. Open up Compile Sources and Copy Bundle Resources then you can then simply drag the files from one to the other.

Wintertime answered 7/9, 2011 at 20:13 Comment(0)
T
1

I got the same problem and I could solve this problem with simple technique in Xcode5. when you add/drag your HTML files into Xcode bundle you need add them by grouping as 2 types

1.assets

2.index.html

you need to add these two files only.

assets folder contains all HTML files like images,.js, content,css. All HTML files should be
included in assets folder. what I mean is you need to group all HTML files in assets folder as a single folder.

Then you drag that particular folder which contains ASSETS and INDEX.HTML files into Xcode bundle.

Then do some changes in your controller declaration and implementation sections. That's it you can run your application in simulator now.If any one have not understood my answer please let me know I will add clear information with screen shots.

I hope it will help some one..Thank you!

If anyone have any doubts still let me know i'll explain step by step

Tailing answered 21/3, 2014 at 11:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.