5

我有一个用 Qt 构建的 OSX 应用程序。它经过代码设计、打包以适合 macstore,并已获得苹果的批准,可以在 mac 商店中销售。

虽然在安装后,它会安装到它在打包过程中所在的位置,而不是 /Applications。

或者,我正在创建文件的 .dmg 包,我可以将其安装到 /Applications 中。

在构建过程结束时,我正在运行这些命令:

codesign --force --deep --verify MyApp.app/ --entitlements ${INSTDIR}/Entitlements.plist -s "3rd Party Mac Developer Application: Company Name"
productbuild --component MyApp.app /Applications --sign "3rd Party Mac Developer Installer: Company Name" MyApp.pkg

结果是我试图通过安装程序安装的 pkg:

$ sudo installer -store -pkg MyApp.pkg -target /
installer: Note: running installer as an admin user (instead of root) gives better Mac App Store fidelity
installer: MyApp.pkg has valid signature for submission: 3rd Party Mac Developer Installer: Company Name (key)
installer: Installation Check: Passed
installer: Volume Check: Passed
installer: Bundle com.CompanyName.MyApp will be relocated to /Users/peti/dev/build/bin/Mac/release/MyApp.app
installer: Starting install
installer: Install 0.0% complete
installer: Install 17.1% complete
installer: Install 96.4% complete
installer: Install 100.0% complete
installer: Finished install

在 productbuild 之后,重定位说 /Applications,但它没有在那里安装它!在随后的运行中,它会说错误的路径。我也尝试过从不同的位置安装。

我也尝试从 Mac Store 安装应用程序,它的作用相同......它进入了不正确的路径。

我用过:

pkgutil --expand

提取包。PackageInfo 文件是这样说的:

<pkg-info overwrite-permissions="true" relocatable="false" identifier="com.CompanyName.MyApp" postinstall-action="none" version="3.0.0" format-version="2" generator-version="InstallCmds-502 (14F1605)" install-location="/Applications" auth="root" preserve-xattr="true">

有什么想法可能会出错吗?我试图用谷歌搜索解决方案,但没有运气。这个不正确的路径可以存储在哪里?在 productbuild 之前,我没有看到嵌入到任何文件中的路径。productbuild 是否在做一些奇怪的事情?

4

2 回答 2

4

最后我想我有一个解释。

它可以正确安装在除我们的构建机器之外的所有其他机器上。原因似乎是,在您从文件系统上的任何位置执行命名的 MyApp.app 后,osx 会记住该路径。因此,当您下次尝试安装它(更新?)时,它将更新已知路径上的应用程序。

一个更奇怪的情况是,当您有两个“安装”应用程序(两个副本)并且您尝试再次安装它时,它将在两个实例之间交替安装它!闻起来像一个错误,Apple 永远不会修复。

感谢@l'L'l 的帮助。如果您能向我解释这种行为,那将是一个加号。

于 2016-04-21T02:02:29.170 回答
0

我也遇到了这个问题,我发现解决它的唯一方法是在过程中使用一个中间pkgbuild步骤,使用一个组件-plist 文件 ( components.plist)。

下面的命令假定一个名为Applications的目录包含在当前目录中存在的构建产品(应用程序)以及文件components.plist. 它将结果写入ApplicationPackage.pkg.

$ > pkgbuild --root ./Applications --component-plist ./components.plist --identifier "com.company.app.pkg" --install-location /Application ApplicationPackage.pkg

然后是产品构建步骤。

Key 实际上是带有 value的BundleIsRelocatable-key 。components.plistfalse

<?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">
<array>
    <dict>
        <key>BundleHasStrictIdentifier</key>
        <true/>
        <key>BundleIsRelocatable</key>
        <false/>
        <key>BundleIsVersionChecked</key>
        <true/>
        <key>BundleOverwriteAction</key>
        <string>upgrade</string>
        <key>RootRelativeBundlePath</key>
        <string>AppBundle.app</string>
    </dict>
</array>
</plist>
于 2018-03-19T22:18:06.977 回答