我的Mac OSX应用包问题。
如果我想运行我的应用程序包,则不会发生任何事情(双击myApp.app
)。
我可以毫无问题地执行./myApp.app/Contents/MacOS/myApp
来运行应用程序。
目录结构:
myApp.app/
Contents/
Info.plist
PkgInfo
Resources/
Frameworks/
MacOS/
myApp
我的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>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>myApp</string>
<key>CFBundleIconFile</key>
<string>icon</string>
<key>CFBundleIdentifier</key>
<string>com.whatever.test</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<key>CFBundleSignature</key>
<string>com.whatever.test</string>
<key>CFBundleVersion</key>
<string>1.0.0</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2014. All rights reserved.</string>
</dict>
</plist>
修改
Console.app结果:
08.02.14 16:30:45,041 com.apple.launchd.peruser.501[1077]: (com.whatever.test.72544[20350]) Job failed to exec(3) for weird reason: 13
08.02.14 16:30:45,043 Finder[1094]: 8837325: Attempting to SIGCONT to pid #20350 failed, with errno=#3, or the process failed to actually start
08.02.14 16:30:45,046 Dock[1091]: no information back from LS about running process LSASN:{hi=0x0;lo=0x168168}
答案 0 :(得分:0)
鉴于您错过了_CodeSignature
目录,我认为您的代码没有正确签名。因此GateKeeper
可能阻止代码运行。
您有两种选择:
Open
- 它将绕过代码签名检查。答案 1 :(得分:0)
这一行:
08.02.14 16:30:45,041 com.apple.launchd.peruser.501[1077]: (com.whatever.test.72544[20350]) Job failed to exec(3) for weird reason: 13
让我认为你有一个基于这个手册页的Permission Denied
问题:
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man2/intro.2.html
答案 2 :(得分:0)
这是一个工作目录问题。执行“myApp.app”时使用getcwd
会产生/
我使用bundle dir而不是getcwd
来修复它:
#include <CoreFoundation/CoreFoundation.h>
std::string getBundleDir()
{
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
char path[PATH_MAX];
if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX))
return "";
CFRelease(resourcesURL);
chdir(path);
return path;
}