diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 9b187190..e252ce81 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,5 +1,5 @@ # @suho is the Team Lead and the others are team member -* @suho @blyscuit @edgarss @markgravity @minhnimble @nmint8m @phongvhd93 @vnntsu +* @suho @blyscuit @edgarss @markgravity @minhnimble @nmint8m @phongvhd93 @vnntsu @ducbm051291 @Shayokh144 # Engineering Leads CODEOWNERS @nimblehq/engineering-leads diff --git a/.github/wiki/Automating-Wiki.md b/.github/wiki/Automating-Wiki.md index 425d6c2f..1060486e 100644 --- a/.github/wiki/Automating-Wiki.md +++ b/.github/wiki/Automating-Wiki.md @@ -2,4 +2,4 @@ 1. Setup the Github Wiki by following this [official guide](https://docs.github.com/en/communities/documenting-your-project-with-wikis/adding-or-editing-wiki-pages#adding-wiki-pages). 2. Create [Personal Access Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token.) with `repo` scope enabled - a bot account is recommended to generate that token. -3. Create a [Repository Secret](https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository) with the above token, the default name for this secret is `NIMBLE_DEV_TOKEN`. \ No newline at end of file +3. Create a [Repository Secret](https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository) with the above token, the default name for this secret is `NIMBLE_DEV_TOKEN`. diff --git a/.github/wiki/Bitrise.md b/.github/wiki/Bitrise.md new file mode 100644 index 00000000..fda498a6 --- /dev/null +++ b/.github/wiki/Bitrise.md @@ -0,0 +1,66 @@ +# Bitrise +Use the Bitrise template to start a new project with Bitrise as the CI/CD tool. + +## Workflows and Steps + +Out of the box, the Bitrise Template has the following workflows and steps: + +| test | deploy_app_store | deploy_staging | deploy_release_firebase | +|---------------------------|---------------------------------------------------------|-----------------------------------------|-------------------------------------------| +| Git Clone Repository | Git Clone Repository | Git Clone Repository | Git Clone Repository | +| Bitrise.io Cache:Pull | Bitrise.io Cache:Pull | Bitrise.io Cache:Pull | Bitrise.io Cache:Pull | +| Run CocoaPods install | Run CocoaPods install | Run CocoaPods install | Run CocoaPods install | +| Fastlane - Build and Test | Xcode Test for iOS | Xcode Test for iOS | Xcode Test for iOS | +| Fastlane - Run XCov | Fastlane Match | Fastlane Match | Fastlane Match | +| Danger | Fastlane - Build and Upload Production App to App Store | Fastlane - Build and Upload Staging App | Fastlane: Build and Upload Production App | + +## Trigger Map + +| Workflow | Trigger | +|-------------------------|-------------------------| +| test | Create or Update a PR | +| deploy_staging | Push branch `develop` | +| deploy_release_firebase | Push branch `release/*` | +| deploy_app_store | Push branch `master` | + +## Environment and Secrets +### App Environtment Variables +- BITRISE_PROJECT_PATH +> e.g., ExampleApp.xcodeproj or in case you're using CocoaPod, it is ExampleApp.xcworkspace. + +- TEAM_ID +> This is your Apple Team ID (e.g., T3T4E84BAA), you can find it in `Membership` at Apple developer portal. + +- MATCH_REPO_URL +> Link to a repository that contains your Fastlane Match it can be either HTTPS or SSH link (e.g., https://github.com/nimblehq/fastlane-match.git) + +### Workflow Environment Variables +All four workflows have their own variables: + +- BUNDLE_ID +> e.g., com.nimblehq.exampleApp + +*Depending on which workflow, the value of those variables may differ from other workflows.* + +### Secrets + +- MATCH_PASSWORD +> This is an encryption password for the Match Repo + +## Installation +1. Follow the setup instruction in [`README.md`](https://github.com/nimblehq/ios-templates#readme). +2. To connect your repository to Bitrise please follow the instruction in this page: [Adding a new app](https://devcenter.bitrise.io/en/getting-started/adding-your-first-app.html). +3. Make sure the option where the `bitrise.yml` locate is set to `Store in-app repository`. +
+ +
+ +4. Provide all the required variables and secrets. +> Final project directory structure +``` +ROOT +├── ExampleApp.xcworkspace +├── bitrise.yml +├──... +``` +5. Push changes to SCM. diff --git a/.github/wiki/Getting-Started.md b/.github/wiki/Getting-Started.md new file mode 100644 index 00000000..0d2af9ad --- /dev/null +++ b/.github/wiki/Getting-Started.md @@ -0,0 +1,13 @@ +## Requirements + +- Xcode `13.3+` +- Ruby `3.1.2` + +## Use the template + +1. Create your repository by pressing the `Use this template` button in this repository or create a new repository and use `nimblehq/ios-templates` as a repository template. +2. Clone your repository +3. Setup the project by running the following command in your terminal: + ```bash + sh make.sh --bundle-id [BUNDLE_ID_PRODUCTION] --bundle-id-staging [BUNDLE_ID_STAGING] --project-name [PROJECT_NAME] + ``` diff --git a/.github/wiki/Github-Actions.md b/.github/wiki/Github-Actions.md new file mode 100644 index 00000000..69a08361 --- /dev/null +++ b/.github/wiki/Github-Actions.md @@ -0,0 +1,65 @@ +# Github Actions + +Use the GitHub Actions template to start a new project with GitHub Actions as the CI/CD tool. + +Out of the box, the template contains the following workflows: + +## Workflows + +There are currently 4 workflows: + +- test +- deploy_firebase +- deploy_release_firebase +- deploy_app_store + +|Task/Workflow |test |deploy_firebase|deploy_release_firebase|deploy_app_store| +|------------------------|------------------------------------------------------------------------------------------------------------------------------------|---------------|-----------------------|----------------| +|Trigger |merge or push to feature/chore/bug branch |merge or push to develop branch|merge or push to release branch|merge or push to main/ master branch| +|Lint (async) |✅ |✅ |✅ |✅ | +|Test |✅ |✅ |✅ |✅ | +|Deploy |❌ |Staging build to Firebase|Production build to Firebase|Production build to App Store| + +## Jobs + +### Lint + +1. Check out the current version. +2. Run a SwiftLint on a Linux machine. Show result on pull request's check. + +### Test + +1. Check out the current version. +2. Install dependencies including Gem, Fastlane, and Cocoapods. +3. Run Test on staging scheme and show result on pull request's check. + +### Deploy + +1. Proceed to 4 if this job is running after `Test` job +2. Check out the current version. +3. Install dependencies including Gem, Fastlane, and Cocoapods. +4. Install provisioning profiles and certificates using Fastlane match. +5. Build archive version of the specified scheme. +6. Deploy to Firebase Distribution, TestFlight, or App Store. + +# Installation + +## Environment Secrets + +Make sure the following secrets are set up. + +|Secret |Description |test|deploy_firebase|deploy_release_firebase|deploy_app_store | +|------------------------|------------------------------------------------------------------------------------------------------------------------------------|----|---------------|-----------------------|-----------------------------------| +|SSH_PRIVATE_KEY |SSH key connected to a user with access to the match repo for check out the match repo. |- |✅ |✅ |✅ | +|MATCH_PASS |Fastlane Match Passphrase for decrypting a match repository. |- |✅ |✅ |✅ | +|APPSTORE_CONNECT_API_KEY|App Store Connect API https://docs.fastlane.tools/actions/app_store_connect_api_key/ for uploading build to TestFlight or App Store.|- |- |- |✅ | +|FIREBASE_TOKEN |Firebase token https://firebase.google.com/docs/cli#cli-ci-systems for uploading build to Firebase Distributions and Analytics. |- |✅ |✅ |✅ For uploading dSYM to Crashlytics| + +## Installation + +1. Following the setup instruction in `README.md`. +2. Modify the files with project's values: + - fastlane/Matchfile + - fastlane/Constants/Constants.rb +3. Provide SECRETS noted in `yml` file in [Github Project's Setting](https://docs.github.com/en/actions/reference/encrypted-secrets) +4. Push changes to Github \ No newline at end of file diff --git a/.github/wiki/Home.md b/.github/wiki/Home.md index de8a50eb..3158e255 100644 --- a/.github/wiki/Home.md +++ b/.github/wiki/Home.md @@ -2,4 +2,4 @@ This wiki contains documentation about our optimized iOS template. -If you want to understand our templates, let's jump into [[Getting Started]]. +If you want to start with our templates, let's jump into [[Getting Started]]. diff --git a/.github/wiki/Project-Configurations.md b/.github/wiki/Project-Configurations.md new file mode 100644 index 00000000..2fefdf34 --- /dev/null +++ b/.github/wiki/Project-Configurations.md @@ -0,0 +1,136 @@ +## Project Configurations + +This document presents in detail the set of configurations used in the iOS projects developed at Nimble. Included in this document are: + +- Terminologies and topics related to project configurations. +- Basic targets, schemes, build settings options, etc., for building a project. + +### Targets + +A target specifies a product to build, such as an iOS, watchOS, or macOS app. + +When creating a project from a template, a default target will be added automatically for the main application. + +There are 3 default targets in a project: + +- {ProjectName} +- {ProjectName}Tests +- {ProjectName}UITests + +### Schemes + +A scheme is a collection of settings that specifies the targets to build for a project, the build configuration to use, and the executable environment to use when the product is launched. + +The 2 main schemes in a project: + +- {ProjectName} +- {ProjectName} Staging + +### Build Configurations in Schemes + +It is possible to build a scheme with different Build Configurations. Initially, there are 2 basic configurations for a project generated automatically by Xcode, which are: + +- Debug +- Release + +However, these basic configurations are not enough for our development process. Since our team always wants to ensure the application is working in a designated manner, additional levels of testing are required before the application is ready to be used. + +The recommended set of configurations to have is: + +- Debug Staging +- Release Staging +- Debug Production +- Release Production + +### Active Compilation Conditions + +Having distinct flags for each configuration is the preferred solution. + +Xcode provides a build setting named `Active Compilation Conditions`, which supports passing conditional compilation flags to the Swift compiler. + +In our iOS template project, there are three custom conditional compilation flags: `DEBUG`, `STAGING`, `PRODUCTION`. The following table will describe how the developers differentiate a configuration from the others. + +| Build Configurations | DEBUG | STAGING | PRODUCTION | +|---|---|---|---| +| Debug Staging | ✔︎ | ✔︎ | | +| Release Staging | | ✔︎ | | +| Debug Production | ✔︎ | | ✔︎ | +| Release Production | | | ✔︎ | + +The major advantage of custom flags is to allow customizable specific features based on a particular environment. + +Example: + +Specify a value based on the environment: + +```swift +enum Environment { + + static func based+ +
+ ++ iOS Templates +
+ +--- Our optimized iOS template used in our projects using Xcode Templates -## Requirements +## Getting Started -Xcode 12.0 +### Requirements -## Wiki +- Ruby `3.1.2` +- Xcode `13.3+` -1. [Standard File Organization](https://github.com/nimblehq/ios-templates/wiki/Standard-file-organization) -2. [Project Configurations](https://github.com/nimblehq/ios-templates/wiki/Project-configurations) -3. [Why having project's dependencies](https://github.com/nimblehq/ios-templates/wiki/Why-having-project%27s-dependencies) -4. [Github Actions](https://github.com/nimblehq/ios-templates/wiki/Github-Actions-Templates) -5. [Bitrise Template](https://github.com/nimblehq/ios-templates/wiki/Bitrise-Template) +### Use the template +1. Create your repository by pressing the `Use this template` button in this repository or create a new repository and use `nimblehq/ios-templates` as a repository template. +2. Clone your repository +3. Setup the project by running the following command in your terminal: + ```bash + sh make.sh --bundle-id [BUNDLE_ID_PRODUCTION] --bundle-id-staging [BUNDLE_ID_STAGING] --project-name [PROJECT_NAME] + ``` -# Tuist Installation and Documentations +## Full Documentation +See the [Wiki](https://github.com/nimblehq/ios-templates/wiki/) for full documentation, project details and other information. -Run the following command in your terminal for the Tuist installation: +## License +This project is Copyright (c) 2014 and onwards. It is free software, +and may be redistributed under the terms specified in the [LICENSE] file. -```bash -bash <(curl -Ls https://install.tuist.io) -``` +[LICENSE]: /LICENSE -Documentation : [Tuist Official Documents](https://docs.tuist.io/tutorial/get-started) +## About +![Nimble](https://assets.nimblehq.co/logo/dark/logo-dark-text-160.png) -## How to use +This project is maintained and funded by Nimble. -### Install Script +We love open source and do our part in sharing our work with the community! +See [our other projects][community] or [hire our team][hire] to help build your product. -Execute the following command -``` -sh make.sh --bundle-id [BUNDLE_ID_PRODUCTION] --bundle-id-staging [BUNDLE_ID_STAGING] --project-name [PROJECT_NAME] -``` +[community]: https://github.com/nimblehq +[hire]: https://nimblehq.co/ \ No newline at end of file diff --git a/Tuist/Config.swift b/Tuist/Config.swift deleted file mode 100644 index e39707e0..00000000 --- a/Tuist/Config.swift +++ /dev/null @@ -1,9 +0,0 @@ -import ProjectDescription - -let config = Config( - generationOptions: [ - .disableAutogeneratedSchemes, - .disableSynthesizedResourceAccessors, - .disableBundleAccessors - ] -) diff --git a/Workspace.swift b/Workspace.swift new file mode 100644 index 00000000..1ac6aca0 --- /dev/null +++ b/Workspace.swift @@ -0,0 +1,17 @@ +import ProjectDescription + +let workspace = Workspace.workspace(name: "{PROJECT_NAME}") + +extension Workspace { + + static func workspace(name: String) -> Workspace { + return Workspace( + name: name, + projects: ["./**"], + generationOptions: .options( + autogeneratedWorkspaceSchemes: + .disabled + ) + ) + } +} diff --git a/make.sh b/make.sh index e3a0c881..632b1294 100644 --- a/make.sh +++ b/make.sh @@ -80,7 +80,7 @@ if [ -z "$bundle_id_production" ] || [ -z "$bundle_id_staging" ] || [ -z "$proje fi # Enforce package name -regex='^[a-z][a-z0-9_]*(\.[a-z0-9_]+)+[0-9a-z_]$' +regex='^[a-z][a-z0-9_]*(\.[a-z0-9_-]+)+[0-9a-z_-]$' if ! [[ $bundle_id_production =~ $regex ]]; then die "Invalid Package Name: $bundle_id_production (needs to follow standard pattern {com.example.package})" fi