A LoopKit PumpManager for Tandem Mobi, building on
pumpX2.
There is NO WARRANTY IMPLIED OR EXPRESSED DUE TO USE OF THIS SOFTWARE.
YOU ASSUME ALL RISK FOR ANY MALFUNCTIONS, BUGS, OR INSULIN DELIVERY ACTIONS.
TandemKit is NOT AFFILIATED WITH OR SUPPORTED by Tandem Diabetes or any other manufacturer.
It has not been officially approved for use by any regulatory body and is provided as a RESEARCH TOOL ONLY.
Trio links TandemKit.framework into the app and registers TandemPumpManager
in code. (Sources/TandemKitPlugin builds a Loop-style plugin bundle instead,
but nothing exercises that path today.)
-
Add TandemKit as a submodule at path
TandemKit, trackingdev:git submodule add -b dev git@github.com:jwoglom/tandemkit TandemKit
Add
TandemKit/TandemKit.xcodeprojtoTrio.xcworkspace. -
In the
Trioapp target, link and embedTandemKit.framework. -
In the same target, add the
ASN1andBigIntpackages under Frameworks, Libraries, and Embedded Content — see Package products and the host app. -
Register the pump manager in
Trio/Sources/APS/DeviceDataManager.swift:import TandemKit private let staticPumpManagers: [PumpManagerUI.Type] = [ // ... TandemPumpManager.self ] private let staticPumpManagersByIdentifier: [String: PumpManagerUI.Type] = [ // ... TandemPumpManager.pluginIdentifier: TandemPumpManager.self ]
-
Add a
.tandemcase toPumpConfig.PumpTypeinTrio/Sources/Modules/PumpConfig/PumpConfigDataFlow.swift. ItspluginIdentifieris"TandemPumpManager", the string its LoopKitAlerts carry. Then handle the case inPumpSetupView.swift:case .tandem: setupViewController = TandemPumpManager.setupViewController( initialSettings: initialSettings, bluetoothProvider: bluetoothManager, colorPalette: .default, allowDebugFeatures: true, prefersToSkipUserInteraction: false, allowedInsulinTypes: [.apidra, .humalog, .novolog, .fiasp, .lyumjev] )
Add the pump wherever Trio lists selectable pumps, e.g.
state.addPump(.tandem).
LoopKit is not a package dependency. The TandemKit target links
LoopKit.framework and LoopKitUI.framework out of BUILT_PRODUCTS_DIR, so
TandemKit cannot build on its own — another project in the same workspace has to
produce them. It must be the
loopandlearn fork that Trio uses.
Upstream LoopKit/LoopKit has no Pluggable, which TandemPumpManager
conforms to.
Everything else comes from SwiftPM, resolved by TandemKit.xcodeproj and pinned
in its Package.resolved: SwiftECC, BigInt, ASN1 and Digest.
Package.swift describes the source layout and resolves these, but cannot
compile the targets; see the comment at the top of the manifest. The Xcode
project is the supported build.
All four are automatic library products, so Xcode normally links them statically
into TandemKit.framework and the host app needs to do nothing.
That changes if a second framework in the workspace links one of the same
products. Xcode then rebuilds it as a generated dynamic framework
(ASN1_<hash>_PackageProduct.framework) so both clients share one copy. A
dynamic framework has to be embedded in the .app, and Xcode embeds only the
package products that the application target itself links. If the two
frameworks are the only ones linking it, nothing embeds it, and the app dies at
launch:
Library not loaded: @rpath/ASN1_<hash>_PackageProduct.framework/ASN1_<hash>_PackageProduct
Referenced from: .../Trio.app/Frameworks/AccuChekKit.framework/AccuChekKit
Termination Reason: DYLD 1 Library missing
Trio hits this, because loopandlearn/AccuChekKit links leif-ibsen/ASN1 too.
The fix is step 3 in the Trio instructions above, and it is correct whether Xcode ends up building the
product statically or dynamically. Re-check it whenever the set of products
TandemKit links changes, or a new framework starts linking one of them.