A small SwiftUI application showing how to use the published Messagevisor Swift SDK in an iOS application.
The application downloads a production Messagevisor datafile, creates an SDK instance with the ICU module, and renders plain and formatted translations.
Learn more at messagevisor.com.
You need Xcode 16 or newer. The application targets iOS 14 or newer.
- Open
MessagevisorExampleIOS.xcodeprojin Xcode. - Wait for Swift Package Manager to resolve Messagevisor Swift 0.1.0.
- Select an iPhone simulator.
- Run the
MessagevisorExampleIOSscheme.
The application fetches this production datafile:
https://messagevisor-example-cloudflare-pages.pages.dev/production/messagevisor-mobile-en-US.json
The important SDK usage is in MessagevisorViewModel.swift:
let datafile = try DatafileContent.fromData(data)
let m = createMessagevisor(
MessagevisorOptions(
datafile: datafile,
timeZone: "America/New_York",
modules: [createICUModule()]
)
)
let signIn = try m.translate("auth.signin")
let contact = try m.translate(
"nav.contact",
values: ["closingTime": .date(closingTime)]
)The SDK instance is closed when the view disappears and before a refreshed datafile replaces the current instance.
GitHub Actions resolves the published SDK package and builds the application for a generic iOS Simulator destination without code signing.
Learn more in the Messagevisor Swift SDK documentation.