Fix Code Sign Error When Building with CocoaPods
November 30, 2015Code Sign Error Building CocoaPods Framework Targets
I would like to share a recent troubleshooting experience with the dependency manager, CocoaPods, and creating an AdHoc build for a project that contains Swift language frameworks. Hopefully the solution we found will help you if you ever run into this type of error.
Code Sign error: No code signing identities found: No valid signing identities (i.e. certificate and private key pair) matching the team ID "(null)" were found.
CodeSign error: code signing is required for product type 'Framework' in SDK 'iOS 8.4'
Adding a Swift Framework to Objective-C Project
Recently we added a new Swift language framework, PromiseKit, to an existing Objective-C project. We have been using CocoaPods, since day one with the project, but this was the first Swift code being integrated into the Xcode Workspace. Newer versions of CocoaPods (since version 0.36 ) have added support for Dynamic Frameworks via the use_frameworks!
configuration option. This is the preferred way to integrate a Swift language 3rd party library into a Project. Initially, all went well - the project built and ran locally on the iOS Simulator with no trouble.
Xcode Build Error on Continuous Integration Server
Our first sign of trouble was when the new code was committed and pushed and a build was run. Every pre-existing 3rd party library Pod dependency that was not one of the new Frameworks (all Objective-C static libraries) failed to build with a Code Sign Error
. At first we tried the typical code signing troubleshooting: checking the signing certificate and updating the provisioning profile, but these did not fix the error or change the messages in the build log.
Swift Framework Libraries Require Code Signing but NOT Objective-C
Digging into the problem a bit further, we discovered that the new Swift framework was building properly and just the pre-existing Objective-C Pods (formerly static libraries) were failing with the Code Sign Error. Time to hit the Google!
After much research on CocoaPods GitHub Issues page and looking over some similar problems with the latest iOS/OS X dependency manager Carthage, I realized that the Objective-C libraries should NOT be getting code signed. Swift frameworks require code signing because they embed the Swift standard library and runtime, enabling use of older Swift code in a newer project. Apple requires Code Signing to verify the runtime code that’s being copied into an iOS app (helps enforce the iOS security sandbox). The old school Objective-C static libraries do not need this and actually do not even support it, hence the weird build error about “No signing identities matching team ID (null).”
The Solution - Disable Code Signing
One solution would be to manually edit each Pod library target and disable Code Signing. Not a great option since those build settings will be re-created each time pod install
is re-run. After perusing the CocoaPods documentation, we found the solution. A “Post Install” script that modifies the Pod targets before they are saved to disk (and integrated into the Xcode Workspace.) We manually disable Code Signing via the appropriate Build Settings for each of the Pod dependencies. Add this to the bottom of your Podfile
and your Code Signing error will be resolved!
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['EXPANDED_CODE_SIGN_IDENTITY'] = ""
config.build_settings['CODE_SIGNING_REQUIRED'] = "NO"
config.build_settings['CODE_SIGNING_ALLOWED'] = "NO"
end
end
end
Looking for more like this?
Sign up for our monthly newsletter to receive helpful articles, case studies, and stories from our team.
Web app vs. mobile app: How to decide which is best for your business
March 26, 2024When considering whether to develop a web app or a mobile app for your business, there’s honestly no definitive answer. But this article will help you make an informed decision that aligns with your business goals and sets you up for success.
Read moreMichiganLabs’ approach to product design: A strategic, problem-solving process
February 12, 2024Product design, or UX design, is a strategic problem-solving process that leads to a valuable digital product. Learn what to expect when working with product designers for your custom software.
Read moreTech is for everyone
June 20, 2024Have you ever felt like the tech world was an Ivy league school, where only the most elite students gain acceptance? Discover paths into the industry you may not have considered.
Read more