| name | cocoapods-publishing-workflow |
| description | Use when publishing CocoaPods libraries to CocoaPods Trunk. Covers pod trunk registration, podspec validation, version management, and publishing best practices for successful library distribution. |
| allowed-tools | ["Read","Write","Edit","Bash","Grep","Glob"] |
CocoaPods - Publishing Workflow
Complete guide to publishing your CocoaPods library to the official CocoaPods Trunk.
Publishing Overview
Process Steps
- Register with CocoaPods Trunk (one-time)
- Prepare your podspec
- Validate locally (
pod lib lint)
- Validate for publishing (
pod spec lint)
- Tag version in git
- Push to Trunk (
pod trunk push)
Trunk Registration
Register Email (One-Time)
pod trunk register email@example.com 'Your Name'
Check Registration
pod trunk me
Podspec Preparation
Version Management
Pod::Spec.new do |spec|
spec.version = '1.0.0'
spec.source = {
:git => 'https://github.com/username/MyLibrary.git',
:tag => spec.version.to_s
}
end
Required Metadata
Pod::Spec.new do |spec|
spec.name = 'MyLibrary'
spec.version = '1.0.0'
spec.summary = 'Brief one-line description'
spec.description = 'Longer description with more details about what the library does'
spec.homepage = 'https://github.com/username/MyLibrary'
spec.source = { :git => 'https://github.com/username/MyLibrary.git', :tag => spec.version.to_s }
spec.license = { :type => 'MIT', :file => 'LICENSE' }
spec.authors = { 'Your Name' => 'email@example.com' }
spec.ios.deployment_target = '13.0'
end
Local Validation
Quick Validation
pod lib lint --quick
Full Validation
pod lib lint
pod lib lint --swift-version=5.9
pod lib lint --verbose
Handle Warnings
pod lib lint --allow-warnings
pod lib lint
Publishing Validation
Spec Lint
pod spec lint
Pre-Publishing Checklist
Git Tagging
Create Tag
git add .
git commit -m "Release version 1.0.0"
git tag 1.0.0
git push origin main --tags
Tag Format
git tag 1.0.0
git tag 1.0.0-beta.1
git tag 1.0.0-rc.1
Publishing to Trunk
Push Pod
pod trunk push MyLibrary.podspec
pod trunk push MyLibrary.podspec --swift-version=5.9
pod trunk push MyLibrary.podspec --allow-warnings
Successful Publish Output
Validating podspec
-> MyLibrary (1.0.0)
Updating spec repo `trunk`
-> MyLibrary (1.0.0)
--------------------------------------------------------------------------------
🎉 Congrats
🚀 MyLibrary (1.0.0) successfully published
📅 January 1st, 2024
🌎 https://cocoapods.org/pods/MyLibrary
👍 Tell your friends!
--------------------------------------------------------------------------------
Version Updates
Patch Release (Bug Fixes)
spec.version = '1.0.1'
git add .
git commit -m "Fix: Resolve crash in background mode"
git tag 1.0.1
git push origin main --tags
pod trunk push MyLibrary.podspec
Minor Release (New Features)
spec.version = '1.1.0'
git add .
git commit -m "Add: Support for custom themes"
git tag 1.1.0
git push origin main --tags
pod trunk push MyLibrary.podspec
Major Release (Breaking Changes)
spec.version = '2.0.0'
git add .
git commit -m "BREAKING: Refactor API for modern Swift"
git tag 2.0.0
git push origin main --tags
pod trunk push MyLibrary.podspec
Managing Multiple Pods
List Your Pods
pod trunk me
Add Contributors
pod trunk add-owner MyLibrary email@example.com
pod trunk remove-owner MyLibrary email@example.com
Deprecation
Deprecate Old Version
pod trunk deprecate MyLibrary --version=1.0.0
pod trunk deprecate MyLibrary
Deprecation with Replacement
spec.deprecated = true
spec.deprecated_in_favor_of = 'NewAwesomeLibrary'
Common Issues
Issue: Tag Doesn't Match
ERROR | [MyLibrary] The repo has no tag for version 1.0.0
Solution:
git tag 1.0.0
git push origin --tags
Issue: Validation Fails
ERROR | [MyLibrary] xcodebuild: Returned an unsuccessful exit code
Solution:
pod lib lint --verbose
Issue: Missing License
ERROR | [MyLibrary] Missing required attribute `license`
Solution:
spec.license = { :type => 'MIT', :file => 'LICENSE' }
Best Practices
Pre-Publish Testing
cd Example
pod install
pod 'MyLibrary', :path => '../MyLibrary'
pod lib lint
pod spec lint
Version Numbering
spec.version = '1.0.0'
spec.version = '1.0.1'
spec.version = '1.1.0'
spec.version = '2.0.0'
CHANGELOG
# Changelog
## [1.1.0] - 2024-01-15
### Added
- Custom theme support
- Dark mode compatibility
### Fixed
- Memory leak in background processing
## [1.0.0] - 2024-01-01
- Initial release
README
# MyLibrary
Brief description of library.
## Installation
\`\`\`ruby
pod 'MyLibrary', '~> 1.0'
\`\`\`
## Usage
\`\`\`swift
import MyLibrary
let library = MyLibrary()
library.doSomething()
\`\`\`
## Requirements
- iOS 13.0+
- Swift 5.7+
## License
MyLibrary is available under the MIT license.
Anti-Patterns
Don't
❌ Publish without testing
pod trunk push --skip-tests
❌ Use --allow-warnings for initial release
pod trunk push --allow-warnings
❌ Forget to tag git
pod trunk push
❌ Skip version bump
spec.version = '1.0.0'
Do
✅ Test thoroughly before publishing
pod lib lint
pod spec lint
✅ Fix all warnings
pod lib lint
✅ Always tag git
git tag 1.0.0
git push --tags
✅ Bump version for every release
spec.version = '1.0.1'
Complete Publishing Example
vim MyLibrary.podspec
vim CHANGELOG.md
git add .
git commit -m "Release 1.0.0: Initial public release"
git tag 1.0.0
git push origin main --tags
pod lib lint
pod spec lint
pod trunk push MyLibrary.podspec
pod search MyLibrary
Related Skills
- cocoapods-podspec-fundamentals
- cocoapods-subspecs-organization
- cocoapods-test-specs
- cocoapods-privacy-manifests