强制以编程方式以32位模式启动Cocoa应用程序 [英] Forcing a Cocoa application to start in 32-bit mode programmatically

查看:84
本文介绍了强制以编程方式以32位模式启动Cocoa应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Cocoa应用程序,该应用程序通常在支持该体系结构的任何Mac上都以完全64位模式运行.

I have a Cocoa application that usually runs in full 64-bit mode on any Mac that supports this architecture.

现在我有一个外部API,该API仅作为32位插件提供,可以加载到主程序中.该API用于第三方输入设备,我的用户中只有很小一部分会购买,但这对于那部分用户很重要.

Now I have an external API that is only available as a 32-bit plug-in to be loaded into the main program. This API is for a third-party input device that only a small percentage of my users will ever purchase, but that is important for that small percentage.

我的问题是,该程序仅在以32位模式执行时才能使用此API.最简单的事情当然是:

My problem is that the program can only use this API if executed in 32-bit mode. The easiest thing to do is of course to:

方案1:要求用户通过Finder的获取信息"对话框更改其信息,以32位模式启动该程序.

这很容易做到,但是很难做到.

This is easily done, but hardly elegant..

方案2:始终以32位模式运行,从而避免了问题

我也不想做什么..为了具有奇特功能,要惩罚98%的用户.

Hardly what I want to do either.. penalizing 98% of users for the sake of an exotic feature.

方案3:自动更改应用程序的启动属性,以便在下次启动时以及以后每次启动时都以32位模式启动

方案4:在启动时,确定所使用的体系结构,然后在必要时以32位模式重新启动

场景3和4存在的问题是,有关如何执行此操作的文献很少,这可能会让我在Mac App Store指南中遇到麻烦.

Scenarios 3 & 4 have the problem that very little is documented on how to do this and it might get me into trouble with the Mac App Store guidelines.

到目前为止,我已经建立:

So far, I've established:

  • 使用"arch"命令行工具可以让我以32位模式重新启动可执行文件
  • Finder脚本不允许我更改以32位模式启动"标志
  • 该标志由Launch Services API( http://blog.timac.org/? p = 490 )
  • 但是我还没有找到任何接口来以编程方式更改Launch Services API中的标志
  • that using the "arch" command line tool will allow me to restart my executable in 32-bit mode
  • Finder scripting won't let me change the "Launch in 32-bit mode" flag
  • the flag is managed by the Launch Services API (http://blog.timac.org/?p=490)
  • BUT I haven't found any interface to programmatically change the flag in the Launch Services API

到目前为止,我只能看到这些选项,但这些选项似乎都不是很好:

So far I can see only these options, none of which seem particularly great:

  1. 使用NSTask和"arch"命令行工具重新启动应用程序
  2. 直接写入com.apple.LaunchServices.plist
  3. 将32位插件隔离到其自己的仅32位进程中并使用IPC

解决方案1可能会使我在提交MAS时遇到麻烦.解决方案2几乎肯定会在某个阶段这样做..从用户的角度来看,只有解决方案3才是完美的,但会增加大量的复杂性,从而最大程度地减少回报.

Solution 1 could get me into trouble with the MAS submission. Solution 2 would almost certainly do so at some stage.. only solution 3 would be perfect from a user's perspective but add a huge amount of complexity for minimal pay-off.

任何有关如何干净地"并以合理的努力做到这一点的建议,将受到高度赞赏!

Any advice on how to do this "cleanly" and with reasonable effort would be highly appreciated!

推荐答案

选项5: 创建另一个始终以32位运行的可执行文件,其唯一目的是驱动有问题的32位组件.从主应用程序启动该可执行文件,并使用某种独立于处理器的io相互通信,可能是套接字.

Option 5: Create another executable that always runs as 32 bit and its sole purpose is to drive the 32 bit component in question. Launch that executable from your primary application and use some type of processor independent io to communicate with each other, probably sockets.

这篇关于强制以编程方式以32位模式启动Cocoa应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