Chee Yi

CocoaPods Deployment Target Mismatch

As an iOS developer, it’s inevitable that we’ll come across a situation where we’re forced to use CocoaPods—be it trying to integrate the Google Maps SDK, Firebase and the like.

Just yesterday, a client sent me an email saying he wasn’t able to generate a release archive of an iOS app I had worked on. The error he was seeing was “No such module ‘XYZ’”, where XYZ is a pod we were using for that project.

I recloned the repo and found out that the “no such module” error was caused by another error:

Target ‘Pods-ProjectName’ of project ‘Pods’ was rejected as an implicit dependency for ‘Pods_ProjectName.framework” because its architectures ‘arm64’ didn’t contain all required architectures ‘armv7 arm64’

My first thought was “oh shit”. After digging around for a bit, I learned that all devices currently capable of running iOS 11 (iPhone 5s and up) are 64-bit devices, so it makes sense that arm64 is there, but what about armv7? Turns out the project’s iOS deployment target was set to 10.3, but our Podfile had this in it:

platform :ios, '11.0'

This was automatically set by CocoaPods if you run pod install without uncommenting the original placeholder and specifying a version yourself. The problem then is that the Pods project generated by CocoaPods would have its iOS deployment target set to 11.0, and it’ll only be built for arm64.

Why didn’t this show up during debug?

This was an oversight on my part. During the development phase, we developers rarely build our apps in Release mode, and so things work great if you build your app on a test device or simulator that is running iOS 11, since Xcode—to save time—only builds for the architecture of the target device you’re running on. This doesn’t apply for Release builds, since you’d want your Release build to be runnable on all devices you claim to support.

Build Active Architectures Only

In my case, the Release build will need to support armv7 and arm64, but since the Pods project only supports arm64 this became an issue.

Conclusion

It’s crucial for your Podfile (and in extension, your generated Pods project) and your main Xcode project to have identical iOS deployment targets. If you run into the same issue I did, change the Podfile’s platform :ios part to your desired deployment target, and run pod update. CocoaPods will regenerate the Pods project and everything would be 💯 again. 🎉

This project is maintained by cheeyi