Tirupati Balan

Tirupati Balan

Upload Closed-Source Framework to CocoaPods

Swift

Publishing a closed-source framework to CocoaPods can be challenging. This guide aims to alleviate your pain points by sharing how I successfully uploaded a precompiled .framework file to CocoaPods.

Prerequisites

Make sure you go through the following resources:

Common Issues

I encountered several issues related to the .podspec file, such as:

  • Unexpected version directory
  • Wrong .source file error
  • Invalid .public_header_files
  • Non-validating .homepage URL
  • Specification does not validate

Step-by-Step Guide

Create Universal Framework

First, create a universal iOS framework. Refer to this article for a step-by-step guide.

Create .podspec File

Create a MyFramework.podspec file in your project directory and add the following content:

Pod::Spec.new do |s|
    s.name                    = 'MyFramework'
    s.version                 = '1.0.0'
    s.summary                 = 'MyFramework summary.'
    s.homepage                = 'https://www.example.com/'
    s.author                  = { 'MyFramework' => 'hello@example.com' }
    s.license                 = { :type => 'Apache-2.0', :file => 'LICENSE' }
    s.platform                = :ios
    s.source                  = { :http => 'https://example.com/download/ios_sdk/1.0.1/MyFramework.zip' }
    s.ios.deployment_target   = '9.0'
    s.ios.vendored_frameworks = 'MyFramework.framework'
end

Validate .podspec

Run the following command to validate:

pod spec lint --allow-warnings

Archive and Upload Framework

Create a .zip file containing your framework and LICENSE:

zip -r MyFramework.zip LICENSE MyFramework.framework

Upload the .zip file to your server. In my case, I used Firebase Private Hosting.

Register With CocoaPods Trunk

Register an account for authentication:

pod trunk register you@youremail.com 'Your organization name'

Push to CocoaPods

Finally, push your .podspec file:

pod trunk push MyFramework.podspec

Testing

Add the following line to your .podfile and run pod install:

pod 'MyFramework', '1.0.0'

That’s it! You’ve successfully uploaded your closed-source framework to CocoaPods.

Happy Coding!