加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

xcode – 什么是最快/最简单的方法 – 从一开始就一步一步地在OS

发布时间:2020-12-15 01:44:23 所属栏目:百科 来源:网络整理
导读:我正在Qt中编写一个跨平台的应用程序(使用Qt Creator).其中一个目标平台是OS X. 通过使用BitRock Installer system创建.app文件,打包应用程序以在OS X上安装. 该应用程序旨在供各种不同学院和大学的政治学学生和研究人员下载和使用. (从App Store或产品网站
我正在Qt中编写一个跨平台的应用程序(使用Qt Creator).其中一个目标平台是OS X.

通过使用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,或作为独立的应用程序安装程序独立分发:

>检查应用程序图标 – 它应具有所有尺寸(16×16,32×32,64×64,128×128,256×256,512×512,1024×1024). (见https://stackoverflow.com/a/21028483/368896)
>添加编译选项以正确生成调试符号:

QMAKE_CFLAGS = -gdwarf-2 QMAKE_CXXFLAGS = -gdwarf-2

(注意Qt Creator可能不会将QMAKE_CFLAGS突出显示为有效,但仍可能需要包括在内 – 请参阅here)
>设置应保存在与包标识符同名的目录中.
>检查应用程序的Info.plist文件.它应包含正确的包标识符和10.6.6的最小MacOS X版本.

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

(另请参阅以下有关如何获取包标识符的说明.)

(最小OS X版本 – 应该设置为10.6.6或更高版本 – 可以使用.pro文件中的以下行进行设置:QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6 – 但如果您使用自定义info.plist文件,则此设置赢了’生效,因此您必须在自定义info.plist中包含正确的设置;请参阅文件中应使用的条目的上一个链接.)
>您还需要证书才能签署您的应用程序和安装程序:打开“Keychain Access”(使用Mac OS X搜索) – >双击每个证书(查看这些证书的种类栏)并输入密码 – >检查Keychain Access中添加的证书.

在iTunesConnect中注册应用程序

>在http://itunesconnect.apple.com登录您的开发者帐户(将您重新路由到https://,但您可能需要先输入http://)

(注意:如果您还没有,则必须先创建一个Mac开发者帐户,每年99美元,才能继续.)
>点击“管理您的应用” – > “添加新应用”
>如果应用程序没有Bundle 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): 07004.

-> 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).最后,选择Bundle ID.单击继续.
>选择可用日期(目前只是尽可能的 – 目前,它最多只能使用2年).选择价格等级(可以是任何 – 客户可以稍后更改).单击继续.
>在以下屏幕上输入详细的应用程序信息,然后单击“保存”.
>点击应用页面中的“查看详细信息” – >点击“准备上传二进制文件” – >在摘要页面上单击链接“Application Loader的最新版本”并下载它 – >点击“继续”.

创建和上载安装程序

>检查应用程序Info.plist – 输入正确的包ID,应用程序名称,类别.
>在发布模式下构建应用程序.
>提取调试符号.在命令行:

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 07006,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
07007 for more details.exists and is enabled for code

>创建安装程序(需要其他证书;请参阅注释):

productbuild –component ./MyApp.app/ Applications –sign“第三方Mac开发者安装程序:Daniel Nissenbaum(S6V5TT9QRL)”MyApp.pkg

请注意,需要使用不同的证书作为–sign参数的参数.证书的类型为“Mac Installer Certificate”,而不是“Mac App Distribution”(与上面的codesign一起使用的证书类型).要创建此证书,请按照上述相同步骤操作,但选择Mac Installer Certificate作为类型.在此处使用其Common Name作为–sign参数的参数.

应用程序名称前面的./可能很重要.此外,使用与运行codesign时所执行的–sign参数相同的参数 – Developer证书的公用名.往上看.
>检查安装程序:

sudo installer -store -pkg MyApp.pkg -target /
>如果没有错误,您现在拥有一个合法的Mac应用程序,打包到合法的Mac安装程序中,这两个程序都可以分发给任何人.您可以通过简单地发送.pkg文件(通过网站,Dropbox等)来分发它们,也可以上传到Mac App Store.
>我还没有确认这些步骤,这些步骤实际上将应用程序上传到Mac App Store:打开应用程序加载器并使用Apple Developer Account登录 – >选择“发送您的应用” – >选择正确的AppID – >单击“应用程序信息”页面上的“选择…”按钮,然后选择创建的pkg文件 – >点击“发送”.

附加信息

> Information about entitlements
> Information about Info.plist
> Additional information about deploying app to Mac AppStore

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读