Macos 安装时忽略productbuild路径

Macos 安装时忽略productbuild路径,macos,qt,productbuild,Macos,Qt,Productbuild,我有一个用Qt构建的OSX应用程序。它经过代码设计、包装以适合macstore,并已获得苹果的批准,可以在macstore中销售 尽管安装后,它会安装到打包过程中它所在的位置,而不是/应用程序 或者,我正在创建该文件的.dmg包,可以将其安装到/Applications中 在构建过程结束时,我将运行以下命令: codesign --force --deep --verify MyApp.app/ --entitlements ${INSTDIR}/Entitlements.plist -s "3

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

尽管安装后,它会安装到打包过程中它所在的位置,而不是/应用程序

或者,我正在创建该文件的.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做了什么奇怪的事情吗?

最后我想我有一个解释

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

更奇怪的情况是,当您有两个应用程序的“安装”(两个副本)并且尝试再次安装时,它将在两个实例之间交替安装!闻起来像个虫子,苹果永远也无法修复


谢谢你的帮助@l'l'l。如果你能给我解释一下这种行为,那将是一个加号。

我也遇到了这种情况,我找到的唯一解决办法是在过程中使用一个组件plist文件(
components.plist
)使用中间
pkgbuild
步骤

下面的命令将创建一个名为Applications的目录,其中包含要在当前目录中显示的内置产品(应用程序)以及文件
components.plist
。它将结果写入
ApplicationPackage.pkg

$ > pkgbuild --root ./Applications --component-plist ./components.plist --identifier "com.company.app.pkg" --install-location /Application ApplicationPackage.pkg
然后是productbuild步骤

键实际上是
bundleisrelocateble
-键在
组件中。plist
的值为
false

<?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>

集束式分束器
可重定位
捆绑版本检查
BundleOverwriteAction
升级
RootRelativeBundlePath
AppBundle.app

.dmg
是一个磁盘映像,而不是一个包,但您当然可以在上面存储一个
.pkg
。@我知道,我不明白的是为什么打包的位置与安装路径有关。如果您指的是构建它时文件所在的位置,那是因为它用它来决定安装到哪里。@I'L'I嗯,为什么?如上所述,我明确表示productbuild的安装目标是/Applications。你能详细说明一下吗?尝试构建你的应用程序,然后执行
mv MyApp.app/Applications
。试图
cp-r
一个应用程序包可能会把事情搞砸。