dan*_*ood 9 ruby cocoa sass objective-c
I'm trying to figure out how I could bundle a package, written in Ruby (Sass) into a Cocoa application (Objective-C, not Ruby Cocoa) for me to execute (via NSTask is fine, unless there is an easy way to bridge ObjC<->Cocoa that I'm not aware of).
The Sass package is something you have to install, using "gem install" or "rake install" -- doing so puts a ton of files in my ~/.gem directory. Since I want anybody who has installed my Cocoa-based application to be able to execute this tool from within my app, I don't want to have the user go through a process of installing anything additional, so I'm hoping to be able to embed everything I need in the Resources directory of my app package.
然而,不熟悉Ruby的内部和结构(对不起,我只是把ObjC/Cocoa保留在脑子里我遇到了麻烦!),我不清楚在〜/中安装了1,444个文件中的哪一个.gem目录(是的,我算了)我需要嵌入应用程序以及我可能需要做什么才能使目录引用等工作正常.
如果有人有任何将ruby工具嵌入Cocoa应用程序的经验,我将非常感谢您的意见.我没想到这是这么辛苦,考虑到红宝石被安装在Mac OS X ...但显然这个包(通常是?非典型?)不只是一个单一的脚本文件更....
您可以将 gems 安装到特定位置:
\n\nGEM_HOME=path/to/your/project/gems gem install sass\nRun Code Online (Sandbox Code Playgroud)\n\n然后,作为构建过程的一部分,将该文件夹复制到您的资源中。当你想运行 sass 时,找到你的 gem 文件夹。像这样调用 ruby:
\n\nNSString *gems_path = \xe2\x80\xa6;\nNSTask *task = [[NSTask alloc] init];\n// you may want to copy NSProcessInfo.processInfo.environment and modify it instead\ntask.environment = @{ @"GEM_HOME": gems_path };\ntask.launchPath = @"/usr/bin/ruby";\ntask.arguments = @[[gems_path stringByAppendingPaths:@[@"bin",@"sass"]], @"rest", @"of", @"your", @"arguments"];\n// add handling for I/O\n[task launch];\nRun Code Online (Sandbox Code Playgroud)\n\n(输入github,可能有愚蠢的错误)
\n\n请注意,您可能还想捆绑 ruby(也许是macruby),以防止兼容性问题。如果没有,请确保测试您支持的所有 OS X 版本,尤其是 10.9,因为 ruby 已升级到 2.0。
\n| 归档时间: |
|
| 查看次数: |
698 次 |
| 最近记录: |