Code Customization

In a DIY community, there are always requests for code customization instructions.

Refer to LoopDocs: Code Customizations for the complete list of documented customizations.

  • Some customizations must be personalized while others are the same for everyone
  • This page provides customization text that you can copy and use directly with the GitHub Browser Build method
  • These same customizations are available with the Mac-Xcode Build method

If you use these or other customizations, and need to ask for help with a problem, be sure to indicate what code customizations you added to your app.

Prepared Customizations

The list of prepared customizations is found below.

For Mac-Xcode builders, the same text can be used to apply customizations but you can also add or remove these customizations using the Customization Select Script.

GitHub Browser Build for Loop with Patches

If you built the released version of Loop using the GitHub Build Method and want to add some or all of the items added to Loop with Patches, you are in the right place. The link below takes you to instructions for modifying your build_loop.yml file so you can build the same version that Mac-Xcode builders get with the Build-Select script when they choose Loop with Patches.

  • Main LnL Patches: Instructions to modify the build_loop.yml file to build Loop with Patches (same as Build-Select version)

Once you have added the text found in that link, you can return to the Single Customization List and add additional customizations into your build_loop.yml file.

If you are scratching your head, wondering what the previous sentences mean, keep going, we will try to explain it. Still confused after reading the next few sections? Please reach out for help.

    Single Customization List

    Mac-Xcode Builders have access to this list via the Customization Select Script.

    GitHub Broswer Builders:

    • Please read about how to modify the build_loop.yml file to customize your Loop app before trying to use the links to Prepared Customizations
    • Single customizations can be added by copying and pasting the specific text found at each of the links below in a blank line below the Loop Customization template

    All Builders: Please review the URL associated with each customization linked below to ensure this is the code change you intend to use.

    List of Prepared Customizations

    GitHub Builders

    For those using the GitHub browser build method, you will need to edit the build_loop.yml file. This can be done in a browser open to your LoopWorkspace fork.

    1. Make sure you are logged into your GitHub account
    2. Go to your fork ( github dot com / username / LoopWorkspace )
    3. Navigate by tapping on Code, then the folder “.github/workflows” and then build_loop.yml
    4. When you tap on build_loop.yml, you see the text for that file
    5. There is a pencil on the right side – tap on the pencil and now you can edit the file
    6. Follow the directions below until you make the changes you want
      • First insert the Customization Template into build_loop.yml (for Loop 3.2.2 and earlier) (if not already present)
      • Below that, copy and paste any of the comment-command lines you want
      • Please include the comment lines so you know what the customization does
    7. Save the changes by committing directly to your fork with an appropriate comment (make as many edits and commits as you want)
    8. When you are happy with your build_loop.yml, hit Actions: 4 Build Loop
    9. Assuming there are no build errors, your new build will be ready in TestFlight in about an hour

    Customization Template

    You need to add a section to the build_loop.yml file in your fork where you will then add text for customization. It is expected that the next release will not require this – a template will already be there for you. The sections of the build_loop.yml file are defined by indentation. The items within a section are indented two spaces more than the head of the section.

    Each item you add will be in this customization section. The text you copy and paste from this page is designed to have the correct indentation, discussed below.

    While you are editing your build_loop.yml file,

    1. Locate line 31, (as of version Loop 3.2.x)
    2. This is just above the words:
      “# Patch Fastlane Match to not print tables”
    3. Your cursor can be anywhere on line 31 (should be a blank line)
    4. Copy the text shown and paste it into build_loop.yml.

    Review the format after you paste:

    • There needs to be one blank line between each section and the tabs need to be adjusted so the columns line up
    • The text below has been formatted to be correct, but please check it.
      • The “#” in “# Customize Loop” that you paste in needs to be in the same column as the “#” in “# Checks-out the repo” and the “#” in “# Patch Fastlane Match to not print tables”
      • The word run is indented 2 spaces
      • The “#” for each comment, below run, for each customization should be two spaces to the right of the word run
        • All the inserted customizations line up in the same column
      • The word “curl” for each customizations you add starts right below the “#” in the comment

    Click on one of the lines in the template of text below to copy the entire template to your paste buffer. The words “Copied to Clipboard” will appear briefly.

              
          # Customize Loop: Download and apply patches
          - name: Customize Loop
            run: | 
    
              # The patches start here
            

    Prepared Customizations: Components

    Each of the prepared customizations found on this page includes a link (URL) where you can see the exact code change that will be implemented if you use it.

    There are two lines (for most items) that you can copy and paste into your build_loop.yml file.

    • The first line is a comment statement that begins with a # symbol and describes the effect of the customization
      • If more than one line is required for the comment, each line needs to begin with #
    • The second line is the command that applies the patch – it typically starts with the word curl and has the components shown below.
      • Sometimes, more than one line is required
    • Be sure to include all lines

    If you plan to use the prepared customizations, I suggest you skip the rest of this section – you don’t need this level of detail.

    The next level of detail in this section might be helpful for people who want customizations that are not already provided for them and plan to use the LoopDocs: Customize with GitHub instructions.

    Command components to apply the patch to LoopWorkspace:

    curl https://github.com/loopnlearn/LoopWorkspace/commit/SHA-1.patch | git apply

    Command components to apply the patch to a Module:

    curl https://github.com/loopnlearn/Module/commit/SHA-1.patch | git apply --directory=Module

    Explanation:

    • The first “word” is “curl”, which stands for “copy from a URL”
    • The next part is the URL where you could go to examine the code changes you will be introducing.
      • The URL is from the “https:” through the “SHA-1”, where the SHA-1 is a really long alphanumeric string that refers to a specific commit in the GitHub fork universe
      • Note that the user name (shown as loopnlearn) does not have to match the username where that commit was prepared
      • You can make a commit in your own fork, copy the SHA-1 from that commit in your fork to insert into your build_loop.yml, but leave the loopnlearn unchanged and GitHub will still find that commit
      • The SHA-1 is an alphanumeric string that identifies that commit in the GitHub fork universe regardless of which user made the commit
      • If you paste the URL from https through SHA-1 (without the “.patch”) into a browser, it shows the modification found in that commit
    • The addition of the “.patch” to the URL (after the SHA-1) tells GitHub to convert that one commit into a patch that you can apply with the “git apply” command
    • The vertical line, known as a pipe, passes that patch to the git apply command that follows – this is what applies the patch
      • A command to apply the patch to LoopWorkspace just needs the git apply
      • A command to apply the patch to a Module needs to have the directory specified with the Module name (which is case sensitive)

    Build Loop with Patches

    WARNING – Do not add the text in this section to your build_loop.yml file if your fork is from the loopnlearn / LoopWorkspace main_lnl_patches branch.

    Apply the LnL Patches

    This is a set of instructions that can be added to the build_loop.yml file for the released code (your fork is from the LoopKit / LoopWorkspace main branch).

    You can add all of them or choose from among them. (Comment out the `git` or `curl` line of any item you do not want.)

    If you apply all of these to the released code, your app will be the same as if you built using the loopnlearn main_lnl_patches branch by choosing Loop with Patches in the Build-Select script.

    These should be the first patches in your build_loop.yml file because it includes the header (template) for the Customize Loop addition to the file.

    It includes the text discussed at the Introduction to Prepared Customizations link – so you do not need that step.

    The text below is properly formatted (indented) to paste at line 31 (for 3.2.x main build_loop.yml).

    1. Navigate to the build_loop.yml file
    2. Click on the pencil icon
    3. Move your cursor to the line 31 (version 3.2.x – it should be a blank line)
    4. Click on the block of text below and paste it into the build_loop.yml file
    5. Click on green Start commit button (upper right)
    6. Click on box where it says Update build_loop.yml
    7. Click to copy comment (at right) and paste:
    8. Click on Commit changes, leave check boxes alone (Commit directly to your branch)
    9. Run the Action: 4. Build Loop
    10. If that runs without errors, then you can add more customizations below this one.

    Click on any line in the block of text below to copy the entire block to your clipboad. The words “Copied to Clipboard” will appear briefly.

    
            
          # Customize Loop: Download and apply patches
          - name: Customize Loop
            run: |
            
              # BEGINNING: apply the lnl_patches to the released code
              # See: https://www.loopandlearn.org/main-lnl-patches
              
              # LoopWorkspace commit: Adds xDrip4iOS and GlucoseDirect CGM clients
              # Note - the added submodules must be cloned before the patch will work
              git clone https://github.com/johandegraeve/xdrip-client-swift-1.git xdrip-client-swift
              git clone https://github.com/creepymonster/GlucoseDirectClient.git GlucoseDirectClient
              # This patch configures LoopWorkspace to use the added CGM submodules
              curl https://github.com/loopnlearn/LoopWorkspace/commit/4092277a21fa44a1258b693a5fbcce4d8d9dbd17.patch | git apply
    
              # LoopWorkspace commit: Merge pull request to add LoopnLearn logo (from MikePlante1)
              curl https://github.com/loopnlearn/LoopWorkspace/commit/7c1dd02e74508a171128de85741e44b09ccee118.patch | git apply
    
              # This applies CustomTypeOne LoopPatches to released submodules Loop and LoopKit
              # See: https://www.loopandlearn.org/custom-type-one-loop-patches
              curl https://raw.githubusercontent.com/CustomTypeOne/LoopPatches/main/LoopWorkspace.patch | git apply
    
              # END: lnl_patches now applied to the released code
              
              # additional patches can be put below - make sure columns line up
              
    

    Prepared Customization Details

    Each customization, consisting of a comment line and a command line can be copied and then pasted into the build_loop.yml file as described in Introduction to Prepared Customizations.

    Increase Future Carbs Limit to 4 hours

    URL to view the code change: https://github.com/loopnlearn/Loop/commit/a974b6749ef4506ca679a0061c260dabcfbf9ee2

    Click on one of the comment/curl lines below to copy the patch (this copies the comment and the curl lines). The words Copied to Clipboard will appear briefly.

       
              # Loop: Increase future carb time limit to 4 hours from 1 hour default
              curl https://github.com/loopnlearn/Loop/commit/a974b6749ef4506ca679a0061c260dabcfbf9ee2.patch | git apply --directory=Loop
        
    

    Libre Users: Limit Loop to 5 minutes

    URL to view the code change: https://github.com/loopnlearn/Loop/commit/414588c5e7dc36f692c8bbcf2d97adde1861072a

    This is meant primarily for users of Libre sensors which can update CGM values every 1 minute.

    Loop is triggered when a CGM signal arrives; but it is not intended to run every minute. The app can handle the more frequent updates but the pumps associated with Loop cannot. Loop expects the CGM managers associated with Loop to provide once per 5 minute updates to glucose. However, some of the extra CGM managers added with customization did not do that (initially -we think they have been updated to enable that as a selection). If the CGM values are updated too fast (to Loop or to Apple Health) this can cause communication issues with Medtronic pumps and early pod failures.

    Click on one of the comment/curl lines below to copy the patch (this copies the comment and the curl lines). The words Copied to Clipboard will appear briefly.

       
              # Loop: LoopDataManager: Limit loop cycles to no more frequent than once every 4.8 minutes
              curl https://github.com/loopnlearn/Loop/commit/414588c5e7dc36f692c8bbcf2d97adde1861072a.patch | git apply --directory=Loop
              
    

    Modify Carb Warning & Limit: Low Carb to 49 & 99

    This is one of two Carb Warning & Limit modifcations to choose from – select ONLY one.

    The Low Carb version warns when a meal is over 49 g and refuses to allow a single meal entry over 99 g.

    URL to view the code change: https://github.com/loopnlearn/Loop/commit/d9939c65a6b2fc088ee5acdf0d9dc247ad30986c

    Click on one of the comment/curl lines below to copy the patch (this copies the comment and the curl lines). The words Copied to Clipboard will appear briefly.

            
              # Loop: LoopConstants: Limit carb entry to 99 and shows warning if over 49 g
              curl https://github.com/loopnlearn/Loop/commit/d9939c65a6b2fc088ee5acdf0d9dc247ad30986c.patch | git apply --directory=Loop
              
    

    Modify Carb Warning & Limit: High Carb to 201 & 300

    This is one of two Carb Warning & Limit modifcations to choose from – select ONLY one.

    The High Carb version warns when a meal contains 202 g or more and refuses to allow a single meal entry over 300 g.

    URL to view the code change: https://github.com/loopnlearn/Loop/commit/a79482ac638736c2b3b8c5057b48e3097323a522

    Click on one of the comment/curl lines below to copy the patch (this copies the comment and the curl lines). The words Copied to Clipboard will appear briefly.

            
              # Loop: LoopConstants: Limit carb entry to 300 and show warning if over 201 g
              curl https://github.com/loopnlearn/Loop/commit/a79482ac638736c2b3b8c5057b48e3097323a522.patch | git apply --directory=Loop
              
    

    Disable Authentication Requirement

    URL to view the code change: https://github.com/loopnlearn/LoopKit/commit/77ee44534dd16154d910cfb11dea240cf8a23262

    Click on one of the comment/curl lines below to copy the patch (this copies the comment and the curl lines). The words Copied to Clipboard will appear briefly.

            
              # LoopKit: Disable authentication for bolusing and therapy setting changes
              curl https://github.com/loopnlearn/LoopKit/commit/77ee44534dd16154d910cfb11dea240cf8a23262.patch | git apply --directory=LoopKit
              

    Modify Override Insulin Needs Picker (50% to 200%, steps of 5%)

    This modification limits the override sensitivity (insulin needs) to 50% to 200% in steps of 5%. This is often requested for young Loopers.

    URL to view the code change: https://github.com/loopnlearn/LoopKit/commit/f35654104f70b7dc70f750d129fbb338b9a4cee0

    Click on one of the comment/curl lines below to copy the patch (this copies the comment and the curl lines). The words Copied to Clipboard will appear briefly.

            
              # LoopKit: Modify the override sensitivity range to 50% to 200%, allow 5% steps
              curl https://github.com/loopnlearn/LoopKit/commit/f35654104f70b7dc70f750d129fbb338b9a4cee0.patch | git apply --directory=LoopKit
              

    CAGE: Upload Pod Start to Nightscout

    This is a more complicated change and modifies both OmniKit (Eros) and OmniBLE (DASH) so it works regardless of pod type. It is saved as a “patch” file, so the URL might not be as easy for the novice to read.

    URL to view the code change: https://raw.githubusercontent.com/loopnlearn/loopbuildscripts/main/patch/cage.patch

    Click on one of the comment/curl lines below to copy the patch (this copies the comment and the curl lines). The words Copied to Clipboard will appear briefly.

            
              # Upload pod start to Nightscout, Updates both OmniKit (Eros) and OmniBLE (DASH)
              curl https://raw.githubusercontent.com/loopnlearn/loopbuildscripts/main/patch/cage.patch | git apply
              

    SAGE: Upload Dexcom Sensor Start to Nightscout

    This modification uploads to Nightscout to reset the SAGE counter when a Dexcom Sensor (G6 or G7) is started.

    This uses a LoopWorkspace “patch” file, so the URL might not be as easy for the novice to read.

    URL to view the code change: https://raw.githubusercontent.com/loopnlearn/loopbuildscripts/main/patch/g6g7_sage.patch

    Click on one of the comment/curl lines below to copy the patch (this copies the comment and the curl lines). The words Copied to Clipboard will appear briefly.

            
              # SAGE: upload Dexcom sensor start to Nightscout
              curl https://raw.githubusercontent.com/loopnlearn/loopbuildscripts/main/patch/g6g7_sage.patch | git apply
              

    Change Default to Upload Dexcom Readings

    This modification changes the default setting for G6 or G7 Sensor to upload to the remote services, for example, Nightscout and/or Tidepool.

    • With this patch, the user no longer needs to remember to check the box with each transmitter change (G6)
    • Some people like to switch between G6 and G7 – this patch works for both

    This uses a LoopWorkspace “patch” file, so the URL might not be as easy for the novice to read.

    URL to view the code change: https://raw.githubusercontent.com/loopnlearn/loopbuildscripts/main/patch/g6g7_upload_readings.patch

    Click on one of the comment/curl lines below to copy the patch (this copies the comment and the curl lines). The words Copied to Clipboard will appear briefly.

            
              # Set Default selection to upload Dexcom readings to remote services (Nightscout and Tidepool)
              curl https://raw.githubusercontent.com/loopnlearn/loopbuildscripts/main/patch/g6g7_upload_readings.patch | git apply
              

    Loop 2 Code Customization

    This section is left for those still using FreeAPS, which is based off Loop 2.2.x. Those users must use the Mac-Xcode build; the GitHub browser build is not available for FreeAPS.

    Regardless of the location of the customization (here or LoopDocs), please read Instructions for Finding the Lines. Using the Key_Phrase (LoopDocs) or Keyword (this page) makes it much easier to find the code to change.

    The following code customizations are found only on this site.

    Pods: Change Default Expiration Reminder

    This is a built-in feature for Loop 3.  Again, this customization is only for Loop 2.

    The default value is 2 hours before the 72 hour end of “guaranteed” life on the pod; this is measured from the time the insulin is injected into the pod. The range of allowed values is:

    • no smaller than 1 hour, i.e., remind at 71 hours
    • no bigger than 24 hours, i.e., remind at 48 hours

    The information needed to make the modification:

    • Keyword: expirationReminderAlertDefaultTimeBeforeExpiration
    • Folder: rileylink_ios/OmniKit/Model
    • File: Pod.swift
    • Line: 69

    Default:

    public static let expirationReminderAlertDefaultTimeBeforeExpiration = TimeInterval.hours(2)

    The Pod has an internal timer that keeps track of minutes that the Pod has been active. This timer may have a slight drift with respect to actual time, so the 72 hour expiration beeps or the 80 hour Pod shutdown may be a few minutes before or after you expect it, based on this reported expiration date/time. However, the reminder is simply an iPhone notification – it will occur at the stated minute. And if the pod is replaced before the reminder – you might still get a reminder notification because this is based on an iPhone (not a pod) reminder function.

    Medtronic: Disable mySentry

    This requires a workspace build and is only needed for older code, i.e., Loop v2.2.4 and earlier; FreeAPS v2.1 (176) and earlier. Current versions of the code have this available as a selectable option in the pump menu where needed.

    Folks on Medtronic Pumps that have the mySentry feature (523, 554, 723, 754)  report battery draining rapidly on the radio-link.

    A fix has been reported in GitHub.

    This customization disables the mySentry feature, but will give you longer battery life AND fewer communications issues (less yellow/red loops, less bolus errors).

    • Keyword: hasMySentry
    • Folder: rileylink_ios/MinimedKit/Models
    • File: PumpModel.swift
    • Line: 54

    Original line:

        return generation >=23

    Change to:

        return false

    Food Emojis

    This customization allows you to move current emojis found on the carb entry screen to different absorption speed categories as well as add emojis to fit your usage.

    NOTE: the food emoji categories were modified for Loop 3 – do not use this section for Loop 3 code.

    Many users find using Medium (3 hours) for some foods found in the Fast (2 hours) section improves meal management. For those with child loopers, adding new emojis and re-arranging emojis can be a great way to teach them how different foods affect them and how to pick the correct absorption time when they are working on self-management. Finally, those adjusting the default absorption times for fast/medium/slow, may wish to adjust these emoji classifications as well.

    You can move the emojis around, make a new line, or whatever you like. Just make sure each emoji follows the same pattern of being surrounded by double-quotes, followed by a comma.

    The information needed to make the modification:

    • Keywords: [double quote] [emoji] [double quote] [comma] [space]. Follow this format.
    • Folder: LoopKit/LoopKitUI/CarbKit
    • File: FoodEmojiDataSource.swift
    • Lines: 16-23, 31-33, 41-42, 50-53

    Examples of where you may want to move some emojis:

    Move doughnut and pie to slow. Move pancakes, bread, chocolate, and milk to medium

    Examples of emojis you may want to add:

    Fast:
    "🧃", "🥭","🫐" ,"🧋"
    Medium:
    "🥯", "🥚", "🧇",
    Slow:
    "🧈",
    Other:
    "❓",

    You can copy/paste emojis from an emoji website, like https://getemoji.com/.

    Disable Suspend Beeps

    The pump-suspended interface is different for Loop 3. 

    Some people requested the ability to suspend a pump without reminder beeps on the pod. (This safety feature was added in Loop v2.2.6, but there are no controls to determine when that beeps begin or how frequently it beeps, i.e., every 5 minutes. It can be silenced in the Pod Settings display after the first beep when the Alarm shows up.)

    This customization permanently silences the reminder beep when suspending a pod.

    • Keyword: usePodSuspendedReminder
    • Folder: rileylink_ios / OmniKit / PumpManager
    • File:PodCommsSession.swift
    • Line: 574

    Original line:

         let usePodSuspendedReminder = suspendTime == 0 || suspendTime > .minutes(5) // untimed or long enough suspend

    Replacement code is shown below. If you click on one of these lines, both will be copied to your paste buffer. You will see Copied to Clipboard briefly.

         // let usePodSuspendedReminder = suspendTime == 0 || suspendTime > .minutes(5) // untimed or long enough suspend
         let usePodSuspendedReminder = false

    By overwriting the original line with these 2 lines, you commented out the original line by putting “//” at the beginning and added new line.

    Skip to content