1.首先当然是用Qt Creator。编译一个Release版本号的软件
注意到编译出来的大小非常小,才420KB,由于一些类库还没包括进去的原因。如今还仅仅能在你本地执行,复制到其它Mac电脑就不能执行了。
2.生成终于版的app
./macdeployqt yourappname.app 就能够了。就会自己主动在yourappname.app所在文件夹又一次生成一个新的比較大的app了。
关于一些使用了第三方类库的,我还没研究过怎样打包。
3.给app加上icon
里面有个叫info.plist的文件,里面记录了非常多这个软件的信息,icon的信息也记录在这里。
<?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>NSPrincipalClass</key> <string>NSApplication</string> <key>CFBundleIconFile</key> <string>icon.icns</string> <key>CFBundlePackageType</key> <string>APPL</string> <key>CFBundleGetInfoString</key> <string>Created by Qt/QMake</string> <key>CFBundleSignature</key> <string>??
??</string> <key>CFBundleExecutable</key> <string>TextureUnpacker</string> <key>CFBundleIdentifier</key> <string>@BUNDLEIDENTIFIER@</string> <key>NOTE</key> <string>This file was generated by Qt/QMake.</string> </dict> </plist>
就是CFBundleIconFile key 对于的值。
这个时候,右击app。选择显示信息(GetInfo),然后把icns文件拖到左上角的图标位置。
4.生成dmg文件
下面是我打包用的图片:
http://www.waitingfy.com/archives/1242