如何将 OCaml 与 iPhone API 连接?

发布于 2024-07-26 12:47:26 字数 200 浏览 1 评论 0原文

我想开始为 iPhone 开发应用程序,但我真的很想使用 OCaml 而不是 Objective-C。 经过一番谷歌搜索后,似乎这绝对是可能的,但我还没有找到任何实际编译的代码片段。

是否可以使用 OCaml 编写 iPhone 应用程序? 如果是这样,您能否提供一个片段来演示如何从 OCaml 调用 Cocoa API?

I'd like to start developing applications for iPhone, but I'd really like to use OCaml rather than Objective-C. After some googling, it seems like this is definitely possible, but I haven't found any code snippets which actually compile.

Is it possible to write iPhone apps using OCaml? If so, could you provide a snippet demonstrating how to make calls into the Cocoa API from OCaml?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

深海里的那抹蓝 2024-08-02 12:47:26

我们的网站上有构建 OCaml 到 iOS 交叉编译器的说明。 我们从上面提到的补丁开始,但我们发现它们需要以多种方式进行修改才能在普通 iPhone/iPad 上运行。 我们正在销售一款名为 Cassino 的 iPhone 应用程序,该应用程序完全用 OCaml 编写(Cocoa Touch 的薄包装除外)。 所有 Cocoa Touch 的包装将是一项艰巨的工作,但单个应用程序的包装还不错。 与 ObjC 相比,使用 OCaml 进行编码非常愉快。

我们还刚刚在我们的网站上发布了名为 Portland 的小型 OCaml iPhone 应用程序的完整源代码。 请访问 psellos.com 了解更多信息。

We have instructions for building an OCaml-to-iOS cross compiler on our site. We started with the patches mentioned above, but we found they needed to be modified in several ways to run on a stock iPhone/iPad. We are selling an iPhone app named Cassino that is entirely written in OCaml (except for thin wrappers to Cocoa Touch). Wrappers for all of Cocoa Touch would be a big job, but wrappers for a single application aren't so bad. And coding in OCaml is very pleasant compared to ObjC.

We also just published full sources for a small OCaml iPhone app named Portland at our site. Read more at psellos.com.

兰花执着 2024-08-02 12:47:26

OCaml 不能立即用于构建 iPhone 应用程序。 您必须让 OCaml 输出 ARM 代码而不是 x86 代码。 您还必须为所有 iPhone API 调用构建包装器。

尽管如此,这些人还是在经历痛苦来尝试这一点。

http://web.yl.is.su -tokyo.ac.jp/~tosh/ocaml-on-iphone/

我的粗浅建议是,你应该专注于使用 Obj-C 来处理所有事情。 如果
如果您确实想要 ML,请仅将其用于内核或有趣的部分。
我会找到一个将 gen 编码为 C 之类的 *ML,然后使用该结果
作为应用程序的库。

祝你好运。

Out of the box, OCaml cannot be used to build IPhone apps. You would have to have OCaml output ARM code rather than x86 code. You would also have to build wrappers for all the IPhone API calls.

Still, these guys are going through the pain to try this.

http://web.yl.is.s.u-tokyo.ac.jp/~tosh/ocaml-on-iphone/

My humble recomendation is that you focus on using Obj-C for everything. If
you really want an ML, use it only for the kernel or the interesting portion.
I would find an *ML that code gens to something like C, and then use that result
as a library to the app.

Good luck.

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