Skip to content

Quickstart

This quickstart explains how to run the iOS SampleApp and validate a full WorkoutKit launch flow.

The public SDK entry points are GoModeController and GoVideoController. The sample app uses MonGoModeController and MonVideoGoController as local subclasses that override SDK callback methods for save, post-workout, and analytics behavior.

This sample flow is intended to validate connectivity and launch behavior. For production, use your own GraphQL client, backend authorization logic, and host-app callback handling; the sample app is a reference, not a required app architecture.

1. Open the sample project

Clone the iOS SDK repository and open the sample app in Xcode:

From Xcode, load the SampleApp target and ensure dependencies are resolved.

2. Install Apollo CLI in Xcode

Inside Xcode, right-click SampleApp in the left navigator and run Apollo > Install CLI, then authorize execution when prompted.

3. Configure GraphQL endpoint and auth for schema generation

Before running Apollo commands, update SampleApp/apollo-codegen-config.json:

  • Set endpointURL to the server URL provided by the WorkoutKit team.
  • Add X-Developer-Authorization-Key if your environment requires it for schema access.

4. Generate DemoCloud GraphQL models

Run these commands from the repository root:

bash
./apollo-ios-cli fetch-schema --path SampleApp/apollo-codegen-config.json
./apollo-ios-cli generate --path SampleApp/apollo-codegen-config.json

5. Configure runtime network settings

Update DemoCloudClient.swift with your runtime API endpoint and required authorization headers (if your platform requires them) in DemoHeadersAddingInterceptor.

swift
func intercept(request: URLRequest, next: @Sendable (URLRequest) async throws -> Apollo.HTTPResponse) async throws -> Apollo.HTTPResponse {
    var newRequest = request
    newRequest.addValue(WorkoutKitConfig.deviceId(), forHTTPHeaderField: "X-WorkoutKit-Device")
    // Add your Authorization header here when required.
    return try await next(newRequest)
}

6. Run the app and launch a workout

Build and run SampleApp from Xcode. In the app:

  1. Open the workout list.
  2. Select a workout.
  3. Confirm the payload retrieval.
  4. Launch the session.

The sample app automatically branches to MonGoModeController for classic workouts and MonVideoGoController for video workouts. In a production app, you can either instantiate GoModeController and GoVideoController directly or create your own subclasses when you need to override methods documented in iOS Controllers Reference.

swift
let controller: UIViewController
if response.data?.publicWorkoutSession.asWorkoutBlockSession != nil {
    controller = try await MonGoModeController(data: data, token: token)
} else {
    controller = try await MonVideoGoController(data: data, token: token)
}

controller.modalPresentationStyle = .fullScreen
present(controller, animated: true)

References