gpt4 book ai didi

xcode - 从一开始逐步逐步/最快的方法到在OS X上 “code sign”我的Qt应用程序是什么,以便可以分发?

转载 作者:行者123 更新时间:2023-12-04 13:27:23 26 4
gpt4 key购买 nike

我正在Qt中编写跨平台应用程序(使用Qt Creator)。目标平台之一是OSX。

通过使用BitRock Installer system创建.app文件,将该应用程序打包为可在OS X上安装。

该应用程序供各种不同学院和大学的政治学专业的学生和研究人员下载和使用。 (从App Store或产品网站上下载都可以。)

我不需要iCloud或与App Store相关的任何其他功能。我只需要能够分发此应用程序,这样就不会出现警告(如下)。

当前,该应用程序处于Alpha测试状态-仅由产品经理进行测试。尽管如此,我还是希望为产品经理提供OS X的安装软件包,该软件包的而不是会向他们显示以下警告:

The [installer application] can't be opened because it is from an unidentified developer



(更重要的是,在发布应用程序时,我也不希望最终用户看到此警告。)

我了解我需要准备通过 using an Apple Developer account and properly signing the application分发的应用程序。

我已经创建了一个开发人员帐户,并且尝试按照链接中的步骤对我的应用程序进行签名并准备进行分发。

但是,由于该应用程序是在Qt中而不是Xcode中构建的,因此我不知道如何完成这些步骤,因为某些关键步骤假定正在使用Xcode。

我搜索了任何问题,这些问题可能描述了如何在OS X上准备Qt应用程序以进行分发,但空无一物。

(此外,在任何情况下,我还希望提供一组尽可能简单的步骤,最好是比上述链接中提供的步骤更简单的步骤。)

哪一组最简单的步骤可以使我在OS X上对使用Qt开发的应用程序进行代码签名,以便可以对其进行分发?

最佳答案

准备.app文件

