iOS Publishing Example
This article will demonstrate the process of publishing a Cocos Creator project as an iOS application. Before getting started, you will need the following preparations:
- A macOS device with Xcode installed
- An Apple Developer account
Register an Apple Developer account
Firstly, you need to have an Apple Developer account. If you don't have one, please go to the registration page to create an account.
Verify the macOS System and Xcode Version
Publishing iOS apps via Cocos Creator environment requirements:
- Xcode version 11.5 or above.
- macOS version 10.14 or above.
Note: By default, the corresponding Xcode version in the App Store matches the system. If you want to use a specific version of Xcode, you can download it from the Xcode download page.
Prepare a Test Project
Open an existing project or create a new one.
As shown in the image above, select Project -> Build from the top menu in Cocos Creator to open the build panel.
In the blue section on the left side of the image, you can find the common parameters that need to be configured for all platforms supported by Cocos Creator. For more details, you can refer to the General Build Options page.
iOS Specific Options
Choose the platform as iOS, and as you scroll down the panel, you will see the red section on the right side. These are the configurations specific to the
iOS platforms. For more details, please refer to the General Native Build Options and Build Options - iOS pages.
The Bundle Identifier is a required configuration. It is generally in the format of
com.mycompany.myproduct. For example, in this example, it is set to
Perform the Build
After completing the configurations, click the Build button to generate the Xcode project.
Once the build is successful, you can click the open file button as shown below to open the generated project folder.
If you haven't changed the build path, you can find the
build/ios/proj directory in the project root, which contains the following files:
Compile and Run in Xcode
build/ios/proj/<project_name>.xcodeproj to open the Xcode project.
<ProjectName>-mobile as the build target, choose a suitable simulator or a connected iOS device, and click the compile and run button to start the project.
Sometimes, projects need to call iOS system functions from the script layer, or when integrating a third-party iOS SDK, it is necessary to call its API through script code. In such cases, the communication mechanism between the script layer and the native layer is required.
For communication mechanisms, please refer to:
Some issues only occur on specific devices and environments. If you can debug the code on the corresponding situation, you can quickly identify the problem and find a solution.
Features and System Versions
Different features rely on specific system versions. Please refer to Features and System Versions for more details.