iOS Base Template
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.
Features
This template comes with:
Main
- Complete API service class to easily communicate with REST services.
- Examples for account creation and Facebook integration.
- Useful classes to manage User and Session data.
- Secure way to store keys of your third party integrations.
- Generic implementation of navigation between view controllers.
- Handy helpers and extensions to make your coding experience faster and easier.
Extensions
This App Template also contains other branches with specific features that may be of use to you:
- feature/mvvm+rxswift in case you want to work with RxSwift and MVVM.
- feature/moya_integration manage routes and HTTP resources with Moya and Alamofire.
To use them simply download the branch and locally rebase against master/develop from your initial iOS base clone. Important: See steps below on how to install this features.
How to use
- Clone repo.
- Install desired extensions from their branches.
- 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.
Pods
Main
- 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.
- R.swift for strongly typed and autocompleted assets, segues and more.
- Firebase for tools to help you build, grow and monetize your app.
Utilities
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.
Testing
- KIF for UI testing.
- KIF/IdentifierTests to have access to accesibility identifiers.
Optional
- FBSDKCoreKit facebook pods dependency.
- FBSDKLoginKit for facebook login.
Mandatory configuration
Firebase
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.
Optional configuration
- In
info.plist
on the URL types array, findfbXXXXXXXXXXX
and replace it for the string "fb" + the ID of your app. i.e:fb435272928934
. - Change the
FacebookAppID
value for the same AppID that you replace above. - Change the
FacebookDisplayName
value for the name of the app on Facebook. - Done :)
Code Quality Standards
In order to meet the required code quality standards, this project runs SwiftLint during the build phase and reports warnings/errors directly through XCode. 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.
Security recommendations
Third Party Keys
We strongly recommend that all private keys be added to a .plist
file that will remain locally and not be committed to your project repo. An example file is already provided, these are the final steps to set it up:
- Rename the
ThirdPartyKeys.example.plist
file on your project so that it is calledThirdPartyKeys.plist
. To add a set of keys simply add a dictionary with the name you want the key to have and add the corresponding Debug, Staging and Release keys as items. - Remove the reference of
ThirdPartyKeys.plist
from XCode but do not delete the file. This way, you will keep the file locally(it is already in the .gitignore list) in the project directory. Note: Do NOT move the file from the current location, the script uses the $(PROJECT_DIR) directory. - Go to Product -> Scheme -> Edit scheme. Then select Pre-actions for the Build stage and make sure that the
Provided build setting
is set to your current target. Repeat this step for the Post-actions script. - Done :)
Secure storage
We recommend using AWS S3 for storing .plist
files containing Third Party keys, 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
CI/CD configuration with Bitrise (updated on Dec 12th 2021)
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
Automated Build and Deployment using Fastlane (DEPRECATED)
We use Fastlane to automate code signing, building and release to TestFlight.
See details in Fastlane folder.
Continuous Integration / Delivery (DEPRECATED)
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
License
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.
Credits
iOS Base is maintained by Rootstrap with the help of our contributors.