如何将 js 文件添加到我的 xcode 项目中?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2017937/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to add js file to my xcode project?
提问by jin
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
我在我的 xcode 左侧项目树中添加了一些 js 和 css 文件。但是当我构建这个项目时,我收到警告:没有规则来处理架构 i386 的 sourcecode.javascript 类型的文件 '$(PROJECT_DIR)/js/builder.js'
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!
我想如果我在 xcode 中丢失了我的项目的一些设置,但是如何添加一些像 js 和 css 文件?非常感谢!
回答by Rob Keniger
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 Sourcesbuild phase.
当您添加 JavaScript 文件时,Xcode 会检测到该文件是源代码文件,假设您要编译它并自动将其添加到Compile Sources构建阶段。
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 Sourcesbuild phase and add it to the Copy Bundle Resourcesbuild phase.
要阻止 Xcode 尝试编译它并使其复制文件,请在 Groups and Files 列表中展开您的目标,从Compile Sources构建阶段中删除 JavaScript 文件并将其添加到Copy Bundle Resources构建阶段。
回答by Genki
For Xcode 4, click on the main project, click on Build Phases. Open up Compile Sourcesand Copy Bundle Resourcesthen you can then simply drag the files from one to the other.
对于 Xcode 4,单击主项目,单击 Build Phases。打开编译源和复制捆绑资源,然后您可以简单地将文件从一个拖到另一个。
回答by Narasimha Nallamsetty
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
我遇到了同样的问题,我可以用 Xcode5 中的简单技术解决这个问题。当您将 HTML 文件添加/拖动到 Xcode 包中时,您需要通过将它们分组为 2 种类型来添加它们
1.assets
1.资产
2.index.html
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.
assets 文件夹包含所有 HTML 文件,如图像、.js、内容、css。所有 HTML 文件都应
包含在资产文件夹中。我的意思是您需要将 assets 文件夹中的所有 HTML 文件分组为一个文件夹。
Then you drag that particular folder which contains ASSETS and INDEX.HTML files into Xcode bundle.
然后将包含 ASSETS 和 INDEX.HTML 文件的特定文件夹拖到 Xcode 包中。
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
如果有人有任何疑问仍然让我知道我会一步一步解释