ios 你能用 Ruby 开发原生 iPhone 应用程序吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/219653/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 15:20:18  来源:igfitidea点击:

Can you develop native iPhone apps in Ruby?

iphonerubycocoa-touchios

提问by BefittingTheorem

Hi I'm looking into iPhone development, and Objective-C is not be my preferred language. As far as I can see at this moment Ruby cannot be used to talk to Cocoa Touch at the moment on the iPhone.

嗨,我正在研究 iPhone 开发,而 Objective-C 不是我的首选语言。就我目前所见,目前无法在 iPhone 上使用 Ruby 与 Cocoa Touch 交谈。

So my question is, am I wrong? Can I use Ruby on the iPhone to develop Cocoa Touch applications. And what is the future looking like for Ruby on the iPhone?

所以我的问题是,我错了吗?我可以在 iPhone 上使用 Ruby 开发 Cocoa Touch 应用程序吗?Ruby on iPhone 的未来会怎样?

采纳答案by Ben Gottlieb

No, you are correct. Currently, and most likely for the foreseeable future, Ruby will not be an option, at least for AppStore applications. There's no reason you couldn't do this on a Jailbroken phone, but Apple is pretty wed to Objective C for official development.

不,你是对的。目前,并且很可能在可预见的未来,Ruby 不会成为一种选择,至少对于 AppStore 应用程序而言。您没有理由不能在越狱手机上执行此操作,但 Apple 非常愿意使用 Objective C 进行官方开发。

回答by gimenete

Now you can with RubyMotion

现在您可以使用RubyMotion

回答by Tim Burks

In the iPhone OS, mprotect() will fail if you try to use it to mark writable sections of memory as executable. This breaks bridges like RubyCocoa (and probably MacRuby) that use libffi to create Objective-C method handlers at runtime. I believe that this is by design because it was not always the case.

在 iPhone 操作系统中,如果您尝试使用 mprotect() 将内存的可写部分标记为可执行,则会失败。这打破了像 RubyCocoa(可能还有 MacRuby)这样使用 libffi 在运行时创建 Objective-C 方法处理程序的桥梁。我相信这是设计使然,因为情况并非总是如此。

Ultimately, this is more a matter of platform politics than technology, but a technical workaround for this exists. Instead of generating custom method handlers at runtime, precompile a pool of reconfigurable ones that are assigned as needed, essentially making the bridging process entirely data-driven. As far as I know, this is not yet being done in RubyCocoa or MacRuby.

归根结底,这更多是平台而非技术问题,但存在解决此问题的技术解决方法。不是在运行时生成自定义方法处理程序,而是预编译根据需要分配的可重新配置的池,从本质上使桥接过程完全由数据驱动。据我所知,这还没有在 RubyCocoa 或 MacRuby 中完成。

Another significant thing to consider is that the compiled Ruby and RubyCocoa runtimes can be significantly larger than compiled Objective-C apps. If these libraries were available on the iPhone, this wouldn't be an issue, but for now, even if you had RubyCocoa working, you might not want to use it for apps that you distribute.

另一个需要考虑的重要事项是编译后的 Ruby 和 RubyCocoa 运行时可能比编译后的 Objective-C 应用程序大得多。如果这些库在 iPhone 上可用,这将不是问题,但就目前而言,即使您使用 RubyCocoa,您也可能不想将它用于您分发的应用程序。

回答by Kendall Helmstetter Gelner

You are better off as a programmer knowing a number of different languages - think of Objective-C as a good learning opportunity.

作为一名了解多种不同语言的程序员,你会更好 - 将 Objective-C 视为一个很好的学习机会。

I've found that things you learn in other languages often make you a better programmer overall, and give you new insights into other languages you already know.

我发现你在其他语言中学到的东西通常会让你成为一个更好的程序员,并让你对你已经知道的其他语言有新的了解。

回答by pfeilbr

rhomobileis an option to run ruby code on the iPhone, but it's essentially web app development. A web server runs locally on the iPhone and your ruby code renders to standard client side web technologies (html/css/javascript).

