To distribute a closed source pod you first need to modify your private repository so that you can produce a .xcframework
file.
Distribute through a URL
You have to zip the .xcframework
file and make it available through a URL to your audience. (whether this is public or private)
Then you can create a .podspec
file like this:
Pod::Spec.new do |s|
s.name = '<POD_NAME>'
s.version = '<VERSION>'
s.summary = '<SUMMARY>'
s.description = <<-DESC
<DESCRIPTION>
DESC
s.homepage = '<A_URL_TO_A_WEBPAGE>'
s.author = { '<AUTHOR_NAME>' => '<AUTHOR_EMAIL>' }
s.source = { :http => '<URL_TO_YOUR_ZIP_FILE>' }
...
s.vendored_frameworks = '<PATH_OF_XCFRAMEWORK_FILE_IN_THE_ZIP>.xcframework'
end
After that there are 2 methods to distribute it:
Public: If you want to distribute your pod through cocoapods specs repo, you can push your .podspec
file to the cocoapods
trunk following this guide:
pod trunk push <PATH_TO_YOUR_PODSPEC_FILE>.podspec
The installation from the users will be like any other pod:
use_frameworks!
target 'TargetName' do
pod '<POD_NAME>'
end
Private: For private distribution follow this quide, create a
private specs repo and use the following command to push your podspec:
pod repo push <REPO_NAME> <PATH_TO_YOUR_PODSPEC_FILE>.podspec
The installation from the users will be like this:
use_frameworks!
target 'TargetName' do
pod '<POD_NAME>', :source => '<PRIVATE_SPECS_REPO_URL>'
end
Public: If you don't mind about cocoapods specs repo (or if you
want to test your .podspec
file) you can make your .podspec
file
publicly available through a URL and then instruct the users to use
the podspec way in their Podfile
to install your pod:
use_frameworks!
target 'TargetName' do
pod '<POD_NAME>', podspec: '<URL_TO_YOUR_PODSPEC_FILE>.podspec'
end
Private: The same method also applies to the private distribution,
as long as your users are the only ones that known or have access to
the podspec URL.
Distribute through a Github repo
Although I don't recommend committing a binary file (which is the .xcframework
) into a git repo, you can pretty much do the same using a git repo but without the need to zip your .xcframework
file.
Create a git repository and add the .xcframework
file along with a .podspec
file like this:
Pod::Spec.new do |s|
s.name = '<POD_NAME>'
s.version = '<VERSION>'
s.summary = '<SUMMARY>'
s.description = <<-DESC
<DESCRIPTION>
DESC
s.homepage = '<A_URL_TO_A_WEBPAGE>'
s.author = { '<AUTHOR_NAME>' => '<AUTHOR_EMAIL>' }
s.source = { :git => '<URL_TO_YOUR_GIT_REPO>.git', :tag => s.version.to_s }
...
s.vendored_frameworks = '<PATH_OF_XCFRAMEWORK_FILE_IN_THE_REPO>.xcframework'
end
Public: Then you can distribute your pod through cocoapods specs repo by pushing your .podspec
file to the cocoapods trunk like this:
pod trunk push <PATH_TO_YOUR_PODSPEC_FILE>.podspec
Private: For private distribution, you can create a private specs repo and use the following command to push your podspec:
pod repo push <REPO_NAME> <PATH_TO_YOUR_PODSPEC_FILE>.podspec