iOS base is a boilerplate project created by Rootstrap for new projects using Swift 5. The main objective is helping any new projects jump start into feature development by providing a handful of functionalities.
This template comes with:
- Extensible and decoupled integration with an API Client to easily communicate with REST services.
- A few examples to comprehend the app architecture(e.g. Account creation, Login, Logout)
- Useful classes to manage User and Session data.
- Secure way to store and manage secret keys of your third party integrations.
- Centralized and intuitive navigation system that simplifies the transitioning between view controllers and streamlines the navigation flow within the app.
- Convenient helpers and extensions to boost your productivity and improve the general coding experience.
- Clone the repo.
- Run
./init
from the recently created folder. - Initialize a new git repo and add your remote URL.
- Done!
To manage user and session persistence after the original sign in/up we store that information in the native UserDefaults. The parameters that we save are due to the usage of Devise Token Auth for authentication on the server side. Suffice to say that this can be modified to be on par with the server authentication of your choice.
- Alamofire for easy and elegant connection with an API.
- IQKeyboardManagerSwift for auto-scrolling to current input in long views. Note: this pod is not fully working on iOS 11. Here is the issue we encountered and the meantime solution.
- Firebase for tools to help you build, grow and monetize your app.
We have developed other libraries that can be helpful and you could integrate with the dependency manager of your choice.
- PagedLists: Custom
UITableView
andUICollectionView
classes to easily handle pagination. - RSFontSizes: allows you to manage different font sizes for every device screen size in a flexible manner.
- RSFormView: a library that helps you to build fully customizable forms for data entry in a few minutes.
- SwiftGradients: Useful extensions for
UIViews
andCALayer
classes to add beautiful color gradients.
- KIF for UI testing.
- KIF/IdentifierTests to have access to accesibility identifiers.
In order for the project to run, you have to follow these steps:
- Register your app with Firebase.
- Download Firebase configuration file
GoogleService-Info.plist
from your account. - Add the downloaded file to the /Resources folder.
- Done :)
See the Firebase documentation for more information.
In order to meet the required code quality standards, this project runs SwiftLint during the build phase and reports warnings/errors directly through XCode.
NOTE: It's needed to install SwiftLint into your local machine to report warnings/errors.
The current SwiftLint rule configuration is based on Rootstrap's Swift style guides and is synced with the CodeCliemate's configuration file.
NOTE: Make sure you have SwiftLint version 0.35.0 or greater installed to avoid known false-positives with some of the rules.
We strongly recommend that all private keys be added to a secrets.xcconfig
file that will remain locally and not be committed to your project repo.
- Add the new environment variable in your system:
- Optional: For local development, you can run
export KEY=value
in the terminal. Or you could start with a pre-filled secrets.dev.xcconfig file. - In your CI/CD platform, simply add the environment variable with its value to the respective settings section.
- Optional: For local development, you can run
- Add the new key name to the
keys.env
file. This could be any other file you use as source for the script mentioned in the next step. - Configure your CI/CD to run:
chmod u+x setup-env.sh
./setup-env.sh
- Add the key to the Info.plist of your app's target. Example: ThirdPartyKey = ${THIRD_PARTY_KEY}
- Add a new case to the
Secret.Key
enum. The rawValue must match the key in the Info.plist file - Use it wisely :)
Note: The setup-env
script will fill in the secrets.xcconfig
for Staging and Release builds.
Use secrets.dev.xcconfig
for the Debug
Build Configuration.
We recommend using AWS S3 for storing .xcconfig
files containing all secrets, as well as any other sensitive files. Alternatively when not using Fastlane Match (eg might not be compatible with some CICD systems), AWS S3 can also be used for storing Certificates, Private Keys and Profiles required for app signing. The CICD code examples (described below) make use of the AWS CLI to download any files relevant for our project from a predefined bucket and folder
Another alternative for managing sensitive files whithin the repo using Git-Secret can be found in the feature/git-secret branch
We are going to start using a tool called Bitrise to configure de CI/CD pipelines for mobiles apps.
--> For iOS apps you can find how to do it in this link: https://www.notion.so/rootstrap/iOS-CI-CD-01e00409a0144f5b85212bf889c627dd
We use Fastlane to automate code signing, building and release to TestFlight.
See details in Fastlane folder.
We recommend GitHub Actions for integrating Fastlane into a CI/CD pipeline. You can find two workflows in the GitHub workflows folder:
- ci.yml : triggered on any push and PR, runs unit tests, coverage report and static analysis with CodeClimate
- release.yml : triggered on push to specific branches, builds, signs and submits to TestFlight
Alternatively you can merge branch feature/jenkins for some equivalent CICD boilerplate with Jenkins.
On both alternatives we assume usage of Fastlane match for managing signing Certificates and Profiles, and AWS S3 for storing other files containing third-party keys
iOS-Base is available under the MIT license. See the LICENSE file for more info.
NOTE: Remove the free LICENSE file for private projects or replace it with the corresponding license.
iOS Base is maintained by Rootstrap with the help of our contributors.