Install on iOS
AFCore for iOS and watchOS is an XCFramework distributed as a Swift Package from AdvantaHealth/AFCore. It supports iOS 15+ and watchOS 9+ and builds with Xcode 15 or later. The framework embeds its Apple privacy manifest (PrivacyInfo.xcprivacy).
1. Add the package
- Xcode → File → Add Package Dependencies…
- Repository URL:
https://github.com/AdvantaHealth/AFCore.git - Version: Up to Next Major from 1.12.1 (newer versions are on the releases page).
- Add the AFCore product to your app target.
Or, in a Package.swift:
.package(url: "https://github.com/AdvantaHealth/AFCore.git", from: "1.12.1")
Upgrading from 1.11? Read Upgrading to 1.12 first.
2. Initialize at launch
Initialize once, synchronously, in App.init() or application(_:didFinishLaunchingWithOptions:), so the SDK is also ready when iOS relaunches the app in the background for a visit or a location update:
import AFCore
do {
let config = AFCoreConfig.Builder()
.baseUrl(value: "https://api.example.com")
.realm(value: .bismuth) // .horizon if your members are on Horizon
.enableLogging(value: true)
.build()
try AFCore.shared.initialize(config: config)
} catch {
print("AFCore initialization failed: \(error)")
}
See Initialization for the options.
3. Capabilities and Info.plist
Enable only what your features use:
| Feature | Signing & Capabilities | Info.plist |
|---|---|---|
| Gym Visits (visit detection) | Background Modes → Location updates | NSLocationWhenInUseUsageDescription, NSLocationAlwaysAndWhenInUseUsageDescription |
| SmartWalking | HealthKit | NSHealthShareUsageDescription |
| Barcode check-in, Fit@Home | -- | NSCameraUsageDescription |
| Motion permission | -- | NSMotionUsageDescription |
| Push notifications | Push Notifications, Background Modes → Remote notifications | -- |
App Review reads the usage strings, so explain plainly why each permission helps the member.
4. Background tasks (offline delivery)
If your app uses visit detection, self-reports, barcode check-ins or Fit@Home selfies, let AFCore deliver submissions captured offline while the app is suspended:
- Add
com.advantahealth.afcore.outbox-flushtoBGTaskSchedulerPermittedIdentifiersinInfo.plist. - Enable Background Modes → Background fetch.
- Call
AFBackgroundTasks.shared.registerHandler()beforeapplication(_:didFinishLaunchingWithOptions:)returns.
Without this, pending submissions are still delivered when the app is next opened or the connection returns. Android needs no setup.
Optional: AFCoreUI for SwiftUI
The published package ships the AFCore product only. The optional AFCoreUI SwiftUI library is consumed as a local Swift package for now.
Learn more
See the API Reference. Complete integration guides are in AIDE Docs.