0

我有一个名为determinant_calculator.app 的简单应用程序,它是使用Python 3.9 和pyinstaller 创建的。它在我自己的运行 OS 11.3.1 的 Mac 上运行良好。我想与 App Store 以外的其他人分享它。我有一个 Apple Developer 帐户,但我没有开发经验,也没有使用过 XCode。我正在尝试按照https://github.com/pyinstaller/pyinstaller/wiki/Recipe-OSX-Code-Signing中给出的步骤进行操作

我访问了 Apple Developer 的网站并创建了一个证书 developerID_application.cer,并将其下载到我的桌​​面上。在 Keychain Access 中,我上传了证书并在“我的证书”下看到它作为“开发者 ID 应用程序:PaulF (47A67S7RBW)”

determinant_calculator.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>CFBundleDevelopmentRegion</key>
      <string>English</string>
      <key>CFBundleDisplayName</key>
      <string>determinant_calculator</string>
      <key>CFBundleExecutable</key>
      <string>determinant_calculator</string>
      <key>CFBundleIconFile</key>
      <string>PythonApplet.icns</string>
      <key>CFBundleIdentifier</key>
      <string>org.pythonmac.unspecified.determinant_calculator</string>
      <key>CFBundleInfoDictionaryVersion</key>
      <string>6.0</string>
      <key>CFBundleName</key>
      <string>determinant_calculator</string>
      <key>CFBundlePackageType</key>
      <string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>0.0.0</string>
<key>LSHasLocalizedDisplayName</key>
<false/>
<key>NSAppleScriptEnabled</key>
<false/>
<key>NSHumanReadableCopyright</key>
<string>Copyright not specified</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>PyMainFileNames</key>
<array>
    <string>__boot__</string>
</array>
<key>PyOptions</key>
<dict>
    <key>alias</key>
    <true/>
    <key>argv_emulation</key>
    <false/>
    <key>emulate_shell_environment</key>
    <false/>
    <key>no_chdir</key>
    <false/>
    <key>prefer_ppc</key>
    <false/>
    <key>site_packages</key>
    <false/>
    <key>use_faulthandler</key>
    <false/>
    <key>use_pythonpath</key>
    <false/>
    <key>verbose</key>
    <false/>
</dict>
<key>PyResourcePackages</key>
<array/>
<key>PyRuntimeLocations</key>
<array>
    <string>@executable_path/../Frameworks/Python.framework/Versions/3.9/Python</string>
    <string>/Library/Frameworks/Python.framework/Versions/3.9/Python</string>
</array>
<key>PythonInfoDict</key>
<dict>
    <key>PythonExecutable</key>
    <string>/Library/Frameworks/Python.framework/Versions/3.9/bin/python3</string>
    <key>PythonLongVersion</key>
    <string>3.9.2 (v3.9.2:1a79785e3e, Feb 19 2021, 09:06:10) 
[Clang 6.0 (clang-600.0.57)]</string>
    <key>PythonShortVersion</key>
    <string>3.9</string>
    <key>py2app</key>
    <dict>
        <key>alias</key>
        <true/>
        <key>template</key>
        <string>app</string>
        <key>version</key>
        <string>0.24</string>
    </dict>
</dict>

然后在命令行中输入以下内容:

codesign -s "PaulF" determinant_calculator.app

我被要求提供我的钥匙串登录信息,一切似乎都很好。(至少我没有收到任何错误消息。)现在在determinant_calculator.app 包内容中,我看到了一个名为_CodeSignature 的新文件夹。

第一次压缩文件后,我通过 Dropbox 将 .app 与另一台计算机共享。

但是,当我在新电脑上解压文件并双击它时,我得到错误信息,“determinant_calculator”无法打开,因为无法验证开发者。

这是我第一次尝试对应用程序进行公证,我的 Python 脚本非常简单,只使用 tkinter 和 numpy。

4

1 回答 1

1

您不仅需要对您的应用程序进行代码设计,还需要对其进行公证(作为单独的步骤)。如果您在您的应用所在的文件夹中运行以下命令,它将将该应用发送给 Apple 进行检查。Apple 将返回票证 ID。然后,您可以在几分钟后检查您的公证历史,以查看公证是否通过:

公证命令:

xcrun altool --notarize-app --primary-bundle-id "com.yourname.yourappname" --username "YourAppleID@mail.com" --password "@keychain:Developer-altool" --file "helloworld.zip"

公证历史检查命令:

xcrun altool --notarization-history 0 --username "YourAppleID@mail.com" --password "@keychain:Developer-altool"
于 2021-10-08T05:28:22.613 回答