Qt’s iOS port allows you to run Qt applications on iOS devices, such as iPhones, iPads, and iPod Touches.(Qt中的iOS接口支持在iPhones、iPads、iPod Touches等设备中运行Qt应用程序。)
一、Getting Started(入门指南)
Development and deployment is done using Xcode. The supported workflow is to maintain a .pro file based project, which generates an Xcode project. Building and deploying can be done using either Xcode or Qt Creator. We will look at that in more detail in the next section.
The minimum deployment target for Qt applications is specified in Supported Platforms.
(使用Xcode开发和部署,构建和部署既可以用Xcode也可以用Qt Creator。在后面的章节会有详细介绍)
1.Setting Up the Development Environment(构建开发环境)
You can download the Qt 5 installers from the Downloads page. For more information, see Getting Started with Qt.
Before installing Qt, you first need to install Xcode. You will find it in the Mac App Store here.(在下载页面下载Qt5安装程序,更多信息可以查看Qt入门指南。在安装Qt之前,你首先要安装Xcode,它可以在Mac 应用商店中找到。)
Note: As recommended by Apple, you should always use the latest Xcode version when building your applications for the App Store. In practice this means you also need the latest version of macOS to develop apps with Qt, due to Xcode’s system requirements.(注意:当你为应用商店构建应用的时候,Apple公司推荐使用最新的Xcode版本。事实上这也意味着你必须用最新版本的macOS来开发应用,这也是Xcoed的系统要求。)
For running Qt applications on your Mac or in the simulator that comes with Xcode, this is all you need. However, for running applications on a mobile device and/or publishing your applications in the App Store, you must join the Apple Developer Program, and set up developer certificates and provisioning profiles. The easiest solution is to use a profile that takes any App ID (a *).(在Mac上或模拟器上运行Qt程序,你只需要Xcode即可。然而,如果你要在移动设备上运行应用程序或是在应用商店发布你的应用,你就必须加入Apple Developer Program,创建开发者证书和提供配置文件,最简单的解决方法是使用可以得到任何App ID的配置文件。)
Before building any Qt applications, you should test that Xcode is set up correctly, for example, by running one of the standard Xcode application templates on your device.
(在构建任何一个Qt应用之前,你必须测试一下Xcode是否创建正确,可以在你的设备上运行一个标准的Xcode应用来进行测试。)
2.Building Applications From the Command Line(用命令行来构建应用程序)
As mentioned previously, the development workflow consists of maintaining a normal .pro file project and exporting it to Xcode.
(就像先前提到的一样,开发的工作流程包括维护一个正常的.pro文件项目和输出到Xcode。)
Here is how to build a project with Xcode:
(下面是用Xcode怎样构建一个工程)
Note: that you must re-import the project if its setup changes, for example, when adding or removing source files.(注意:如果创建的工程发生了变化,你必须重新进入这个工程。比如说添加了或者删除了源文件等情况。)
3.Building Applications with Qt Creator(使用Qt Creator构建应用程序)
You can find information on how to set up and run Apple mobile device applications in Qt Creator’s manual:(在Qt Creator的指南中,你可以找到如何创建和运行Apple移动设备应用程序的信息:)
Connecting Apple Mobile Devices.(连接Apple移动设备)
As mentioned previously, you must have Xcode installed.(就像先前提到的,你必须已经安装了Xcode。)
二、Using Objective-C Code in Qt Applications(在Qt应用程序中使用Objective-C 代码)
Clang, the compiler used for applications on Apple Platforms, allows mixing C++ and Objective-C code. To enable this mode, suffix your source files with .mm, and add them to OBJECTIVE_SOURCES instead of SOURCES in the .pro file. This makes it possible to use frameworks from Apple’s Developer Library in Qt applications. Most useful is perhaps the possibility for adding In-App Purchasing with the StoreKit framework.(用于苹果平台上的应用程序的编译器允许混合C++ 和Objective-C代码,为了使能这个模式,可以为你的源文件添加.mm的后缀,添加它们到OBJECTIVE_SOURCES而不是在.pro文件中的SOURCES。这可能会用到Qt应用程序中的Apple开发库的框架)
We currently have one example mixing Objective-C and C++ code. You find it here.(下面是混合了Objective-C 和 C++代码的一个示例。 )
三、Examples for iOS(iOS的示例)
In Qt Creator, tested examples on iOS can be looked up. Use the ios keyword to search for examples in the Qt Creator Welcome mode. Note that some examples may have limited functionality.(在Qt Creator中,可以找到运行在ios上的测试用例,在Qt Creator Welcome界面搜索关键字ios就可以找到。注意:有些例子功能有限。)
For a list of examples known to work on iOS devices, visit Qt for iOS Examples.(可以去Qt for iOS Examples中找到更多的在iOS上运行的示例。)
四、Related Topics(相关主题)
The following topics provide more details about Qt for iOS:(下面的主题提供了更多关于Qt for iOS的细节)