修改 Info.plist 以启动应用程序
Modify Info.plist to launch app
我正在尝试构建一个简单的应用程序,最终用户只需双击即可启动。
这是我的文件夹树:
MyProgram.app/
Contents/
Info.plist
MacOS/
exe_not_exe --> this is a dummy exe, but needed
MyProgram-mac-os-x86_64/
MyProgram.app/ ---> THIS APP is executable
Contents/
Info.plist
MacOS/
exe_really_exe --> this is the exe really executed
我希望当用户双击第一个 MyProgram.app 时,应用程序启动,但实际上使用 exe_really_exe
,而不是 exe_not_exe
。
第一个Info.plist有关键的地方:
<key>CFBundleExecutable</key>
<string>exe_not_exe</string>
所以我尝试构建这个树文件夹:
MyProgram.app/
Contents/
Info.plist
MacOS/
exe_not_exe
launcher --> this is a new file
MyProgram-mac-os-x86_64/
MyProgram.app/
Contents/
Info.plist
MacOS/
exe_really_exe
并且在 launcher
文件中:
#!/usr/bin/env bash
open ../../MyProgram-mac-os-x86_64/MyProgram.app
open ../../MyProgram-mac-os-x86_64/MyProgram.app/MacOS/exe_really_exe
(我尝试了两种不同的说明)。如果我从其目录启动 launcher
文件,一切都会按预期进行。
我修改了Info.plist(树中最高的那个):
<key>CFBundleExecutable</key>
<string>launcher</string>
但最后,如果我双击 MyProgram.app(树中最高的那个),应用程序不会启动。如果我从命令行启动它,我得到错误:
LSOpenURLsWithRole() failed with error -10810 for the file MyProgram.app/
你能帮我看看我的程序有什么问题吗?
看来我做的一切都是对的。但我需要重命名 .app 包,然后再重命名。 Mac OS 需要 "reload" Info.plist,否则更改不算数。这完全是愚蠢和愚蠢的,它让我花了很长时间才弄明白。
我正在尝试构建一个简单的应用程序,最终用户只需双击即可启动。
这是我的文件夹树:
MyProgram.app/
Contents/
Info.plist
MacOS/
exe_not_exe --> this is a dummy exe, but needed
MyProgram-mac-os-x86_64/
MyProgram.app/ ---> THIS APP is executable
Contents/
Info.plist
MacOS/
exe_really_exe --> this is the exe really executed
我希望当用户双击第一个 MyProgram.app 时,应用程序启动,但实际上使用 exe_really_exe
,而不是 exe_not_exe
。
第一个Info.plist有关键的地方:
<key>CFBundleExecutable</key>
<string>exe_not_exe</string>
所以我尝试构建这个树文件夹:
MyProgram.app/
Contents/
Info.plist
MacOS/
exe_not_exe
launcher --> this is a new file
MyProgram-mac-os-x86_64/
MyProgram.app/
Contents/
Info.plist
MacOS/
exe_really_exe
并且在 launcher
文件中:
#!/usr/bin/env bash
open ../../MyProgram-mac-os-x86_64/MyProgram.app
open ../../MyProgram-mac-os-x86_64/MyProgram.app/MacOS/exe_really_exe
(我尝试了两种不同的说明)。如果我从其目录启动 launcher
文件,一切都会按预期进行。
我修改了Info.plist(树中最高的那个):
<key>CFBundleExecutable</key>
<string>launcher</string>
但最后,如果我双击 MyProgram.app(树中最高的那个),应用程序不会启动。如果我从命令行启动它,我得到错误:
LSOpenURLsWithRole() failed with error -10810 for the file MyProgram.app/
你能帮我看看我的程序有什么问题吗?
看来我做的一切都是对的。但我需要重命名 .app 包,然后再重命名。 Mac OS 需要 "reload" Info.plist,否则更改不算数。这完全是愚蠢和愚蠢的,它让我花了很长时间才弄明白。