这是创建已签名程序包的分步指南,该程序包可以上传到Mac App Store或作为独立的应用程序+安装程序独立分发:

  • 检查应用程序图标-它应具有所有大小(16x16、32x32、64x64、128x128、256x256、512x512、1024x1024)。 (请参阅https://stackoverflow.com/a/21028483/368896)
  • 添加编译选项以正确生成调试符号:
    QMAKE_CFLAGS += -gdwarf-2 QMAKE_CXXFLAGS += -gdwarf-2
    (请注意,Qt Creator可能未将QMAKE_CFLAGS突出显示为有效,但仍可能需要将其包括在内-参见here)
  • 设置应保存在与包标识符相同名称的目录中。
  • 检查应用程序的Info.plist文件。它应包含正确的捆绑软件标识符和最低MacOS X版本10.6.6。

    (注意:尽管Qt Creator自动生成了一个默认的info.plist文件,该文件位于.app捆绑包内,但也可以创建自己的文件并自动使用它。请参见this link for a sample info.plist file that works with Qt and the App Store,请注意QMAKE_INFO_PLIST确实可以使用a自定义文件(请参阅该链接中的注释)。

    (另请参阅以下有关如何获取捆绑包标识符的注释。)

    (最低OS X版本-应该设置为10.6.6或更高版本-可以在.pro文件中的以下行中进行设置:QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6-但是,如果您使用自定义的info.plist文件,则该设置不会生效,因此您仍然必须在自定义info.plist中包括正确的设置;请参阅前面的链接,以获取应在文件中使用的条目。)
  • 您还需要证书来签署您的应用程序和安装程序:打开“Keychain Access”(使用Mac OS X搜索)->双击每个证书(在kind列中查找)并输入密码->在Keychain中检查添加的证书使用权。

  • 在iTunesConnect中注册应用程序
  • 通过http://itunesconnect.apple.com登录到您的开发人员帐户(这会将您重新路由到https://,但您可能需要先输入http://)。

    (注意:如果您还没有一个,则必须先创建一个Mac开发者帐户,每年$ 99,然后才能继续。)
  • 单击“管理您的应用”->“添加新应用”
  • 如果应用程序没有捆绑包ID,请创建它。

  • Creating a new Bundle ID is not intuitive.

    To create a new Bundle ID:

    -> Log in to the Developer Center website: This is a different site (perhaps open it in a new tab): http://developer.apple.com.

    -> Click Member Center near the very top right (next to the search bar)

    -> Click on Manage your certificates, App IDs, devices, and provisioning profiles (underneath Certificates, Identifiers & Profiles)

    -> Click on App IDs in the left navigation bar (in the Identifiers section) (This might already be selected.)

    -> Click on + button

    -> The screen you now see (Register Mac App ID / Registering an App ID) is the screen you use to create a new bundle identifier

    -> Enter the necessary information. Write anything for the App ID Description (it can contain only a short line of text)

    The Explicit App ID field is actually the new Bundle ID. Type a reverse URL here, such as com.mydomain.myapp. A website or server does not actually need to exist at this URL. You just make one up here, but of course you can use one that already exists if you wish.

    -> Click Continue, then Submit if you're satisfied, then Done

    Now be sure to go back to the previous section, and add the Bundle ID you have just created to the custom info.plist file.

    Also save the Team ID in case you need it later - this is the string that precedes the Bundle > > ID (called the prefix) that you see when you look at the details of the Bundle ID you've just > > > created in the Developer Center.


  • 现在,返回iTunesConnect网站。 (也许在另一个标签中-这不是开发人员中心的网站。)
  • 在“应用程序信息”部分中,选择语言。然后,输入应用名称。为SKU字段组成一个随机字符串(我使用的格式为2436-7623-7782-8327)。最后,选择捆绑ID。单击继续。
  • 选择可用日期(目前,尽可能地短-当前,最多只能使用2年)。选择价格等级(可以是任何价格-客户以后可以更改)。单击继续。
  • 在以下屏幕上输入详细的应用程序信息,然后单击“保存”。
  • 在应用程序页面中单击“查看详细信息”->单击“准备上传二进制文件”->在摘要页面上,单击链接“Application Loader的最新版本”并下载它->单击“继续”。

  • 创建和上传安装程序
  • 检查应用程序Info.plist-输入正确的捆绑软件ID,应用程序名称,类别。
  • 以 Release模式构建应用程序。
  • 提取调试符号。在命令行中:
    dsymutil MyApp.app/Contents/MacOS/MyApp -o MyApp.app.dSYM
  • 执行帮助程序macdeployqt(Qt附带)。在命令行中:
    /path/to/macdeployqt /path/to/myapp.app
    (macdeployqt可以在QTDIR/bin中找到。有关一些官方详细信息,请参见this link。)

    运行macdeployqt可以通过并入.app捆绑包内部的必要Qt框架并更改应用程序中的各种其他内部设置来修改现有应用程序。
  • 协同设计应用程序:

  • Codesigning is a tricky step.

    (1) Obtaining a DISTRIBUTION CERTIFICATE

    You must first create a Distribution certificate, if you don't already have one. (Not a Developer certificate.)

    (The following steps are taken from this link, with a correction regarding the certificate type)

    -> Open Xcode (version 5 as of this writing) -> Navigate to Xcode > Preferences -> Click the Accounts tab -> If you have not already done so, add the Apple ID that is registered in the Mac Developer Program -> Select the Apple ID that you want to use, and click View Details -> In the window that opens, click Add (+) and then select Mac App Distribution.

    (2) Code signing the application with the Distribution Certificate

    To properly codesign, every .framework and .dylib inside the .app bundle must FIRST be signed; and then the .app itself must be signed. See critical steps in bottom paragraph of this grey block before you codesign the internal Qt frameworks - and be sure to do this first.

    The command to sign the internal libraries/frameworks, and the command to sign the main .app, is the same:

    codesign -s "3rd Party Mac Developer Application: Daniel Nissenbaum (S6V5TT9QRL)" –-entitlements
    MyEntitlements.plist MyApp.app

    The --entitlements MyEntitlements.plist option is only necessary if you actually have entitlements beyond the basic defaults. I (Dan Nissenbaum) did not select additional privileges for my app when I created the Bundle ID in Developer Center (such as ability to access iCloud, push notifications, etc.). So, I left off the --entitlements option, and I have not looked into how to obtain a MyEntitlements.plist file.

    Note regarding the -s argument: See paragraph below for information about finding the correct name to use (this is the Distribution Certificate "Common Name").

    This codesign command is for the main .app. To codesign the internal (Qt) libraries/frameworks, which must be done first, use the proper path; i.e., in the command above, use MyApp.app/Contents/Frameworks/QtCore.framework rather than MyApp.app - and note that the path to the libraries/frameworks must be just to the root of the internal library/framework bundle, not to inside the internal library/framework bundle.

    Various other internal .dylibs or .frameworks may also need to be signed, in addition to the Qt .frameworks - if you try to sign your main application but have not signed all of the internal .dylibs/.frameworks, you will receive an error indicating another internal .dylib/.framework that needs signing. Just proceed through them all. In my case, there were about 10 additional .dylibs that needed to be signed after I completed signing the Qt .frameworks.

    Once you have the developer certificate, you need to find the name of the certificate for use with the codesign process. Open "Keychain Access" (to find this, simply type "Keychain Access" into the Search bar in the Finder, and locate the application from among the results returned). In the main list that you see when Keychain Access runs, you will see your Developer certificate among various other things. There will also be some other certificates - ignore those. It should be obvious which certificate is the correct one. In my case (which is standard, I assume), the certificate name is "3rd Party Mac Developer Application: Daniel Nissenbaum (S6V5TT9QRL)". This is the official name of the certificate, to be used as the -s argument to codesign, but to really confirm this, double-click on the certificate and in the info window that appears, have a look at the "Common Name". The value of Common Name is the official text to use as the -s argument of codesign.

    Note regarding a complication with codesign'ing the internal Qt frameworks. As of today, when macdeployqt is run, the Qt frameworks are not fully copied correctly into the .app bundle. They are missing their Info.plist file. But these necessary Info.plist files DO exist inside the Qt installation. You can simply use the Finder to copy them. (For example on my system, the required Info.plist file for the QtWidgets.framework framework has this path (where "Qt" corresponds to the root path of your Qt installation): Qt/5.1.1/clang_64/lib/QtWidgets.framework/Contents/Info.plist. This is to be copied into MyApp.app/Contents/Frameworks/QtWidgets.framework/Resources. Ditto for all of the other Qt frameworks that were copied into the MyApp.app bundle by macdeployqt. See https://stackoverflow.com/a/19639825/368896 for more details.exists and is enabled for code


  • 创建安装程序(需要其他证书;请参阅注释):
    productbuild –-component ./MyApp.app /Applications –-sign "3rd Party Mac Developer Installer: Daniel Nissenbaum (S6V5TT9QRL)" MyApp.pkg
    请注意,需要使用其他证书作为--sign参数的参数。 证书的类型为“Mac Installer证书”,而不是“Mac App Distribution”(上面与codesign一起使用的证书的类型)。要创建此证书,请按照上述相同的步骤进行操作,但是选择“Mac Installer证书”作为类型。在此处使用其通用名称作为--sign参数的参数。

    应用程序名称前的./可能很重要。另外,对--sign参数使用与运行codesign时相同的参数-开发人员证书的通用名称。看上面。
  • 检查安装程序:
    sudo installer -store -pkg MyApp.pkg -target /
  • 如果没有错误,则您现在有一个合法的Mac应用程序,打包到一个合法的Mac安装程序中,这两个程序都可以分发给任何人。您可以通过简单地发送.pkg文件(通过网站,Dropbox等)来分发它们,也可以将其上传到Mac App Store。
  • 我尚未确认这些步骤,这些步骤实际上是用于将应用程序实际上传到Mac App Store的:打开Application Loader并使用Apple Developer Account登录->选择“交付您的应用程序”->选择正确的AppID->单击在“应用程序信息”页面上单击“选择...”按钮,然后选择创建的pkg文件->单击“发送”。

  • 附加信息
  • Information about entitlements
  • Information about Info.plist
  • Additional information about deploying app to Mac AppStore
  • 关于xcode - 从一开始逐步逐步/最快的方法到在OS X上 “code sign”我的Qt应用程序是什么,以便可以分发?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20909341/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com