使用 Xcode 作为 Javascript IDE,可以吗?

发布于 2024-12-16 19:42:45 字数 1395 浏览 0 评论 0原文

我正在开发一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜无邪 2024-12-23 19:42:45

我会尝试逐步完成您应该做的事情......

“调试”配置将简单地编译主 .less 文件(其中
包括所有小的 .less 文件),

  • 我将创建一个构建规则来处理 .less 文件,使用脚本来编译它们。

将 JS + CSS + HTM 文件复制到
一些目录(~/Sites/projectX_debug),以及所有图形
资源。然后根据选择的“子配置”,启动
iPhone 模拟器、iPad 模拟器、Safari 或 Chrome,
清除其缓存(通过AppleScript?)并打开index.htm

  • 为此,您只需将文件添加到“构建阶段”部分的复制阶段。
  • 您可以在目标的“构建设置”部分中设置构建目录(~/Sites/projectX_debug,如果您愿意)。

“release”配置将所有 JS 文件粘合在一起并缩小
他们,编译并缩小.less文件,将index.htm更改为
仅参考粘合的 JS,然后使用以下命令优化所有 PNG
pngout/pngcrush/whatever 在将所有存档发送到本地之前
目录 (~/Sites/projectX_release) 或通过 sftp 到我的产品
服务器。

  • 对于这一部分,您可能想要创建一个新目标并添加不同的规则和设置。

或者

如果上面的内容太复杂:

  1. 编写两个 bash 脚本。
  2. 制定两个目标。
  3. 将 bash 脚本添加为每个目标中的构建阶段。

希望有帮助。

I will try and step through the things you should do...

the "debug" config would simply compile the main .less file (which
includes all small .less files),

  • I would create a build rule to handle .less files, use a script to compile them.

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

  • For this you just need to add your files to the copy phase in the 'Build Phases' section.
  • You can set your build directory in your target's 'Build Settings' section (~/Sites/projectX_debug, if you'd like).

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.

  • For this part you might want to create a new target and add different rules and settings.

OR

If the above is too complicated:

  1. Write your two bash scripts.
  2. Make two targets.
  3. Add your bash script as a build phase in each target.

Hope that helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文