让 Cocoa 应用程序在 Windows 上运行有多难?

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

How hard is it to get a Cocoa application to run on Windows?

windowscocoamacos

提问by Sam Hasler

In the wikipedia article on Cocoait says:

关于可可维基百科文章中,它说:

There are also open source implementations of major parts of the Cocoa framework that allows cross-platform (including Microsoft Windows) Cocoa application development, such as GNUstep, Cappuccino, and Cocotron.

还有 Cocoa 框架的主要部分的开源实现,允许跨平台(包括 Microsoft Windows)Cocoa 应用程序开发,例如GNUstepCappuccinoCocotron

Yet when I looked into whether Mac application Tweetiewas available for windows the developer had ruled it out:

然而,当我查看 Mac 应用程序Tweetie是否可用于 Windows 时,开发人员已经排除了它

Windows doesn't have Cocoa, the programming environment that Tweetie is made in, as such, it seems like a poor possibility.

Windows 没有 Cocoa,Tweetie 的编程环境,因此,它似乎不太可能。

I'd like to have an answer to point the Tweetie developers (and as a resource for other cocoa developers) which would tell them:

我想有一个答案来指出 Tweetie 开发人员(并作为其他可可开发人员的资源),这会告诉他们:

  • Which implementation is the most suitable for getting a cocoa app running on windows?
  • How much work is it likely to take to get the app running under windows?
  • How easy/hard is it to maintain a common code base for Mac and Windows?
  • (any other considerations I've missed?)
  • 哪种实现最适合在 Windows 上运行可可应用程序?
  • 让应用程序在 Windows 下运行可能需要多少工作?
  • 为 Mac 和 Windows 维护一个通用代码库有多容易/困难?
  • (我错过的任何其他考虑因素?)

Of course if it would be too much work I'd like to know that too before suggesting it and potentially sending someone else on a fruitless search.

当然,如果工作量太大,我也想知道,然后再提出建议,并可能让其他人进行毫无结果的搜索。

回答by Peter Hosey

Don't forget:

不要忘记:

  1. “Major parts of the Cocoa frameworks” is not the same as “the entirety of the Cocoa frameworks”. Tweetie could be using something that's missing.
  2. Tweetie could be (very probably is) using APIs from the non-Cocoa frameworks, such as Core Foundation, Core Services, Core Graphics, and Core Animation. A port of the Cocoa frameworks alone won't include any of these APIs, and even a more complete Mac-API-emulation framework will not include all of them.
  3. These frameworks are eternally chasing Apple. Even if they catch up, they'll be instantly behind again as of the next Mac OS X release. Mac developers already put off using new APIs in new Mac OS X?releases while they wait for users to upgrade to those new releases; now you're asking atebits to alsowait for the other-framework developer to catch up to Apple again.
  4. Any second implementation of an existing API will have bugs that the first implementation doesn't, and vice versa. These differences will cause development and support problems.
  5. You're asking atebits to add a third platform to an application that already exists on two. Supporting one platform is a lot of work. Supporting two platforms is a hell of a lot of work. Supporting three? Now you're getting into big-company territory.
  1. “Cocoa 框架的主要部分”与“Cocoa 框架的整体”不同。Tweetie 可能正在使用缺少的东西。
  2. Tweetie 可能(很可能是)使用来自非 Cocoa 框架的 API,例如 Core Foundation、Core Services、Core Graphics 和 Core Animation。仅 Cocoa 框架的一个端口不会包含这些 API 中的任何一个,甚至更完整的 Mac-API 仿真框架也不会包含所有这些 API。
  3. 这些框架永远在追逐苹果。即使他们赶上了,到下一个 Mac OS X 版本时,他们也会立即再次落后。Mac 开发人员已经推迟在新的 Mac OS X 版本中使用新 API,同时等待用户升级到这些新版本;现在您要求 atebits等待其他框架开发人员再次赶上 Apple。
  4. 现有 API 的任何第二个实现都会有第一个实现没有的错误,反之亦然。这些差异会导致开发和支持问题。
  5. 您要求 atebits 将第三个平台添加到已经存在于两个平台上的应用程序中。支持一个平台需要做很多工作。支持两个平台是一项艰巨的工作。支持三个?现在您正在进入大公司领域。

So, even with these Cocoa-like frameworks, the answer is: Hard.

因此,即使使用这些类似 Cocoa 的框架,答案也是:很难。

回答by lyxera

Among GNUstep, Cappuccino and Cocotron, Cocotron is only possible choice to port a Mac application to windows. Cappuccino is for web and GNUstep only runs on top of cygwin or mingw, which means the GUI looks nothing like native windows apps.

在 GNUstep、Cappuccino 和 Cocotron 中,Cocotron 是将 Mac 应用程序移植到 Windows 的唯一可能选择。Cappuccino 适用于网络,而 GNUstep 仅运行在 cygwin 或 mingw 之上,这意味着 GUI 看起来与本机 Windows 应用程序完全不同。

It is theoretically possible to build cocoa windows apps using Cocotron. However, the reality is that it is still very hard to use, and it is still quite limited in the Cocoa API.

理论上可以使用 Cocotron 构建可可 Windows 应用程序。但是,实际情况是它仍然很难使用,并且在 Cocoa API 中仍然非常有限。

Therefore, two possible solutions:

因此,有两种可能的解决方案:

  • Try hard to remove the codes that are not supported by Cocotron in the original code base and do the cross compilation. Maintaining common code base will be painful.
  • Start a new GUI at all, no common code base. two choices here
    • Start a cross platform project with cross application framework such as Qt, or Java.
    • Start a windows only project. There are a lot of choices here, .Net WinForm application, MFC, etc.
  • 尽量去掉原代码库中Cocotron不支持的代码,进行交叉编译。维护通用代码库将是痛苦的。
  • 完全启动一个新的 GUI,没有通用的代码库。这里有两个选择
    • 使用 Qt 或 Java 等跨应用程序框架启动跨平台项目。
    • 启动一个仅限 Windows 的项目。这里有很多选择,.Net WinForm应用程序,MFC等。

回答by zpesk

There are Windows compilers for Objective-C(the programming language used to write cocoa apps). However, Cocoa includes the frameworks for presenting the GUI. These visual frameworks are specific to Mac OS X because they use OS X only windows and other controls. So someone would need to re-implement the controls in Cocoa to use Windows controls.

适用于 Objective-C(用于编写可可应用程序的编程语言)的Windows 编译器。但是,Cocoa 包含用于呈现 GUI 的框架。这些可视化框架特定于 Mac OS X,因为它们仅使用 OS X 窗口和其他控件。所以有人需要在 Cocoa 中重新实现控件才能使用 Windows 控件。

Also, I am fairly certain that Tweetie uses Mac OS X only technologies like Core Animation. This does not exist on Windows, so the nice animation effects present in the apps would have to be implemented in a completely different way.

此外,我相当确定 Tweetie 仅使用 Mac OS X 技术,例如 Core Animation。这在 Windows 上不存在,因此应用程序中存在的漂亮动画效果必须以完全不同的方式实现。