Build and Update
Jump to…
Build with GitHub | Xcode | Script
Update with GitHub | Xcode | Source Control | CLI
Build Trio with GitHub
The Trio repository contains instructions for building the Trio app using a browser and GitHub. More detailed instructions are also available in LoopDocs.
Tip
If using the LoopDocs instructions you need the important information below to build Trio intead of Loop
Fork from: https://github.com/nightscout/Trio
Identifier Nameswill be:FreeAPS,FreeAPSWatch,FreeAPSWatch WatchKit Extension,LiveActivityExtensionThese names are the same as that used by iAPS, they are distinguised by the Identifier itself, which include the new BundleID for your Trio app
If you build with Xcode before, they will start with XC and use the Identifier string rather than the Name
Identifierswill be:org.nightscout.TEAMID.trioorg.nightscout.TEAMID.trio.watchkitapporg.nightscout.TEAMID.trio.watchkitapp.watchkitextensionorg.nightscout.TEAMID.trio.LiveActivity
Only the first 3 of these identifiers need to have the
App GroupaddedFor the list below, make sure the box next to
App Groupis checked, and clickConfigureto select the same app group as Loop:group.com.TEAMID.loopkit.LoopGroupYou must add this
App Groupto each of the following identifiers:org.nightscout.TEAMID.trioorg.nightscout.TEAMID.trio.watchkitapporg.nightscout.TEAMID.trio.watchkitapp.watchkitextension
In
App Store Connect, theBundle IDfor Trio will be:org.nightscout.TEAMID.trio
One-Time Update to Display Branch And Commit in Testflight
The Trio build can be configured to display the branch name and commit ID as test notes in TestFlight. This is an optional step, which can be especially useful if building the dev branch.
First, you must have already built Trio and have it available on Apple App Store Connect.
Tap on the TestFlight tab
Choose any build to open a new detailed screen for that build
In the Test Details section, type anything you want
After you have done this one-time step, each successive build will include the branch name and commit automatically.
You can add additional tests notes for any build if you desire.
Update Trio with GitHub
Open your fork at github.com/YOUR-USERNAME/Trio with your GitHub username instead of YOUR-USERNAME
Look to see if your fork is up to date
If your fork shows that your branch is behind, sync the branch to get the latest updates
Before building, you can Verify Trio Version
If you selected a GitHub Personal Access Token (GH_PAT) that never expires, select Actions: 4. Build Trio and wait about an hour for your updated app to appear in TestFlight.
If your token has expired, create a new one (and set it to “never expire”) and update the GH_PAT in your Trio secrets. Then, you can build your updated code.
Distribution Certificates
When you first build using GitHub, a Distribution Certificate is generated. It typically is valid for one year. You should get an email from Apple when you are within 30 days of that certificate expiring. When it expires, you can no longer build a new app. (Existing apps in TestFlight are not affected, they get the full 90 days.)
The directions to renew your Distribution Certificate are found in LoopDocs: Renew Certificate.
Build Trio with Xcode
The recommendation is to use the TrioBuildSelectScript to build your code.
Build Trio with Script
The TrioBuildSelectScript is similar to the script used to build Loop. If you need it, extensive instructions for that script are provided at these links: LoopDocs: Build Select Script and Loop and Learn: Build Select Script.
The TrioBuildSelectScript offers the choice to:
Build Trio
Build Related Apps
Run Maintenance Utilities
Exit Script
To execute the TrioBuildSelectScript, open a terminal on your Mac and copy and paste the command below into the terminal. Then, read and follow the directions.
/bin/bash -c "$(curl -fsSL \
https://raw.githubusercontent.com/loopandlearn/lnl-scripts/main/TrioBuildSelectScript.sh)"
Build Trio
When you select Build Trio, you will be provided with a choice of branches with information to guide your selection and URL for documentation. This script will then download a fresh copy of your selected branch and guide you through building with Xcode on your Mac.
Once the download completes, the script will also
Create the automatic signing file
Offer to remove provisioning profiles from your computer to ensure the build will last an entire year
Provide instructions for how to build the app once Xcode opens
Open Xcode with your new download.
At this point the main menu is displayed again for you to select another option or to exit the script
The download is placed in your Downloads folder in a directory called BuildTrio. The downloaded clone is found in a folder with the branch name, date, and time encoded.
Run Maintenance Utilities
When you select Run Maintenance Utilities, you will be provided with a choice of utilties helpful for Mac builders.
The following options are offered:
Delete Old Downloads
Clean Derived Data
Xcode Cleanup (The Big One)
Clean Profiles
Return to Menu
For more information, refer to Loop and Learn: Maintenance Utitilites documentation.
Build Errors
If you encounter any build issues, please look at the LoopDocs Build errors page. Only some things on that page are relevant for building Trio, but many potential issues will likely be covered there. You will also get helpful advice about what info to provide if you need to ask for help. When you have identified the error message(s), you can use the search tool in LoopDocs to see if your error is mentioned.
If you need it, you are most likely to get help in one of these groups:
Facebook groups like Loop and Learn and Looped primarily focus on Loop but offer a wide variety of support surrounding all types of DIY Looping.
xDrip4iOS or Glucose Direct as CGM Source
Important
LibreTransmitter is provided as part of Trio. Neither xDrip4iOS or Glucose Direct are required to interact with your compatible Libre sensor using Trio.
If you want to use xDrip4iOS or Glucose Direct as a CGM source via “shared app group,” you must also build that app from a source with the same developer ID used for building Trio. Scripts are available for these apps as well. All scripts follow the same download and build pattern and configure automatic signing files for you.
The download is placed in your Downloads folder in a directory called BuildxDrip4iOS or BuildGlucoseDirect, respectively. The downloaded clone is found in a folder with the branch name, date, and time encoded.
These can be accessed using the TrioBuildSelectScript menu options mentioned above. Or you can run each script individually.
xDrip4iOS
/bin/bash -c "$(curl -fsSL \
https://raw.githubusercontent.com/loopandlearn/lnl-scripts/main/BuildxDrip4iOS.sh)"
Glucose Direct
/bin/bash -c "$(curl -fsSL \
https://raw.githubusercontent.com/loopandlearn/lnl-scripts/main/BuildGlucoseDirect.sh)"
Alternative Branch
Sometimes, specific branches are offered for testing. Any desired branch can be cloned using the Build Trio script. After the final quote of the script command, add a space, hyphen, space, and branch_name. An example is shown below: replace branch_name with your desired branch. Note that specific branches like this are not deleted as part of the Delete Old Downloads utility discussed in Maintenance Utilities.
/bin/bash -c "$(curl -fsSL \
https://raw.githubusercontent.com/loopandlearn/lnl-scripts/main/BuildTrio.sh)" - branch_name
Update Trio with Xcode
The recommendation is to use the Xcode Source Control features to update your code.
If you prefer the command line interface, skip ahead to Update Trio with CLI.
Update Trio with Source Control
Open Xcode. If your Trio (FreeAPS) workspace is not already open, you can usually find it in the recent projects, as shown in the graphic below. You can also pull down the Xcode menu for File, select Open Recent, and find your workspace.
The graphic below needs to be updated:
There are 2 methods to open
Source ControlHold down the command key and hit 2 (cmd-2)
Use the menus to select
View,Navigate,Source Control
This modifies the Xcode display with two tabs:
There is a
Changestab and aRepositoriestabIt might say
No changes, but fetch changes to make sure
Tap on the
Integratemenu and selectFetch changes
The graphic below needs to be updated:
Click
IntegrateagainSelect
Pull…
Refer to the graphic below:
Select the branch to pull from
Click
Pull
The correct branch should already be selected for you. If you built from main, select main. If you built from dev, select dev. (This graphic has the older branch name of master.)
The last steps are only relevant if you made any changes to the code:
You may see a pop-up asking to stash your changes. In that case, name the stashed changes to something meaningful to you.
Select “Apply Stash After Operation”
Click “Stash and Pull”
The Trio code is now updated. That was easy. If you used the build script that automatically creates your ConfigOverride file, the targets are already signed, and you are ready to build the Trio app on your phone.
The following section is only for those who prefer to use the command line interface for git. Skip ahead to Verify Trio Version.
Update Trio with CLI
Use finder to locate the directory where the BuildTrio script saved the code. The directory is named after the branch with the date and time for the download:
Released (main) branch: Downloads/BuildTrio/Trio_main-[date-time]/Trio
Example: ~/Downloads/BuildTrio/Trio_main-220122-1352/Trio
Development (dev) branch: Downloads/BuildTrio/Trio_dev-[date-time]/Trio
Example: ~/Downloads/BuildTrio/Trio_dev-220108-1827/Trio
Use finder to open a Terminal window at the Trio directory by right-clicking on it and selecting New Terminal at Folder.
Copy each line below and paste it into the terminal window one at a line and hit enter for each line:
git stash
git fetch
git pull --recurse
git stash pop
If the final git stash pop had errors, you must repeat any customizations you made in your prior code—they are no longer compatible with the updated code.
The Trio code is now updated. To open the workspace in Xcode, type xed . in your terminal window.
The targets should be signed, and you will be ready to build the Trio app on your phone.
Verify Trio Version
Verify that the Trio code was successfully updated by examining the APP_VERSION value in the Config.xcconfig file. (Refer to the graphic below.) Make sure what is shown in your Xcode display matches the expected version on the Trio GitHub Releases page.
If using the GitHub method, you can view this same file in your fork of the Trio repository.