Migrate iOS project dependencies to Bazel. Quick Help.

Photo by iMattSmarton Unsplash

Hello, I’ll refine this later.

First, if you still use xcodeproj, try to migrate using XcodeGen first. This isn’t necessary. But it will help you to understand the project.

Second, If you use CocoaPods, you can use PodsToBUILD. But there’s an issue where you have limited time with huge dependencies to be migrated. So, build with CocoaPods-Rome. Then you integrate with bazel apple rules apple_dynamic_framework.There will be an issue during iTunes verification though. It may be an incomplete bitcode. You may need to disable Bitcode.

Also, there will be some dependencies that will have incorrect layout according to Apple Bundle rules. This happens to me when integrating MidtransSDK. So I move this to PodsToBUILD. But there will be issue later. I’ll cover below.

Third, maybe some dependecies can’t be built with CocoaPods-Rome. You can try to build it with Carthage. This is the last resort for dynamic framework.

Integrating with PodsToBUILD is the recommended way as this will build into static library. But my experience with MidtransSDK yields error when running in the device.

This because MidtransSDK will reference its Nib from main bundle which should refer to its framework bundle rather than Application Bundle. The resources, will be available in different bundle by PodToBUILD generated configuration. So you will find a crash.

You can have a work around to this. But again, you have limited time and resources to do so, so I suggest, this precedence:

  1. CocoaPods
  2. PodToBUILD
  3. Carthage

Conclusion

Migrating to different build system is difficult and easy at the same time. You should try it yourself. There will be pros and cons for your use case. The learning curve is worth to the new knowledge.

Bazel itself is extensible build system and we have Tulsi to incorporate it to Xcode. The best part, we can mix Swift, Objective-C, Kotlin, Rust, C, C++ and languages of your choice to you iOS app with single build system. As bazel says, Fast and Correct, choose two.