gpt4 book ai didi

macos - Mac .app 包向后兼容错误 : "You can' t use this version of the application "[my app name]" with this version of OS X."

转载 作者:行者123 更新时间:2023-12-04 17:44:43 25 4
gpt4 key购买 nike

我正在开发一个跨平台的游戏,将通过 Steam 发布和分发,并且在 Mac 版本上遇到了问题。一切都是用 C++ 编写的,并在 El Capitan 上使用 Xcode 构建,使用由 CMake 生成的项目文件,其中包含一些小的修改。构建完成后,我使用自己的构建脚本将 .app 包放在一起,该包生成目录结构,添加图标文件和二进制文件,以及我自己编写的 Info.plist 文件我可以找到关于哪些元素是必要的文档。

问题在于向后兼容性。当我尝试在运行 Yosemite 的 Mac 上启动游戏 .app 时,我收到以下错误消息:

You can't use this version of the application "[my app name]" with this version of OS X. You have OS X 10.10.5. The application requires OS X 10.11 or later.



问题是,在 Xcode 中我将构建目标指定为 OS X 10.7,所以我很困惑为什么会发生这个错误。我什至可以进入 Finder 中的包,导航到实际的游戏二进制文件,然后毫无问题地运行它。当我双击 .app 文件时,它只会失败并显示此错误消息(其图标显示带斜杠的圆圈,表明我可能在 Info.plist 或包配置中做错了什么)。在 El Capitan 上运行时一切正常。

我也试过设置 LSMinimumSystemVersion适当,但这并不能解决问题。

这是我的 Info.plist的内容文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>Contents/MacOS/[binary name]</string>
<key>CFBundleDisplayName</key>
<string>[game title]</string>
<key>CFBundleIconFile</key>
<string>[icon file]</string>
</dict>
</plist>

我想 Info.plist 中缺少某些东西,但是 Apple 关于所需 key 的文档对于弄清楚可能是什么没有帮助。

如果您需要更多信息来解决这个问题,请告诉我,非常感谢您的帮助!

最佳答案

所以问题似乎是在输出二进制文件的数据部分设置了最低 mac 版本。二进制文件在直接与通过 .app 运行时执行的原因是,当与 .app 一起运行时,它实际上是 LaunchServices 执行二进制文件,并检查嵌入到二进制文件中的版本号。以下是 clang 的汇编输出示例:

    .section    __TEXT,__text,regular,pure_instructions
.macosx_version_min 10, 12
.globl _main
.align 4, 0x90
_main: ## @main
.cfi_startproc
## BB#0:
pushq %rbp
Ltmp0:
.cfi_def_cfa_offset 16
Ltmp1:
.cfi_offset %rbp, -16
movq %rsp, %rbp
Ltmp2:
.cfi_def_cfa_register %rbp
xorl %eax, %eax
movl $0, -4(%rbp)
movl %edi, -8(%rbp)
movq %rsi, -16(%rbp)
popq %rbp
retq
.cfi_endproc


.subsections_via_symbols

就在顶部,“.macosx_version_min”是问题所在。要更改此嵌入式版本号,您只需设置一个编译器标志:
$ gcc -mmacosx-version-min=10.7 -S -o main.S main.c

现在,当我们查看输出程序集时:

    .section    __TEXT,__text,regular,pure_instructions
.macosx_version_min 10, 7
.globl _main
.align 4, 0x90
_main: ## @main
.cfi_startproc
## BB#0:
pushq %rbp
Ltmp0:
.cfi_def_cfa_offset 16
Ltmp1:
.cfi_offset %rbp, -16
movq %rsp, %rbp
Ltmp2:
.cfi_def_cfa_register %rbp
xorl %eax, %eax
movl $0, -4(%rbp)
movl %edi, -8(%rbp)
movq %rsi, -16(%rbp)
popq %rbp
retq
.cfi_endproc


.subsections_via_symbols

繁荣,版本号固定。

关于macos - Mac .app 包向后兼容错误 : "You can' t use this version of the application "[my app name]" with this version of OS X.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39310079/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com