A short and compact guide to create a basic redistributable framework with CocoaPods support. This example is intended to work on iOS, but the same principles can be applied to watchOS, tvOS and macOS.

Create a new Xcode project and select Cocoa Touch Framework.

Framework

For redistributable libraries Objective-C is still the language-to-go. But you can also choose to write them in Swift if the host apps are willing to include the swift runtime.

Framework

Framework

Set the right version, 0.1.0 is a good start point. Check the Allow app extension API only if you plan to use your framework from inside app extensions.

Framework

Create at least a new class.

Framework

Populate the header file.

Framework

Implement the methods.

Framework

Import your header files in the Umbrella Awesome.h header file so they will be accessible.

Framework

Open Terminal and move into the project folder, for example

cd ~/Documents/Projects/Awesome

Framework

Install CocoaPods gem if you don’t have it already.

[sudo] gem install cocoapods

Framework

pod spec create Awesome

Framework

Framework

Edit Awesome.podspec

Framework

Framework

Add a license file

Framework

Create a remote repository and add it the local copy

git remote add origin git@github.com/macteo/Awesome.git

Commit and push

git push origin master

Framework

git tag v0.1.0
git push --tags

Framework

pod spec lint Awesome.podspec

Framework

Create a sample project inside the main folder.

Framework

Framework

Framework

cd AwesomeExample
pod init

Framework

Edit podfile to include the previously defined podspec. We use relative path for the example project.

pod 'Awesome', :path => '../'

Framework

pod install

Framework

Framework

Framework

Build so the dependencies are prepared

import Awesome
AwesomeLogger().log("Hello World")

Framework

Edit Awesome.podspec and bump version number.

Framework

Add sample project files, commit, push and tag.

git add .
git commit -m "Added sample project"
git push origin master
git tag v0.1.1
git push --tags

Framework

Framework