使用 Xcode 作为 Javascript IDE,可以吗?
我正在开发一个 Javascript 密集型 Web 应用程序,目前设计为在 iPhone/iPad 上运行。它还适用于所有 Webkit 浏览器(Safari + Chrome)。
我有一个自制的 MVC 框架,由许多 JavaScript 文件组成:每个视图一个,每个控制器一个,还有许多“帮助”类。
我还有一堆 LESS 文件,一个“主”文件包括每个视图的每个 LESS 文件(例如,如果我有一个 UIListView.js,我也有一个 UIListView.less)。
目前,我正在使用 MacVim 和 Less.app,并在 iPhone/iPad 模拟器、真实 iPhone/iPad 上进行测试,有时当我确实需要使用开发人员工具进行“硬核”调试时,还会在 Safari 或 Chrome 上进行测试。我的所有文件都存储在我的 ~/Sites/projectX
文件夹中,我使用 Mac 的内置 Web 服务器浏览该文件夹。
这在开发时是可以的,我的index.htm 引用了许多小文件,但这并不重要,因为我是通过WiFi 访问内联网的。
我想要实现的是一种更加“以项目为导向”的方法。就像我在 Xcode 中开发 iOS 项目一样,我想使用 Xcode 来满足我所有的开发需求,将所有源文件保存在与 ~/Sites
分开的目录中,比如 ~ /桌面/projectX
。我想要两种配置(调试和发布)与“构建和运行”一起使用:
“调试”配置将简单地编译主 .less 文件(其中包括所有小 .less 文件),复制JS + CSS + HTM 文件以及所有图形资源转移到某个目录(~/Sites/projectX_debug)。然后根据所选的“子配置”,启动 iPhone 模拟器、iPad 模拟器、Safari 或 Chrome,清除其缓存(通过 AppleScript?)并打开 index.htm
,“发布”配置将所有 JS 文件粘合在一起并缩小它们,编译并缩小 .less 文件,更改 index.htm 以仅引用粘合的 JS,然后使用 pngout/pngcrush/whatever 优化所有 PNG,然后将所有存档发送到本地目录(~/Sites/projectX_release)或通过 sftp 到我的生产服务器。
我相信我可以使用 XCode 4 的构建阶段(也许使用 GNU makefiles 或某种预处理器)来实现(如果不是全部,但大部分),但我不知道从哪里开始。
是否有人已经有了这种使用 Xcode 进行 Mac/iOS 开发之外的其他操作的设置,但仍然使用大多数 IDE 传统的构建阶段/makefile 的“经典”概念?
(一个可接受的解决方法是简单地创建一个 bash 脚本来处理这个问题 - 我已经可以自己管理它,但我真的很想使用集成的 XCode 功能,只需按 Cmd-R 来“编译”并运行我的项目处于调试模式)。
I'm working on a Javascript-intensive web app designed to run on iPhone/iPad for now. It also works on all Webkit browsers (Safari + Chrome).
I have a home-made MVC framework consisting of many JavaScript files: one for each view, one for each controller, many "helper" classes.
I also have a bunch of LESS files, one "main" including each LESS file for each view (eg. if I have a UIListView.js, I also have a UIListView.less).
Currently I'm working with MacVim and Less.app, and doing tests on both iPhone/iPad simulators, real iPhone/iPads, and sometimes Safari or Chrome when I really need to do "hardcore" debugging with the developer tools. All my files are stores in my ~/Sites/projectX
folder, which I browse using my Mac's built-in web server.
This is OK while developing, I have many little files referenced by my index.htm but it doesn't matter as I'm on my intranet over WiFi.
What I'd like to achieve is a more "project-oriented" approach. Just as when I develop an iOS project in Xcode, I'd like to use XCode for all my development needs, keep all my source files in a directory separate from ~/Sites
, say ~/Desktop/projectX
. I'd like to have two configurations (debug and release) to use with "Build and run" :
the "debug" config would simply compile the main .less file (which includes all small .less files), copy the JS + CSS + HTM file over to some directory (~/Sites/projectX_debug), along with all graphic resources. Then depending on the "sub-configuration" chosen, launch either the iPhone Simulator, the iPad Simulator, Safari, or Chrome, clear its cache (via AppleScript?) and open the index.htm
the "release" config that would glue all JS files together and minify them, compile and minify the .less file, change the index.htm to reference only the glued JS, then optimize all PNGs with pngout/pngcrush/whatever before sending all the archive to a local directory (~/Sites/projectX_release) or by sftp to my production server.
I believe I can achieve if not all but most of this using the build phases of XCode 4, maybe using GNU makefiles or some kind of preprocessor, but I'm lost at where to start.
Does someone already have this kind of setup for using Xcode to do something else than Mac/iOS development, but still using the "classical" concept of build phases/makefiles traditional to most IDEs?
(An acceptable workaround would be to simply create a bash script to handle that — I can already manage it by myself, but I'd really like to use the integrated XCode features, and just pressing Cmd-R to "compile" and run my project in debug mode).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会尝试逐步完成您应该做的事情......
或者
如果上面的内容太复杂:
希望有帮助。
I will try and step through the things you should do...
OR
If the above is too complicated:
Hope that helps.