A Swift SDK for integrating with the YouVersion Platform, to display Bible content and implement user authentication in iOS, iPadOS, and other platforms where Swift can run.
- Features
- Requirements
- Installation
- Getting Started
- Usage
- Sample App
- For Different Use Cases
- Documentation
- Contributing
- Support
- License
- π Scripture Display - Easy-to-use SwiftUI components for displaying Bible verses with
BibleTextViewandBibleCardView - π Bible Reader - A complete Bible reading experience inside your app with
BibleReaderView - π User Authentication - Seamless "Sign In with YouVersion" integration using
SignInWithYouVersionButton - π
Verse of the Day - Built-in
VotdViewcomponent and API access to VOTD data
- iOS 17+ / iPadOS 17+
- A YouVersion Platform API key (Register here)
- In Xcode, open your app project, then select the menu File β Add Package Dependencies
- Enter the package URL:
https://github.com/youversion/platform-sdk-swift.git - Select
platform-sdk-swiftfrom the search results. - Click Add Package
- Click Add Package on the next dialog.
Or add it to your Package.swift file:
dependencies: [
.package(url: "https://github.com/youversion/platform-sdk-swift.git", from: "0.1.0")
]Add the following to your Podfile:
pod 'YouVersionPlatform', '~> 1.0'Then run pod install
- Get Your App Key: Register your app with YouVersion Platform to acquire an app key
- Configure the SDK: Add the following to your app's initialization:
import SwiftUI
import YouVersionPlatform
@main
struct YourApp: App {
init() {
YouVersionPlatform.configure(appKey: "YOUR_APP_KEY_HERE")
}
var body: some Scene {...
}
Display a single verse:
import YouVersionPlatform
struct DemoView: View {
var body: some View {
BibleTextView(
BibleReference(versionId: 3034, bookUSFM: "JHN", chapter: 3, verse: 16)
)
}
}Display a verse range:
import YouVersionPlatform
struct DemoView: View {
var body: some View {
BibleTextView(
BibleReference(versionId: 3034, bookUSFM: "JHN", chapter: 3, verseStart: 16, verseEnd: 20)
)
}
}Or display a full chapter:
import YouVersionPlatform
struct DemoView: View {
var body: some View {
BibleTextView(
BibleReference(versionId: 3034, bookUSFM: "JHN", chapter: 3)
)
}
}Note: For longer passages, wrap
BibleTextViewin aScrollView.
The SDK automatically fetches Scripture from YouVersion servers and maintains a local cache for improved performance.
Displays a full Bible reading experience, very similar to the YouVersion Bible app, ready to be added as a tab in your app.
BibleReaderView(
appName: "Sample App",
signInMessage: "Sign in to see your YouVersion highlights in this Sample App."
)First, create a helper class for presentation context:
import AuthenticationServices
class ContextProvider: NSObject, ASWebAuthenticationPresentationContextProviding {
func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor {
guard let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
let window = scene.windows.first else {
return ASPresentationAnchor()
}
return window
}
}In the header of your SwiftUI view, store a strong reference to the ContextProvider:
@State private var contextProvider = ContextProvider() // Store a strong referenceAdd the "Sign In" button to your SwiftUI view:
SignInWithYouVersionButton {
Task {
do {
let result = try await YouVersionAPI.Users.signIn(
permissions: [.profile, .email],
contextProvider: contextProvider
)
// The user is logged in and you have an access token at result.accessToken!
// You may now call the YouVersion Platform APIs which require authentication.
} catch {
print(error)
}
}
}
}Note: The SDK stores the access token locally, and persists it across app launches. Deleting or losing the access token is the equivalent of "logging out".
Retrieve information about the authenticated user:
// Implementation TBD - this information will be included in response tokens in the future.Use the built-in VOTD component:
import YouVersionPlatform
struct ContentView: View {
var body: some View {
VotdView()
}
}Or fetch VOTD data for custom UI:
let dayOfYear = Calendar.current.ordinality(of: .day, in: .year, for: Date())!
let votd = try await YouVersionAPI.VOTD.verseOfTheDay(dayOfYear: dayOfYear)
// Use votd.reference with BibleTextViewExplore the Examples directory for a complete sample app demonstrating:
- Scripture display with various reference types
- User authentication flows
- VOTD integration
- Best practices for token storage
To run the sample app:
- Open
platform-sdk-swiftdirectory in Xcode - Select the
SampleAppscheme - Build and run on simulator or device
Building an iOS or iPadOS application? This Swift SDK provides native SwiftUI components including BibleTextView, VotdView, and SignInWithYouVersionButton with full Swift Package Manager support and modern async/await APIs.
Need direct access to YouVersion Platform APIs? See our comprehensive API documentation for advanced integration patterns and REST endpoints.
Building AI applications with Bible content? Access YouVersion's LLM-optimized endpoints and structured data designed for language models. See our LLM documentation for details.
- API Documentation - Complete API reference
- LLM Integration Guide - AI/ML integration docs
- Sample Code - Working examples and best practices
We welcome contributions! Please see our Contributing Guide for details on development setup, code style, and the pull request process.
- Issues: GitHub Issues
- Questions: Open a discussion
- Platform Support: YouVersion Platform
This SDK is licensed under the Apache License 2.0. See LICENSE for details.
Made with β€οΈ by YouVersion
