Skip to content

Repository files navigation

messagevisor-example-ios

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.

Requirements

You need Xcode 16 or newer. The application targets iOS 14 or newer.

Run the application

  1. Open MessagevisorExampleIOS.xcodeproj in Xcode.
  2. Wait for Swift Package Manager to resolve Messagevisor Swift 0.1.0.
  3. Select an iPhone simulator.
  4. Run the MessagevisorExampleIOS scheme.

Messagevisor usage

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.

Checks

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.

License

MIT

About

iOS example application using Messagevisor Swift SDK

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages