Publish Library SDK Swift from private github to CocoaPods

50 Views Asked by At

I have an iOS SDK library published on a private GitHub repository. I tried to publish it to CocoaPods so that other applications can use it. However, after creating the podspec file, tagging the application, running pod lib lint, and finally receiving a successful validation with the command pod lib lint, I encountered an error with the command pod trunk push ****lient.podspec.

NOTE | URL: The URL (https://github.com/*****-ios-natif) is not reachable. Error: Source code for your Pod was not accessible to CocoaPods Trunk. Is it a private repo or behind a username/password on http?

The library is written in Swift and generated with Swift Package Manager. I've noticed other applications with private GitHub repositories successfully publishing their SDKs on CocoaPods. For example, in this application: https://github.com/Kameleoon/client-swift, no source code is visible on GitHub, yet we can simply include the library like so: pod 'kameleoonClient'.

Do I need to generate an archive and publish it to CocoaPods? Is there a tutorial explaining this process?

Any help will be appreciated. Thank you.

1

There are 1 best solutions below

0
tamtoum1987 On

I post my solution here maybe it will help other people I changed a lot of things to get it worked my library was on swift package manager i create a new project library and paste all code inside after that i created to xcarchive one for iphone and other for simulator and i combine them to create xcframework

Create xcarchive for simulator

 xcodebuild archive \
-scheme BClient \
-archivePath "archives/BClient-iOS-simulator.xcarchive" \
-destination "generic/platform=iOS Simulator" \
-sdk iphonesimulator \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES

Create xcarchive for device

 xcodebuild archive \
-scheme BClient \
-archivePath "archives/BClient-iOS.xcarchive" \
-destination "generic/platform=iOS" \
-sdk iphoneos \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES

I Combine them to get xcframework framework

 xcodebuild -create-xcframework \
-framework "archives/BClient-iOS.xcarchive/Products/Library/Frameworks/BClient.framework" \
-framework "archives/BClient-iOS-simulator.xcarchive/Products/Library/Frameworks/BClient.framework" \
-output "BClient.xcframework"

After that i zip the BClient.xcframework to get BClient.zip i publish it to public repo to get url like that : https://github.com/******example/raw/main/BClient.zip

For the BClient.podspec :

 Pod::Spec.new do |spec|

 spec.name = "BClient"

 spec.version = "0.0.6"

 spec.summary = "B Client iOS"

 spec.description = "B Client for iOS"

 spec.homepage = "example.com"

 spec.license = { :type => "MIT", :file => "LICENSE" }

 spec.author = { "B O" => "[email protected]" }

 spec.platform = :ios, "15.2"

 spec.swift_version = '5.9'

 spec.source = { :http => 'https://github.com/******example/raw/main/BClient.zip' }
  spec.ios.vendored_frameworks = 'BClient.xcframework'

 end

After this configuration the command passed successfuly :

pod trunk push BClient.podspec --verbose --allow-warnings --use-libraries