rhomobile是在 iPhone 上运行 ruby​​ 代码的一个选项,但它本质上是 Web 应用程序开发。网络服务器在 iPhone 上本地运行,您的 ruby​​ 代码呈现为标准客户端网络技术 (html/css/javascript)。

http://rhomobile.com/

http://rhomobile.com/

回答by Jon Raphaelson

Actually, the ruby cocoa bridge isn't awkward at all; things work remarkably smoothly, right down to connecting outlets in IB etc. The resulting code is down right beautiful.

其实,红宝石可可桥一点都不尴尬;事情非常顺利,一直到连接 IB 中的插座等等。生成的代码非常漂亮。

As for iPhone development, if you want an official AppStore application, you're out of luck unfortunately. Apple dictated that iPhone is Obj-C/Cocoa Touch, and there's a clause in the SDK license saying that one of the things they willreject an app for is having a language interpreter/JIT compiler, so you couldn't add a ruby interpreter in your app yourself.

至于 iPhone 开发,如果你想要一个官方的 AppStore 应用程序,那你很不幸。苹果决定了iPhone的对象- C /可可触摸,并有一个在SDK许可证说的事情之一,他们的条款拒绝是有一个语言解释器/ JIT编译器的应用程序,所以你不能添加一个Ruby解释器在您自己的应用程序中。

Off topic, but hilariously, this is why Flash for the iPhone is Adobe blowing smoke. They couldn't get a swf player onto the AppStore even if they wanted to, per Apple's license.

题外话,但好笑的是,这就是为什么 iPhone 的 Flash 是 Adob​​e 冒烟的原因。根据 Apple 的许可,即使他们愿意,他们也无法在 AppStore 上安装 swf 播放器。

回答by Adam Blum

Uh, Rhodes (Rhomobile) does allow you to do native apps on the iPhone and all other smartphones. Yes, we do leverage doing rendering via the WebUIView control. But we allow all device capabilities and synchronized local data.

呃,Rhodes (Rhomobile) 确实允许您在 iPhone 和所有其他智能手机上执行本机应用程序。是的,我们确实利用 WebUIView 控件进行渲染。但我们允许所有设备功能和同步本地数据。

回答by Radamanthus

You might want to take a look at shinycocos. It is a child project of cocos2d-iphone, an Objective-C game programming framework for iPhone.

你可能想看看Shinycocos。它是cocos2d-iphone 的子项目,是iPhone的 Objective-C 游戏编程框架。

I haven't yet played with it, but from the git READMEI infer that it bundles Ruby 1.9.1 into your app.

我还没有玩过它,但从git README我推断它把 Ruby 1.9.1 捆绑到你的应用程序中。

回答by Steven Lu

I installed the ruby package from Cydia on my iPod Touch 1G jailbroken on 3.1.3:

我在 3.1.3 上越狱的 iPod Touch 1G 上安装了 Cydia 的 ruby​​ 包:

image

图片

Seems to work.

似乎工作。

Now as for cocoa-touch that is a whole different story I would assume.

现在至于可可触摸,我认为这是一个完全不同的故事。

回答by Mayank Jain

No you can not create iOS native app in Ruby. There is only two options for native apps for mac and iOS:-

不,您不能在 Ruby 中创建 iOS 本机应用程序。Mac 和 iOS 的本机应用程序只有两个选项:-

Objective Cand Swift Programming Language

Objective CSwift 编程语言

Tutorials:-

教程:-

Apple's official tutorial on Objective C

Apple 的 Objective C 官方教程

Apple's official tutorial on Swift Programing Language

Apple 的 Swift 编程语言官方教程

If you are familiar with Ruby and only want to create iOS apps by Ruby. Ruby Motion, can be a cross-platform option for you, but it is not free.

如果您熟悉 Ruby 并且只想通过 Ruby 创建 iOS 应用程序。Ruby Motion可以成为您的跨平台选项,但它不是免费的。

Cross-Platforms

跨平台