Publish closed source framework using CocoaPods

Well, I’m writing this article based on my own recent experience while I have to upload my closed source compiled framework on CocoaPods means there is no public repo URL except one .framework file along with a license.

Below articles helped me a lot to finish uploading my closed source framework on CocoaPods.

After going through all above articles I have still faced few issues like below

  • Unexpected version directory
  • Wrong .source file error
  • Invalid .public_header_files
  • Not validating .homepage url
  • Specification does not validate

and so on but one thing I have realized all problems are related to .podspec file only which I’m facing whenever I’m validating spec file through pod lint command i.e pod spec lint

Let’s discuss step by step how I have created perfect working podspec file and uploaded my .framework successfully

  • If possible go through this article where I have explained how one could create a universal framework.

  • Once you have done with framework create process (as per point 1) you have to create MyFramework.podspec file in your project directory.

Paste the below content inside it: do |s|                    = 'MyFramework'
    s.version                 = '1.0.0'
    s.summary                 = 'MyFramework summary.'
    s.homepage                = ''                  = { 'MyFramework' => '' }
    s.license                 = { :type => 'Apache-2.0', :file => 'LICENSE' }

    s.platform                = :ios
    s.source                  = { :http => '' }

    s.ios.deployment_target   = '9.0'
    s.ios.vendored_frameworks = 'MyFramework.framework'

If above spec file works out for you and if it passed pod spec lint command on your terminal then think 90% of your upload headache passed out.

During .podspec validation I have faced validation of .homepage parameter Error reference so anyhow instead solving it I used --allow-warnings in pod lint validation command as below

pod spec lint --allow-warnings
  • Now create a zip archive of your MyFramework.framework and LICENSE through zip command as below
zip -r LICENSE MyFramework.framework 

For licence file content follow this special thanks to eladnava

  • Upload your file on your server and copy the path of uploaded zip file like below which will in use for s.source parameter

I have used Firebase Private Hosting for .zip file upload and Dillinger for my installation documentation especially for a client where you can easily create styled HTML, pdf file using simple markdown language.

  • For publishing your .podspec file you have to authenticate and use CocoaPods API service i.e CocoaPods Trunk

Follow below command to register yourself Reference

pod trunk register ‘Your organization name' 

You can list your sessions by running pod trunk me

  • Now finally follow below last command to push your .podspec on CocoaPods server Reference
pod trunk push MyFramework.podspec

After following all above step successfully I’m sure now you are ready to test your pod installation through any test project, Just add below line in your .podfile and run pod install command

pod 'MyFramework', '1.0.0'  

That’s it!!!!!

You are done!!!