Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add js file to my xcode project?

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!

like image 987
jin Avatar asked Jan 07 '10 02:01

jin


People also ask

How do I add a JavaScript file?

To include an external JavaScript file, we can use the script tag with the attribute src . You've already used the src attribute when using images. The value for the src attribute should be the path to your JavaScript file. This script tag should be included between the <head> tags in your HTML document.

Where do I put js files?

JavaScript in <head> or <body> You can place any number of scripts in an HTML document. Scripts can be placed in the <body> , or in the <head> section of an HTML page, or in both.


2 Answers

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.

like image 71
Rob Keniger Avatar answered Sep 23 '22 12:09

Rob Keniger


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.

like image 35
Genki Avatar answered Sep 22 '22 12:09

Genki