Introduction
SwiftGenKit is a Swift code generator that helps you automate the process of generating localizable strings, asset catalogs, storyboards, and more from your resources folder. It aims to replace the tedious process of manually working with these resources, making your development workflow more efficient and less prone to errors.
Key Features
- Automate the generation of Swift code for your resources
- Easily access your assets, storyboards, Segues, and localized strings
- Reduce the risk of human error when manually managing resources
- Compatible with various Xcode project configurations
Documentation
To get started with SwiftGenKit, follow these steps:
- Install SwiftGenKit via CocoaPods or Swift Package Manager
- Configure your project’s build phases to generate code using SwiftGenKit
- Access your resources programmatically using the generated Swift code
Installation
To install SwiftGenKit, follow the instructions below based on your preferred dependency manager:
CocoaPods
Add the following line to your Podfile
:
pod 'SwiftGenKit'
Then, run the command:
$ pod install
Swift Package Manager
Add SwiftGenKit as a dependency in your Package.swift
file:
dependencies: [
.package(url: "https://github.com/SwiftGen/SwiftGenKit.git", from: "X.Y.Z")
]
Replace X.Y.Z
with the desired version of SwiftGenKit. Then run:
$ swift build
Usage
Once SwiftGenKit is installed in your project, follow the steps below to generate code for your resources:
- Create a
swiftgen.yml
file in your project’s root directory (if one does not already exist) - Edit the
swiftgen.yml
file to configure the resources you want SwiftGenKit to process - Run one of the SwiftGenKit’s generators to create Swift code:
- To generate Swift code for assets:
$ swiftgen config run --config swiftgen.yml --templatePath MyProject/SwiftGen/templates
- To generate Swift code for storyboards:
$ swiftgen storyboards run --config swiftgen.yml --templatePath MyProject/SwiftGen/templates
- To generate Swift code for localizable strings:
$ swiftgen strings run --config swiftgen.yml --templatePath MyProject/SwiftGen/templates
Refer to the official SwiftGenKit GitHub repository for detailed documentation and examples on configuring and using the different generators.
Support
If you encounter any issues or have any questions regarding SwiftGenKit, you can seek support through the following channels:
- Submit an issue on the GitHub repository
- Ask a question on the Stack Overflow community using the “swiftgenkit” tag
Conclusion
SwiftGenKit is a powerful code generator that simplifies working with resources in your Swift projects. By automating the generation of Swift code, you can save time, reduce errors, and improve your development workflow. Start using SwiftGenKit today and experience the benefits it brings to your project.