May 4, 2023

From Manual Effort to Automated Workflow: The Journey of iOS CI/CD at Nuclei

#### Challenges of Generating Universal iOS Frameworks for Both iPhone and SimulatorIn 2020, we were faced with a recurring challenge of generating frameworks for iOS that could work on both the iPhone and the simulator. The process was tedious and time-consuming, taking up to 4 hours of manual effort every time we needed to create a universal framework for a bank's requirement. We had to generate frameworks for both the simulator and iPhoneOS, use the lipo command line utility to merge the executables into one fat binary and update the header file to make the headers available for both the simulator and iPhoneOS. Moreover, these frameworks were not Xcode agnostic, meaning they needed to be created for every Xcode version that banks were using. This made setting up continuous integration and continuous deployment (CI/CD) for iOS extremely necessary.#### Automating iOS Framework CreationIn 2021, we decided to tackle the challenge by developing an automation script to remove the manual effort required [Read More](https://gonuclei.com/resources/automate-framework-generation-for-a-modular-ios-project/). The script automated everything that one had to do manually, reducing the human effort of 4 hours to just 30 minutes, without any human involvement. However, Xcode 13 was released in 2021, which deprecated the fat binaries that we used to create with universal support. This made it necessary to adopt the use of XCFrameworks, a new way of packaging binaries that was introduced at WWDC 2019. Although Apple had slowly started deprecating the use of fat binaries starting with Xcode 12, they had added a check for all the apps uploaded to the app store to ensure they did not contain any code related to the simulator. In the upload phase, we had to add a script to remove the simulator binary from the fat binary. With Xcode 13, even the usage of fat binaries in a project was completely deprecated. The only way to have universal support was to create XCFrameworks.![automation script excerpt](//images.ctfassets.net/urdv1oztwvyo/1QmBLylGMF9AK4Pu40ID9G/acd6a562eaced77ff9bbbffcfdf718f3/Screenshot_2023-05-04_at_2.37.40_AM.png)#### Overcoming XCFramework Limitations for Legacy iOS VersionsWe tried creating XCFrameworks for our codebase, but we ran into a blocker. We could not generate XCFrameworks for minimum iOS 9 support since XCFramework support was robustly available for iOS 13+. We connected with developers at Apple during WWDC 2022 and explained our case. Although we did not get any significant input to help our case, we decided to debug the issue by going error by error to figure out what was restricting us from creating XCFrameworks. This helped us identify many critical issues, such as clashes with class names present in different projects in the workspace and clashes in class names and project names. The biggest issue was subclassing a class imported from another project. We then refactored the entire codebase for every project that had such classes. We also enabled ABI stability for our projects, and we were successful in creating XCFrameworks for our SDK with minimum iOS 9 support.![minions-excited](//images.ctfassets.net/urdv1oztwvyo/2lfS9u4lAKtJzLBdFYMhhV/b725283754e463bbd204eb6c9bf94d43/minions-excited.gif)#### Streamlining iOS CI/CD Pipeline with Xcode-Agnostic XCFrameworksWith the XCFrameworks generated and ABI stability in place, our frameworks became Xcode agnostic. Once compiled on one Xcode, they would be compatible with any future Xcode. This would also lower the requirements for banks to come to us for a release whenever they had to upgrade their Xcode. However, we still needed to run the script manually. We also had Flutter integrated into our codebase, which made our iOS codebase tightly coupled with the Flutter codebase. This meant that to build the iOS codebase, we first had to build the Flutter project. This limited us from setting up a CI/CD pipeline. We then refactored the codebase to make it independent and buildable without anything related to Flutter. We also made CoreAdapter, one of our projects in the workspace that helps in redirecting various flows in our SDK, independent of any other project. This enabled us to create a GitHub workflow for setting up our CI/CD pipeline. Finally, in April 2023, we achieved our iOS CI/CD. From four hours of manual effort for every bank to just three clicks, triggering the CI/CD pipeline, specifying the GitHub branch, release tag and the Xcode version they want to compile. The pipeline generates XCFrameworks for the SDK and uploads it to our Azure blob, ready to share.![john cena candy](//images.ctfassets.net/urdv1oztwvyo/1VkbRydLtzjxTDIyhx2ZjA/6321f373df1da322fb0d805e485bc624/john_cena_candy.gif)#### ConclusionIn conclusion, our journey to achieving a seamless CI/CD pipeline for our iOS codebase was challenging, but we persisted in our efforts to find a solution. The process involved identifying errors, debugging, refactoring, and creating an independent codebase that enabled us to create a Github workflow for our CI/CD pipeline. While it was challenging, the benefits of having a streamlined process, saving time and effort, and increasing efficiency made it all worthwhile. We learned that determination and perseverance can lead to success, and that a willingness to learn and adapt to new technologies and processes is essential in the ever-changing world of software development.![excited kid](//images.ctfassets.net/urdv1oztwvyo/11FrfIj7WUUg6YJZCwKyRk/be8ffc0ad604d6d3934a26009ded79ff/excited-hockey.gif)

RELATED ARTICLES

No items found.
Written by
Full Name
Published on
22 January 2021

Get a free consultation on Segmentation strategy and
Ecosystem practices

Drop us a line.
Thank you! We'll be in touch soon.
Oops! Something went wrong while submitting the form.
Schedule a demo
Let’s Connect
We’ve received your request. We’ll be in touch soon.
Oops! Something went wrong while submitting the form.