Creating iOS framework with CocoaPods, Carthage, SPM support and Travis for running test and Fastlane for release automation — Part 4

Orçun Deniz
2 min readMay 3, 2020

Creating Swift framework is easy but adding CocoaPods, Carthage and Swift Package Manager support at the same time can sounds like scary in the first place. In addition to that adding Travis to run test for all commits and adding Fastlane to automate release processes for all dependency managers looks like a horror movie. But don’t be afraid. After you finished this series, you can easily create your own Swift frameworks that uses all these tools to make it perfect!

This series consist of 5 parts:

Part 1 — Create CocoaPod and release it.

Part 2 — Add Carthage support

Part 3 — Add Swift Package Manager support

Part 4 — Integrate Travis to build example project and run tests for framework

Part 5 — Integrate Fastlane to automate release processes by running just one line of command.

  1. Setup Travis with GitHub

Go to Travis-ci.com and Sign up with GitHub.

Accept the Authorization of Travis CI. You’ll be redirected to GitHub.

Click on your profile picture in the top right of your Travis Dashboard, click Settings and then click Manage repositories on GitHub.

Select the repositories you want to use with Travis CI on GitHub under Repository Access.

Click Approve and Install button.

2. Press cmd + shift + dot to see hidden files. Then open .travis.yml file under ODCustomFramework and change default lines with following lines to run all tests automatically and build the example project for each commit.

After each commit, Travis VM does followings:

Installs CocoaPods via gem

Locates to Example

Runs pod ‘ODCustomFramework’ to add it to ODCustomFramework-Example

Runs all tests

Builds ODCustomFramework-Example on XCode 11.3 and iPhone 11 Pro Max-13.3

3. Go to Travis and open ODCustomFramework repository, then click the build badge and select Markdown from second dropdown, and then copy the result and paste it into README.md.

4. Commit and push all changes to the GitHub.

git add .
git commit -m "Travis integration"
git push

Now that ODCustomFramework can be installed via Carthage and Swift Package Manager. Run test automatically for every commit with Travis. There is one more step to complete series:

Part 5 — Integrate Fastlane to automate release processes by running just one line of command.

--

--