Andrea Mario Lufino
Andrea Mario Lufino

Reputation: 7921

How to distribute compiled framework using Cocoapods?

I'm building a framework using cocoapods. Now, I have it in a private repository with a private spec repo. I want to distribute this framework not as open source, but closed source. Basically, I want to distribute only the .framework file, already compiled. This way, I will avoid to expose my source code to externals. I don't know how to tell cocoapods to distribute the compiled file.

Upvotes: 2

Views: 2754

Answers (3)

MiMo
MiMo

Reputation: 4975

You can do this by pointing s.source of the podspec file to a zip file of your framework and its source. No need to expose your source in a public repository.

ex.

spec.source = { :http => 'https://bitbucket.org/publicRepo/yourframework.zip' }

Upvotes: 0

picciano
picciano

Reputation: 22701

After compiling your framework, you'll want to create a separate, public repository to use for distribution. That is where you will place your compiled framework, podspec, license, readme files, etc.

The podspec is a bit different for distributing frameworks rather than source code. See example:

Pod::Spec.new do |s|  
    s.name              = 'YourFrameworkName'
    s.version           = '1.7.0'
    s.summary           = 'The YourFrameworkName iOS SDK enables you to embed state-of-the-art real-time goodness into your iOS app.'
    s.homepage          = 'http://example.com'

    s.author            = { 'Name' => '[email protected]' }
    s.license           = { :type => 'Custom', :file => 'LICENSE' }

    s.platform          = :ios
    s.source            = { :http => 'https://github.com/example/YourFrameworkName/releases/download/1.7.0/YourFrameworkName.zip' }

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

    s.dependency 'SwiftyJSON', '3.1.4'
end

Once all that is set up, you can publish the pod spec the normal way.

Keep in mind, and this is an important consideration, that your compiled framework written in Swift will only be usable in projects that use the exact same Swift version. You will quickly run into this limitation as people start using your framework in different projects with various Swift versions.

Upvotes: 3

Jayachandra A
Jayachandra A

Reputation: 1342

  1. First, you create a sample project and install the pods(the library which you want to release as SDK.framework) for the project.
  2. Then see the below-attached image to get the .framework extension file to distribute to the public.

    enter image description here enter image description here

Upvotes: 0

Related Questions