1、QC里编译工程,生成Release版的的app文件;
2、运行macdeployqt把需要的文件打包进app文件中;
% ~/Qt/5.15.0/clang_64/bin/macdeployqt {编译的app文件所在路径}/Release/xxxx.app
3、使用codesign对app进行签名,如果要发App Store的话使用"Mac App Distribution"证书,如果不发的话使用”Developer ID Installer“证书,证书配置在苹果开发者账号苹果证书中创建。
下载证书并安装,结果如下:
3、然后使用codesign对app签名:
% codesign --entitlements {entitlements文件所在目录}/xxxx.entitlements -f -s "3rd Party Mac Developer Application: xxxxxx Co.,Ltd (VQ3IY989UY87)" -v xxxx.app --deep
#运行完结果如下:
xxxx.app: replacing existing signature
xxxx.app: signed app bundle with Mach-O thin (x86_64) [com.xxxx.xxxx] #此处是Bundle Identifier#签名完成
权限文件xxxx.entitlements,可以在xcode的工程里去复制一个,也可以根据需要的权限手工编辑:
检查签名结果:
% codesign -dvvv --entitlements - xxxx.app
Executable=/这里忽略目录/xxxx.app/Contents/MacOS/xxxx
Identifier=com.xxxx.xxxx
Format=app bundle with Mach-O thin (x86_64)
CodeDirectory v=20400 size=18452 flags=0x0(none) hashes=566+7 location=embedded
Hash type=sha256 size=32
CandidateCDHash sha256=3ed48febdcc36c83hfyuuyt876236f4633bb7b
CandidateCDHashFull sha256=3ed48febdcc36c83a748febdcc36c83hfyuuyt876236f463317fb2f401a8f7a7afaf
Hash choices=sha256
CMSDigest=3ed48febdcc36dcc36c83hfyuuyt876236f46337fb2f401a8f7a7afaf
CMSDigestType=2
CDHash=3ed48febdcc3648dcc36c83hfyuuyt87623332f17236f4633bb7b
Signature size=4854
Authority=3rd Party Mac Developer Application: xxxxxxxxx Co.,Ltd (VQ3IY989UY87)
Authority=Apple Worldwide Developer Relations Certification Authority
Authority=Apple Root CA
Signed Time=Nov 2, 2024 at 01:06:18
Info.plist entries=14
TeamIdentifier=V86876Q87987F
Sealed Resources version=2 rules=13 files=46
Internal requirements count=1 size=232
[Dict][Key] com.apple.developer.usernotifications.communication[Value][Bool] true[Key] com.apple.security.app-sandbox[Value][Bool] true[Key] com.apple.security.files.user-selected.read-only[Value][Bool] true[Key] com.apple.security.files.user-selected.read-write[Value][Bool] true[Key] com.apple.security.network.client[Value][Bool] true[Key] com.apple.security.network.server[Value][Bool] true[Key] com.apple.security.personal-information.photos-library[Value][Bool] true[Key] com.apple.security.print[Value][Bool] true#下部分是权限列表
4、然后打开xxxx.app,找到里面的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>xxxx</string><key>CFBundleIconFile</key><string>icon.icns</string><key>CFBundleIdentifier</key> <!--这个必须要有--><string>com.xxxx.xxxx</string><key>CFBundlePackageType</key> <!--这个必须要有--><string>APPL</string><key>CFBundleSignature</key><string>????</string><key>LSMinimumSystemVersion</key><string>10.13</string><key>NOTE</key><string>This file was generated by Qt/QMake.</string><key>NSPrincipalClass</key> <!--这个必须要有--><string>NSApplication</string><key>NSSupportsAutomaticGraphicsSwitching</key><true/><key>CFBundleDisplayName</key> <!--这个尽量要有--><string>我的应用</string><key>CFBundleName</key><string>我的应用</string> <!--这个必须要有--><key>LSApplicationCategoryType</key> <!--这个必须要有--><string>public.app-category.utilities</string><key>CFBundleVersion</key> <!--这个必须要有--><string>100</string><key>CFBundleShortVersionString</key><string>1.0.0</string> <!--这个必须要有--><key>ITSAppUsesNonExemptEncryption</key><false/>
</dict>
</plist>
5、然后,使用productbuild对app进行打包成pkg文件,这里注意使用另外一个安装证书”3rd Party Mac Developer Installer“:
% productbuild --component xxxx.app /Applications/ --sign "3rd Party Mac Developer Installer: xxxxxxxx Co.,Ltd (VQ3IY989UY87)" --product xxxx.app/Contents/Info.plist xxxx.pkgproductbuild: Adding component at /这里省略路径了/Release/智行动力.app
productbuild: Signing product with identity "3rd Party Mac Developer Installer: xxxxxxxx Co.,Ltd (VQ3IY989UY87)" from keychain /Users/hhhhh/Library/Keychains/login.keychain-db
productbuild: Adding certificate "Apple Worldwide Developer Relations Certification Authority"
productbuild: Adding certificate "Apple Root CA"
productbuild: Wrote product to xxxx.pkg
productbuild: Supported OS versions: [Min: 10.13, Before: None]#上面执行完成
6、最后,将生成pkg文件拖拽到Transporter中,看看Transporter上传检查是否出错,如果不出错就可以发布了。
注意:签名证书和产品打包证书是两个;
其余的就,自求多福吧!