Install on iOS
This guide walks through adding AFCore to your iOS app, configuring required capabilities, and preparing for App Store review.
Minimum Requirements
| Requirement | Version |
|---|---|
| Xcode | 15 or later |
| iOS deployment target | 14.0 or later |
| Swift | 5.9 or later |
Device features used by AFCore (enable only what your app requires): Location Services, Bluetooth LE (beacons), Motion and Fitness, HealthKit, Push Notifications.
Add the SDK
- Download or build
AFCore.xcframeworkfrom the latest release. - Drag it into your Xcode project navigator.
- In your app target's General tab, confirm it appears under Frameworks, Libraries, and Embedded Content. AFCore is a static framework -- set the embed option to Do Not Embed.
Xcode Capabilities
In Signing & Capabilities, enable only the capabilities your app needs:
- Background Modes
- Location updates -- required for geofencing.
- Remote notifications -- required for push.
- Uses Bluetooth LE accessories -- required for beacon proximity.
- Background fetch -- used by HealthKit background delivery.
- HealthKit -- required for step tracking (read access).
- Push Notifications -- required for FCM/APNs integration.
Info.plist Keys
Apple requires usage descriptions for each protected resource. App Review verifies these strings, so write clear, specific explanations:
<key>NSLocationWhenInUseUsageDescription</key>
<string>Your location helps us confirm gym visits and show nearby facilities.</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Background location access allows automatic gym visit tracking even when the app is closed.</string>
<key>NSHealthShareUsageDescription</key>
<string>This app reads your steps and activity data from Apple Health to track your wellness rewards.</string>
<key>NSMotionUsageDescription</key>
<string>Motion data supports activity insights and step counting for your fitness program.</string>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>Bluetooth detects nearby gym beacons for accurate facility check-ins.</string>
Initialize AFCore
Call AFCore.shared.initialize(config:) once during app launch -- typically in your App.init() (SwiftUI) or AppDelegate.application(_:didFinishLaunchingWithOptions:) (UIKit). This is the only setup step required. AFCore automatically:
- Restores SmartWalking -- If auto-sync was previously enabled, AFCore re-registers HealthKit background delivery and syncs steps immediately.
- Restores geofencing --
CLLocationManagerregion monitoring is managed by iOS at the system level. Monitored regions persist across app termination and reboots. AFCore re-initializes from persisted config when region events arrive.
SwiftUI
import SwiftUI
import AFCore
@main
struct MyApp: App {
init() {
do {
let config = AFCoreConfig.Builder()
.baseUrl(value: "https://api.example.com")
.clientId(value: "your-client-id")
.clientSecret(value: "your-client-secret")
.enableLogging(value: true)
.logLevel(value: AFLogLevel.verbose)
.build()
try AFCore.shared.initialize(config: config)
} catch {
// Initialization failure is unrecoverable.
// Log the error and present a meaningful message to the user.
print("AFCore initialization failed: \(error)")
}
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
UIKit
import UIKit
import AFCore
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
do {
let config = AFCoreConfig.Builder()
.baseUrl(value: "https://api.example.com")
.clientId(value: "your-client-id")
.clientSecret(value: "your-client-secret")
.enableLogging(value: true)
.logLevel(value: AFLogLevel.verbose)
.build()
try AFCore.shared.initialize(config: config)
} catch {
print("AFCore initialization failed: \(error)")
}
return true
}
}
Replace
baseUrl,clientId, andclientSecretwith the values provided by your Account Manager. Use the QA URL during development and switch to Production before release.
App Store Review Guidance
App Privacy (App Store Connect)
Declare the data types your app collects:
- Location -- precise, background (for geofencing and facility detection).
- Health and Fitness -- steps, distance, calories (read-only, for wellness rewards).
- Identifiers -- device ID (for push notification registration).
- Diagnostics -- crash and performance data (if applicable).
Background Location
- Provide a clear in-app disclosure screen explaining why background location is needed before requesting "Always Allow."
- Start with When In Use access. Upgrade to Always only after the user opts into presence-based features (geofencing, automatic gym visits).
- App Review may request a demo account and steps to reproduce background geofencing. Prepare these in advance.
HealthKit
- Explain in your App Review notes how health data is used (wellness program rewards, step tracking).
- Health data must not be used for advertising or shared with third parties without explicit consent.
General
- Link your Privacy Policy in App Store Connect.
- Test your submission with TestFlight before submitting for review.