Getting Started with Xcode Server: A Practical Guide for Simplifying CI/CD for iOS Apps
In the ever-changing realm of iOS app development, staying ahead of the curve is crucial, and this demands efficient processes and seamless teamwork. Continuous integration and continuous development are of utmost importance in this context.
In the market, there are various CI/CD service providers catering to different platforms and development ecosystems. Some popular options include Jenkins, Travis CI, CircleCI, and GitLab CI/CD. While these platforms offer generic CI/CD capabilities, they may not be optimized for iOS development needs.
Apple’s Xcode Server has been a popular choice for iOS development teams, offering continuous integration and continuous delivery (CI/CD) capabilities with benefits like automated testing, streamlined code integration, and reliable app distribution.
However, as technology advances, new challenges arise, prompting Apple to seek a more powerful and comprehensive solution. Xcode Server encountered issues due to its on-premises nature with limited scalability and dependence on local device testing.
Xcode Cloud — Apple’s latest innovation in the realm of iOS app CI/CD. Xcode Cloud takes the principles of Xcode Server to new heights, offering a cloud-based CI/CD service that goes beyond traditional practices. In this article, we will explore the configuration and functionalities of Xcode Cloud and see how it excels as the best CI/CD choice for iOS development teams.
Note: To use Xcode Cloud, you’ll need Xcode 13.4.1 or later and membership in the Apple Developer Program.
Apple has embraced integrating continuous integration with essential services like Xcode, TestFlight, and App Store Connect, providing a comprehensive suite for building, distributing, and managing Apple applications.
So, let’s see how tto release an application on the App Store, and how to publish the test-flight build using xcode-cloud.
1. Prepare Your Xcode Project: Ensure that you have an existing Xcode project that you want to integrate with Xcode Cloud. The project should be hosted in a Git repository.
2. Enable Xcode Cloud: To enable Xcode Cloud for your project, open Xcode and go to the “Preferences” menu (Xcode > Preferences). In the Preferences window, select the “Accounts” tab and sign in with your Apple Developer account. Make sure you are enrolled in an Apple Developer Program that includes access to Xcode Cloud.
3. Configure Your Project for Xcode Cloud: With Xcode Cloud enabled, open your Xcode project. In the project navigator, select your project’s root node. Look for the “Signing & Capabilities” tab and enable automatic signing. This step is necessary for Xcode Cloud to manage code signing during CI/CD processes.
4. Enable Xcode Cloud for the Project: Once your project is configured, you can enable Xcode Cloud integration. In the project navigator, click on the “Xcode Cloud” button, which is located at the top-right corner of the window. This will initiate the set up process for Xcode Cloud.
5. Create a Workflow: After clicking the “Get started” button, Upon selection of the product/project, the option of the pre-defined workflow will appear. Here, you can review or edit the workflow if needed.
Workflows define how your app is built, tested, and deployed in the cloud. You can create a workflow tailored to your specific project requirements.
Alternatively, setting up the workflow is fairly straight forward in Xcode. First you should go to the Xcode menu bar -> Product -> Xcode Cloud -> Create Workflow.
Every workflow is set up with the following configurations:
- Start Condition: In Xcode Cloud, you have the flexibility to configure various conditions related to branches for initiating builds. They can choose when the build should take place, such as on every change made to a branch, on pull requests, or on pushes to a branch. Additionally, you have the option to specify which branch they want to monitor for changes, whether it’s the main branch or any custom branch they have created. For more advanced scenarios, Xcode Cloud also allows you to define their own custom conditions based on specific criteria.
We can setup a scheduler by tapping on Start Condition + > on a schedule for a branch to run a scheduled workflow on a specific branch, by adding the time and days when it should be triggered
2. Environment: The environment section in Xcode Cloud enables you to select the exact Xcode version and macOS version they want to use for building their project. This feature ensures that the project is built in a controlled and consistent environment, ensuring compatibility and reproducibility across different builds.
3. Actions: In the actions section, you can make crucial selections for the build process. They can choose the project schema, which defines the build configuration and target. Furthermore, you can specify the platform for which the build should be created, whether it’s for iOS, macOS, tvOS, or watchOS. Additionally, they can configure deployment preparation, ensuring that the build is ready for distribution to testers or submission to the App Store.
4. PostActions: Once the build process is complete, the post-actions section allows you to execute additional actions. They can set up groups for external testers and internal testers, making it easier to distribute the build for testing purposes. This feature streamlines the process of sharing the app with stakeholders and ensures efficient testing and feedback gathering.
Prior to proceeding with the next steps, ensure the connection between App Store and Git is set up.Don’t forget to provide access to the corresponding Git project.
After granting access, any workflow action in the repository will trigger the build process. Xcode Cloud offers the option to select a branch before initiating the first build, allowing you to choose the specific branch from which you want to build the project.
Once the build is initiated, you can track its progress in both Xcode IDE and App Store Connect. If any issues occur during the build or archive process, you can review the error logs. Once the build is completed and successfully uploaded, you will be presented with a view containing the commit history and message.
What makes Xcode Cloud distinct from other CI/CD platform?
- One Application for Everything: Xcode Cloud integrates seamlessly with SCM and Xcode IDE, offering CI/CD capabilities within the Xcode app, reducing the need to switch between different platforms.
- Easy to Set Up: Xcode Cloud provides a straightforward onboarding process, making it simple to connect your repository and get started with CI/CD.
- Automatic Code Signing: Xcode Cloud requires automatic code signing, but it’s not mandatory for building, testing, and analyzing code, easing the transition for developers using manual code signing.
- User-Friendly Interface: Xcode Cloud has a user-friendly interface with intuitive workflows, making it accessible for developers with limited CI/CD knowledge.
- Parallel Execution: Xcode Cloud executes tests and actions in parallel, providing faster and more efficient testing and workflow execution. However, it only supports parallel execution for actions and not a combination of sequential and parallel execution.
Xcode Cloud offers limited customization options, which might be a drawback for users accustomed to more extensive customization in other CI/CD platforms.
Pricing
Currently, Xcode Cloud offers 25 compute hours per month free of charge to all accounts with App Store membership until December 2023. After this period, a subscription plan will be available at the rate of US$14.99 per month for those interested in continuing to use the service.
Final thought
Xcode Cloud presents a promising solution for iOS developers seeking streamlined CI/CD processes. Its integration within the Xcode app and straightforward setup are commendable features. Explore Xcode Cloud further, and share your experiences using Xcode Cloud in the comments below
As we continue our mission to make high-quality healthcare accessible to a billion people at Medibuddy, we are always excited to embrace cutting-edge tools like Xcode Cloud to enhance our development workflow to build high quality products.