Skip to main content

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​

  1. Xcode → File → Add Package Dependencies…
  2. Repository URL: https://github.com/AdvantaHealth/AFCore.git
  3. Version: Up to Next Major from 1.12.1 (newer versions are on the releases page).
  4. 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:

FeatureSigning & CapabilitiesInfo.plist
Gym Visits (visit detection)Background Modes → Location updatesNSLocationWhenInUseUsageDescription, NSLocationAlwaysAndWhenInUseUsageDescription
SmartWalkingHealthKitNSHealthShareUsageDescription
Barcode check-in, Fit@Home--NSCameraUsageDescription
Motion permission--NSMotionUsageDescription
Push notificationsPush 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:

  1. Add com.advantahealth.afcore.outbox-flush to BGTaskSchedulerPermittedIdentifiers in Info.plist.
  2. Enable Background Modes → Background fetch.
  3. Call AFBackgroundTasks.shared.registerHandler() before application(_: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.