Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save SheldonWangRJT/d19ac6533e809bbb2de54b9e83df5516 to your computer and use it in GitHub Desktop.
Save SheldonWangRJT/d19ac6533e809bbb2de54b9e83df5516 to your computer and use it in GitHub Desktop.
iOS Create a Carthage Supported Framework
iOS Create a Carthage Supported Framework
#iOSBySheldon
A little bit Background of Carthage:
- Carthage works like Cocoapods, but a little bit simpler.
* When creating a Cocoapods supported framework need a .podspec file to do some config, which is not required by Carthage.
* When using a Cocoapods supported framework, a workspace file will be automatically created, the umbrella header will be setup in a pod project inside workspace. It feels simple, but the whole process creates a lot files including a "giant" workspace.
* When using a Carthage supported framework, it will just download the framework, and its dependencies if any, to a folder. All we need to do is to drag and drop it to the binary linking section in the project build setting tab, for the first time. It sounds complicated but it makes the project clean.
- Carthage is written in Swift.
- Carthage internally uses `-xcodebuild` to build dependency.
- Carthage only supports dynamic frameworks, so iOS 8 and above is required.
Steps to Create the Framework: (Mainly follow the Official Github link)
1. Open Scheme settings and check share scheme in the bottom of the window.
* Note: `carthage build --no-skip-current` can be used to validate
2. Git tag with corresponding framework version [Ref 2, 3]
$ git tag 1.0
$ git push origin 1.0
3. Archive Prebuilt Frameworks into one zip file. If prebuilt frameworks are there already and available to be used, Carthage can use them instead of building from scratch. To offer prebuilt frameworks, the attachment should include .framework and be zipped. Following commands can be used to archive them. [Ref 4]
$ carthage build --no-skip-current
$ carthage archive YourFrameworkName
4. Carthage also can help mitigate by building dynamic frameworks as static frameworks instead. Static frameworks can be linked directly into your application or merged together into a larger dynamic framework with few simple modifications to your workflow, which reduces the pre-main app launch time. [Ref 5]
Few examples of using and creating Carthage Supported Frameworks is attached. [Ref 6, 7]
References Links:
1. Carthage Official Github:
https://github.com/Carthage/Carthage#build-static-frameworks-to-speed-up-your-apps-launch-times
2. Git Tag Official Doc:
https://git-scm.com/book/en/v2/Git-Basics-Tagging
3. Git Tag and Push Stack Overflow:
https://stackoverflow.com/questions/18216991/create-a-tag-in-github-repository
4. Example of Prebuilt Frameworks:
https://help.github.com/articles/about-releases/
5. Dynamic to Static:
https://github.com/Carthage/Carthage/blob/master/Documentation/StaticFrameworks.md
6. Use Carthage Supported Framework:
https://blog.mat.tc/how-to-make-a-carthage-compatible-framework/
7. Use Carthage Supported Framework:
https://www.raywenderlich.com/109330/carthage-tutorial-getting-started
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment