Skip to content

Commit

Permalink
Add Trio-Specific App Group for Isolated Data Storage (nightscout#314)
Browse files Browse the repository at this point in the history
* Add app group `group.$(BUNDLE_IDENTIIFER).trio-app-group` to Trio

* Update testflight.md regarding Trio app group

Co-Authored-By: Marion Barker <marionbarker@users.noreply.github.com>

* Fix wrong CGMBLEKit SHA checked out for submodule

* Update with latest dev; update submodules; resolve merge conflict leftover

* Update testflight.md

* Address review feedback: fix small typos, add bullet point

* Address review feedback: Remove sections; add beta tester hint for app group

---------

Co-authored-by: Marion Barker <marionbarker@users.noreply.github.com>
  • Loading branch information
dnzxy and marionbarker authored Jul 16, 2024
1 parent bd56601 commit 9672da2
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 45 deletions.
1 change: 0 additions & 1 deletion Config.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ APP_BUILD_NUMBER = 1
COPYRIGHT_NOTICE =
DEVELOPER_TEAM = ##TEAM_ID##
BUNDLE_IDENTIFIER = org.nightscout.$(DEVELOPMENT_TEAM).trio
APP_GROUP_ID = group.com.$(DEVELOPMENT_TEAM).loopkit.LoopGroup
APP_ICON = trioBlack
APP_URL_SCHEME = Trio

Expand Down
2 changes: 2 additions & 0 deletions FreeAPS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3026,6 +3026,7 @@
baseConfigurationReference = 38F3783A2613555C009DB701 /* Config.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
APP_GROUP_ID = "group.$(BUNDLE_IDENTIFIER).trio-app-group";
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
Expand Down Expand Up @@ -3091,6 +3092,7 @@
baseConfigurationReference = 38F3783A2613555C009DB701 /* Config.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
APP_GROUP_ID = "group.$(BUNDLE_IDENTIFIER).trio-app-group";
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
Expand Down
95 changes: 51 additions & 44 deletions fastlane/testflight.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,24 @@ These instructions allow you to build Trio without having access to a Mac.
* You do not need to worry about specific Xcode/Mac versions for a given iOS

## **Automatic Builds**
>
>
> The browser build defaults to automatically updating and building a new version of Trio according to this schedule:
> - automatically checks for updates weekly on Wednesdays and if updates are found, it will build a new version of the app
> - automatically builds once a month regardless of whether there are updates on the first of the month
> - with each scheduled run (weekly or monthly), a successful Build Trio log appears - if the time is very short, it did not need to build - only the long actions (>10 minutes) built a new Trio app
>
>
> * automatically checks for updates weekly on Wednesdays and if updates are found, it will build a new version of the app
> * automatically builds once a month regardless of whether there are updates on the first of the month
> * with each scheduled run (weekly or monthly), a successful Build Trio log appears - if the time is very short, it did not need to build - only the long actions (>10 minutes) built a new Trio app
>
> It also creates an alive branch, if you don't already have one. See [Why do I have an alive branch?](#why-do-i-have-an-alive-branch).
>
> The [**Optional**](#optional) section provides instructions to modify the default behavior if desired. >
> The [**Optional**](#optional) section provides instructions to modify the default behavior if desired.
## Introduction

The setup steps are somewhat involved, but nearly all are one time steps. Subsequent builds are trivial. Your app must be updated once every 90 days, but it's a simple click to make a new build and can be done from anywhere.

Note that installing with TestFlight requires the Apple ID account holder for the phone be 13 years or older (age varies with country). This can be circumvented by logging into Media & Purchase on the child's phone with an adult's account. More details on this can be found in [LoopDocs](https://loopkit.github.io/loopdocs/gh-actions/gh-deploy/#install-testflight-loop-for-child).

This method for building without a Mac was ported from Loop. If you have used this method for Loop or one of the other DIY apps (Loop Caregiver, Loop Follow, Xdrip4iOS), some of the steps can be re-used and the full set of instructions does not need to be repeated. This will be mentioned in relevant sections below.
This method for building without a Mac was ported from Loop. If you have used this method for Loop or one of the other DIY apps (Loop Caregiver, Loop Follow, xDrip4iOS), some of the steps can be re-used and the full set of instructions does not need to be repeated. This will be mentioned in relevant sections below.

There are more detailed instructions in LoopDocs for doing Browser Builds of Loop and other apps, including troubleshooting and build errors. Please refer to [LoopDocs](https://loopkit.github.io/loopdocs/gh-actions/gh-other-apps/) for more details.

Expand All @@ -34,17 +35,17 @@ If you build multiple apps, you may want to use a free *GitHub* organization. Pl

* A [github account](https://github.com/signup). The free level comes with plenty of storage and free compute time to build Trio, multiple times a day, if you wanted to.
* A paid [Apple Developer account](https://developer.apple.com).
* Some time. Set aside a couple of hours to perform the setup.
* Some time. Set aside a couple of hours to perform the setup.
* Use the same GitHub account for all "Browser Builds" of the various DIY apps.

## Save 6 Secrets

You require 6 Secrets (alphanumeric items) to use the GitHub build method and if you use the GitHub method to build other apps, e.g., Loop Follow or Xdrip4iOS, you will use the same 6 Secrets for each app you build with this method. Each secret is indentified below by `ALL_CAPITAL_LETTER_NAMES`.
You require 6 Secrets (alphanumeric items) to use the GitHub build method and if you use the GitHub method to build other apps, e.g., Loop Follow or xDrip4iOS, you will use the same 6 Secrets for each app you build with this method. Each secret is indentified below by `ALL_CAPITAL_LETTER_NAMES`.

* Four Secrets are from your Apple Account
* Two Secrets are from your GitHub account
* Be sure to save the 6 Secrets in a text file using a text editor
- Do **NOT** use a smart editor, which might auto-correct and change case, because these Secrets are case sensitive
* Do **NOT** use a smart editor, which might auto-correct and change case, because these Secrets are case sensitive

Refer to [LoopDocs: Make a Secrets Reference File](https://loopkit.github.io/loopdocs/gh-actions/gh-first-time/#make-a-secrets-reference-file) for a handy template to use when saving your Secrets.

Expand All @@ -68,7 +69,7 @@ Log into your GitHub account to create a personal access token; this is one of t
1. Create a [new personal access token](https://github.com/settings/tokens/new):
* Enter a name for your token, use "FastLane Access Token".
* Change the Expiration selection to `No expiration`.
* Select the `workflow` permission scope - this also selects `repo` scope.
* Select the `workflow` permission scope \* this also selects `repo` scope.
* Click "Generate token".
* Copy the token and record it. It will be used below as `GH_PAT`.

Expand All @@ -83,6 +84,7 @@ The first time you build with the GitHub Browser Build method for any DIY app, y
> A private Match-Secrets repository is automatically created under your GitHub username the first time you run a GitHub Action. Because it is a private repository - only you can see it. You will not take any direct actions with this repository; it needs to be there for GitHub to use as you progress through the steps.
## Setup Github Trio repository

1. Fork https://github.com/nightscout/Trio into your account. If you already have a fork of Trio in GitHub, you can't make another one. You can continue to work with your existing fork, or delete that from GitHub and then fork https://github.com/nightscout/Trio.
1. In the forked Trio repo, go to Settings -> Secrets and variables -> Actions.
1. For each of the following secrets, tap on "New repository secret", then add the name of the secret, along with the value you recorded for it:
Expand Down Expand Up @@ -116,25 +118,25 @@ This step validates most of your six Secrets and provides error messages if it d

If you previously built Trio using Mac with Xcode with this Apple ID, skip ahead to [Optional: App Group Description Modification](#optional-app-group-description-modification).

_Please note that Trio uses the same app group as Loop. This enables other apps such as Xdrip4iOS to share data with Trio. It may require some caution if transfering between Trio and Loop._
_Please note that Trio uses a Trio-specific app group, not the same as Loop. This enables other apps such as xDrip4iOS to share data with Trio. It may require some caution if transfering between Trio and Loop._

1. Go to [Register an App Group](https://developer.apple.com/account/resources/identifiers/applicationGroup/add/) on the apple developer site.
1. For Description, use "Loop App Group".
1. For Identifier, enter "group.com.TEAMID.loopkit.LoopGroup", substituting your team id for `TEAMID`.
1. For Description, use "Trio App Group".
1. For Identifier, enter `group.org.nightscout.TEAMID.trio.trio-app-group`, substituting your team id for `TEAMID`.
* If you are told that this group already exists, skip ahead to [Optional: App Group Description Modification](#optional-app-group-description-modification)
1. Click "Continue" and then "Register".

### Optional: App Group Description Modification

> This step is not required, but if you previously built using a Mac with Xcode, it is a good idea to update the **NAME** associated with the **IDENTIFIER** for the Loop App Group. Notice in the table below that the XCode version of the **NAME** is the same as the **IDENTIFIER** but with the `.` replaced with a space.
> This step is not required, but if you previously built using a Mac with Xcode, it is a good idea to update the **NAME** associated with the **IDENTIFIER** for the `Trio App Group`. Notice in the table below that the Xcode version of the **NAME** is the same as the **IDENTIFIER** but with the `.` replaced with a space.
_Referring to the link and table below, tap on the **IDENTIFIER** for the `Loop App Group`, edit the Description to match the **NAME**, then Save the change._
_Referring to the link and table below, tap on the **IDENTIFIER** for the `Trio App Group`, edit the Description to match the **NAME**, then Save the change._

* [App Group List](https://developer.apple.com/account/resources/identifiers/list/applicationGroup)

| NAME | XCode version | IDENTIFIER |
| NAME | Xcode version | IDENTIFIER |
|:--|:--|:--|
| Loop App Group | group com TEAMID loopkit LoopGroup| group.com.TEAMID.loopkit.LoopGroup |
| Trio App Group | group org nightscout TEAMID trio trio-app-group | group.org.nightscout.TEAMID.trio.trio-app-group |

## Bundle Identifiers

Expand All @@ -149,12 +151,13 @@ Open this link in a separate browser window:
_Referring to the table below, tap on each **IDENTIFIER** that has a different **NAME**, edit the Description to match the **NAME**, then Save the change for that identifier._

#### Table of Identifiers
### Table of Identifiers

* If you built previously using a Mac with Xcode, you may see the XCode version in your **NAME** column - it starts with XC and then the **IDENTIFIER** is appended where the `.` is replaced with a space, the example for Trio is shown in detail
* If you built previously using a Mac with Xcode, you may see the Xcode version in your **NAME** column - it starts with XC and then the **IDENTIFIER** is appended where the `.` is replaced with a space, the example for Trio is shown in detail
* If you built during early beta testing, you might not have `Trio` at the beginning of each **IDENTIFIER** and the full **NAME** may be slightly different
* If you built during early beta testing, you might have the Loop App Group associated with the Trio identifiers. If so, use instructions to [Create App Group](#create-app-group) for Trio. Subsequently, modify the App Group associated with the Trio Identifiers using [Add App Group to Bundle Identifiers](#add-app-group-to-bundle-identifiers).

| NAME | XCode version | IDENTIFIER |
| NAME | Xcode version | IDENTIFIER |
|:--|:--|:--|
| Trio | XC org nightscout TEAMID trio | org.nightscout.TEAMID.trio |
| Trio LiveActivity | - | org.nightscout.TEAMID.trio.LiveActivity |
Expand All @@ -167,20 +170,23 @@ _Referring to the table below, tap on each **IDENTIFIER** that has a different *
> If you previously built using a Mac with Xcode you can skip ahead to [Create Trio App in App Store Connect](#create-trio-app-in-app-store-connect).
> If you have previously built Trio as a beta tester (between May 13th, 2024, and today), you will already have an app group (`Loop App Group`) created and configured for your bundle identifiers. In this case, please *do not* skip this section; you are required to create the `Trio App Group` and configure it for your identifiers, as described below.
1. Go to [Certificates, Identifiers & Profiles](https://developer.apple.com/account/resources/identifiers/list) on the Apple developer site.
1. Repeat this step for these three Identifier **NAMES** - refer to the [Table](#table-of-identifiers) above if your Names look different; if they do, see [Optional: Identifier Description Modification](#optional-identifier-description-modification)
* Trio
* Trio Watch
* Trio WatchKit Extension
1. Click on the **IDENTIFIER** row.
1. Scroll down to the "App Groups" capabilies row, click on the "Configure" (or "Edit") button.
1. Select (or verify the selection for) the "Loop App Group" _(yes, "Loop App Group" is correct)_
1. Select the "Trio App Group" _(yes, "Trio App Group" is correct)_
1. Click "Continue".
1. Click "Save".
1. Click "Confirm".
1. Remember to do this for each of three identifiers listed under step 2.

There is an additional identifier, but it does not need the App Group added to it:

* Trio LiveActivity

## Create Trio App in App Store Connect
Expand All @@ -192,7 +198,7 @@ If you created a Trio app in App Store Connect before, skip ahead to [Create Bui
* Select a name: this will have to be unique, so you may have to try a few different names here, but it will not be the name you see on your phone, so it's not that important.
* Select your primary language.
* Choose the bundle ID that matches the `BUNDLE_IDENTIFIER` in your `Config.xcconfig` file
* this is typically `org.nightscout.TEAMID.trio` with `TEAMID` matching your team id
* This is typically `org.nightscout.TEAMID.trio` with `TEAMID` matching your team id
* SKU can be anything; e.g. "123".
* Select "Full Access".
1. Click Create
Expand Down Expand Up @@ -257,7 +263,7 @@ If you choose not to have automatic building enabled, be sure the `GH_PAT` has `

You can modify the automation by creating and using some variables.

To configure the automated build more granularly involves creating up to two environment variables: `SCHEDULED_BUILD` and/or `SCHEDULED_SYNC`. See [How to configure a variable](#how-to-configure-a-variable).
To configure the automated build more granularly involves creating up to two environment variables: `SCHEDULED_BUILD` and/or `SCHEDULED_SYNC`. See [How to configure a variable](#how-to-configure-a-variable).

Note that the weekly and monthly Build Trio actions will continue, but the actions are modified if one or more of these variables is set to false. **A successful Action Log will still appear, even if no automatic activity happens**.

Expand All @@ -267,10 +273,10 @@ Note that the weekly and monthly Build Trio actions will continue, but the actio

|`SCHEDULED_SYNC`|`SCHEDULED_BUILD`|Automatic Actions|
|---|---|---|
| `true` (or NA) | `true` (or NA) | keep-alive, weekly update check (auto update/build), monthly build with auto update|
| `true` (or NA) | `false` | keep-alive, weekly update check with auto update, only builds if update detected|
| `true` (or NA) | `true` (or NA) | keep-alive, weekly update check (auto update/build), monthly build with auto update |
| `true` (or NA) | `false` | keep-alive, weekly update check with auto update, only builds if update detected |
| `false` | `true` (or NA) | keep-alive, monthly build, no auto update |
| `false` | `false` | no automatic activity, no keep-alive|
| `false` | `false` | no automatic activity, no keep-alive |

### How to configure a variable

Expand All @@ -279,21 +285,22 @@ Note that the weekly and monthly Build Trio actions will continue, but the actio
3. Click on `Actions`
4. You will now see a page titled *Actions secrets and variables*. Click on the `Variables` tab
5. To disable ONLY scheduled building, do the following:
- Click on the green `New repository variable` button (upper right)
- Type `SCHEDULED_BUILD` in the "Name" field
- Type `false` in the "Value" field
- Click the green `Add variable` button to save.
7. To disable scheduled syncing, add a variable:
- Click on the green `New repository variable` button (upper right)
- - Type `SCHEDULED_SYNC` in the "Name" field
- Type `false` in the "Value" field
- Click the green `Add variable` button to save
* Click on the green `New repository variable` button (upper right)
* Type `SCHEDULED_BUILD` in the "Name" field
* Type `false` in the "Value" field
* Click the green `Add variable` button to save.
6. To disable scheduled syncing, add a variable:
* Click on the green `New repository variable` button (upper right)
* Type `SCHEDULED_SYNC` in the "Name" field
* Type `false` in the "Value" field
* Click the green `Add variable` button to save

Your build will run on the following conditions:
- Default behaviour:
- Run weekly, every Wednesday at 08:00 UTC to check for changes; if there are changes, it will update your repository and build
- Run monthly, every first of the month at 06:00 UTC, if there are changes, it will update your repository; regardless of changes, it will build
- Each time the action runs, it makes a keep-alive commit to the `alive` branch if necessary
- If you disable any automation (both variables set to `false`), no updates, keep-alive or building happens when Build Trio runs
- If you disabled just scheduled synchronization (`SCHEDULED_SYNC` set to`false`), it will only run once a month, on the first of the month, no update will happen; keep-alive will run
- If you disabled just scheduled build (`SCHEDULED_BUILD` set to`false`), it will run once weekly, every Wednesday, to check for changes; if there are changes, it will update and build; keep-alive will run

* Default behaviour:
* Run weekly, every Wednesday at 08:00 UTC to check for changes; if there are changes, it will update your repository and build
* Run monthly, every first of the month at 06:00 UTC, if there are changes, it will update your repository; regardless of changes, it will build
* Each time the action runs, it makes a keep-alive commit to the `alive` branch if necessary
* If you disable any automation (both variables set to `false`), no updates, keep-alive or building happens when Build Trio runs
* If you disabled just scheduled synchronization (`SCHEDULED_SYNC` set to`false`), it will only run once a month, on the first of the month, no update will happen; keep-alive will run
* If you disabled just scheduled build (`SCHEDULED_BUILD` set to`false`), it will run once weekly, every Wednesday, to check for changes; if there are changes, it will update and build; keep-alive will run

0 comments on commit 9672da2

Please sign in to comment.