Linux 中的 Objective-C

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

Objective-C in Linux

objective-clinux

提问by zeboidlund

Possible Duplicate:
Game programming on Objective-C and linux

可能的重复:
Objective-C 和 linux 上的游戏编程

I know that developing iPhone apps (painlessly, at least) pretty much requires a Mac. However, is it possible to develop normal desktop applications using Objective-C in Linux? For example, could I make a game using a development library for Objective-C, and release it for Linux, rather than iOS?

我知道开发 iPhone 应用程序(至少无痛)几乎需要一台 Mac。但是,在 Linux 中使用 Objective-C 是否可以开发普通的桌面应用程序?例如,我可以使用 Objective-C 的开发库制作游戏,然后为 Linux 而不是 iOS 发布它吗?

采纳答案by Alex Bolotov

There are a lot of normal desktop applicationswhich use GNUstep(free version of Cocoa API) on Linux.

在 Linux上有很多使用GNUstep(Cocoa API 的免费版本)的普通桌面应用程序

For games you can try sdlobjc— SDL binding for Objective-C.

对于游戏,您可以尝试sdlobjc— Objective-C 的 SDL 绑定。

There is even a Linux distribution called étoiléwhich uses GNUstep based user environment and all own GUI applications writen in Objective-C.

甚至还有一个名为étoilé的 Linux 发行,它使用基于 GNUstep 的用户环境和所有自己的用 Objective-C 编写的 GUI 应用程序。

If you want to learn how to program in Objective-C using GNUstep on Linux (or cygwin) there are some possible problems:

如果您想学习如何在 Linux(或 cygwin)上使用 GNUstep 在 Objective-C 中编程,可能存在一些问题:

  • You must use cygwinin windows to build the application. Which means that it:

    a) some applications can be slowed down because of cygwin's translations of POSIX API calls to Win32 API calls. For example fork()call will be translated in Win32's CreateProcess call and some others and will be less efficient than in UNIX.

    b) your application must be distributed with cygwin's dll

    c) your application can't be 64bit (at least for now)

    d) you application will see all your windows disk drives as a part of unix filesystem hierarchy (c:and d:will be /cygdrive/cand /cygdrive/d) and you will have /bin /tmp /usr /etcavialable under /as well.

  • There's not up-to-date books about GNUstep or about programming Objective-C not using Mac OS. Thre is Stephen Kochan's book "Programming in Objective-C 2.0 (2nd Edition)" where he unfortunately ommits explaination of how to build even basic examples under Linux or Windows. I hope it is fixed in 3rd edition.

  • GNUstep has own themes so apps may be themed differently than GTK Linux applications in Linux or usual themed application in Windows.

  • 您必须在 Windows 中使用cygwin来构建应用程序。这意味着它:

    a) 由于 cygwin 将 POSIX API 调用转换为 Win32 API 调用,因此某些应用程序可能会变慢。例如,fork()调用将在 Win32 的 CreateProcess 调用和其他一些调用中转换,并且效率低于 UNIX。

    b) 您的应用程序必须与 cygwin 的 dll 一起分发

    c) 你的应用程序不能是 64 位的(至少现在是这样)

    d)您的应用程序将看到您的所有 Windows 磁盘驱动器作为 unix 文件系统层次结构的一部分(c:d:将是/cygdrive/c/cygdrive/d),并且您将拥有/bin /tmp /usr /etcavialable 下/还有。

  • 没有关于 GNUstep 或关于不使用 Mac OS 编程 Objective-C 的最新书籍。这是 Stephen Kochan 的书“Objective-C 2.0(第 2 版)中的编程”,遗憾的是他省略了对如何在 Linux 或 Windows 下构建基本示例的解释。我希望它在第 3 版中得到修复。

  • GNUstep 有自己的主题,因此应用程序的主题可能与 Linux 中的 GTK Linux 应用程序或 Windows 中的常用主题应用程序不同。