This guide walks you through adding GBGBridge to your iOS project, configuring it, and loading your first web-based identity journey.Documentation Index
Fetch the complete documentation index at: https://docs.go.gbgplc.com/llms.txt
Use this file to discover all available pages before exploring further.
Requirements
| Requirement | Minimum | Notes |
|---|---|---|
| iOS | 15.0 | Required for Swift concurrency and modern SwiftUI features |
| Swift | 5.9+ | Binary module stability ensures forward compatibility |
| Xcode | 15.0+ | Matches Swift 5.9 toolchain |
| Architecture | arm64 | Device and Simulator (arm64 + x86_64) slices included |
Installation
GBGBridge is distributed as a Swift Package. Use Swift Package Manager for most projects, or grab the XCFramework manually if you don’t use SPM.Swift Package Manager (recommended)
- In Xcode, go to File > Add Package Dependencies…
- Enter the GBGBridge package URL:
- Select the version rule, for example, Up to Next Major Version from
1.0.0. - Click Add Package.
- Ensure GBGBridge is added to your app target.
Manual XCFramework
If you prefer manual integration:- Download the
GBGBridge.xcframework.zipfrom the latest release. - Unzip the archive.
- Drag
GBGBridge.xcframeworkinto your Xcode project. - In your target’s General → Frameworks, Libraries, and Embedded Content, ensure GBGBridge is set to Embed & Sign.
Minimal Integration
1. Import the Framework
2. Initialize the Bridge Host
TheBridgeHost manages message routing between the WebView and your native code. The simplest way to create one is with a host version string:
3. Declare Capabilities via Typed Slots
BridgeHost exposes typed capability slots for well-known capture operations. Setting a handler on a slot declares support — no separate configuration step needed:
4. Display the Journey
UseBridgeWebView to load the web journey. It handles WebView creation, bootstrap script injection, and message handler registration automatically.
5. Run Your App
Build and run. The web journey loads inside the native WebView. When the journey sends acapability.query request, GBGBridge automatically responds with the capabilities derived from your typed slots — including which are supported and their permission state.
Alternative: Configuration-Based Initialization
If you need explicit control over the capability dictionary (e.g., for non-camera capabilities or constraints), use the configuration-based initializer:register(handler:) for custom BridgeCapabilityHandler implementations. See the Capability Handling Guide for details.
What Happens Under the Hood
WhenBridgeWebView creates the WebView, several things happen automatically:
- Bootstrap script injection: A JavaScript snippet is injected at document start that initializes
window.GBGBridgewith areceive()function. This ensures the bridge is available before the web content loads. - Message handler registration: The
BridgeHostregisters itself as the handler for thegbgBridgescript message channel. - Capability query handler: A built-in handler for the
capability.queryaction is registered. When usinginit(hostVersion:), the query response is built dynamically from typed slots and custom capabilities, including permission state metadata.
Required App Configuration
GBGBridge itself does not require anyInfo.plist entries or entitlements. However, depending on the capabilities you expose, your host app will need appropriate permissions:
| Capability | Info.plist Key | Example Value |
|---|---|---|
| Camera | NSCameraUsageDescription | ”Camera access is required for document capture.” |
| NFC | NSNFCReaderUsageDescription | ”NFC is used to read identity document chips.” |
| Photo Library | NSPhotoLibraryUsageDescription | ”Photo library access is used to select document images.” |
- Add the Near Field Communication Tag Reading capability in your target’s Signing & Capabilities.
- Include
com.apple.developer.nfc.readersession.formatsin your entitlements file.
Common Integration Pitfalls
A handful of issues catch most teams when first wiring up the bridge — wrong WebView setup, missing capability declarations, ATS rejecting non-HTTPS dev URLs, and malformed messages on the web side. The notes below explain what to check.WebView not receiving messages
Ensure you are usingBridgeWebView or BridgeWebViewConfigurator.configure(_:host:) — not a plain WKWebView. The bootstrap script and message handler must be set up before the page loads.
Capability query returns empty
If usinginit(hostVersion:): check that you set a handler on at least one typed slot, or registered a custom capability via registerCustomCapability(). If using init(configuration:): check that you passed capabilities in your BridgeConfiguration.
App Transport Security errors
If your journey URL uses a local development server (e.g.,http://localhost), add the following to your Info.plist:
Messages not decoding
GBGBridge expects messages in the Bridge Message Protocol format. If you see decode errors inlastError, verify that the web content is sending correctly structured JSON.
Next Steps
- Concepts — Understand the architecture and mental model
- Messaging Guide — Learn to send events and handle requests
- Capability Handling Guide — Register handlers for camera, NFC, and other capabilities
- API Reference — Detailed reference for every public symbol