Installation & Setup

Learn how to use the Localazy Swift SDK for seamless localization of your iOS and macOS projects. To see the Swift SDK in action, you can check our demo project here.

πŸ“¦ Swift Package Manager πŸ”—

Swift SDK for iOS and macOS is distributed with the Swift Package Manager as a binary package.

Add this URL to Swift Packages in your Project file (Xcode 12 and upwards).

https://github.com/localazy/localazy-swift

Minimum target:

  • iOS 13
  • macOS 10.15

πŸ‘· Manual installation πŸ”—

To install the Localazy SDK manually, copy Localazy.xcframework into your project root (Xcode) and add it to the Frameworks, Libraries and Embedded Content section.

βš™οΈ Setup πŸ”—

In your code you can import Localazy by adding:

#if os(macOS)
import Localazy_macOS
#else
import Localazy_iOS
#endif

πŸ’» macOS πŸ”—

For macOS targets, you need to ensure Outgoing connections (Client) and Disable Library Validation entitlement is checked in Signing & Capabilities (App Sandbox) section.

πŸŽ› Configuration πŸ”—

To configure Swift SDK for iOS and macOS create and set up the Localazy.plist configuration file. You can start by copying the example below to your Xcode project.

Localazy.plist options

Key Type Description Default
readKey String Your Localazy read key. (Can be retrieved from settings.) null
tag String Release tag to be used to fetch translations. latest
statistics Dictionary Statistics configuration dictionary allows Localazy to optimize its behaviour and prioritize translations. (see table below) -

statistics dictionary options

Key Type Description Default
statsEnabled Boolean Should the library send stats true
updateInterval Number Update interval in ms 86400
updateIntervalForFailure Number Update interval for failure in ms 14400
statsInterval Number Send stats interval in ms 86400
statsIntervalForFailure Number Send stats interval for failure in ms 14400
updateDelay Number Update delay in ms 0
statsDelay Number Stats delay in ms 0
minimalStatsSize Number Minimal stats size in bytes 2048
maximumStatsSize Number Maximum stats size in bytes 262144
sendStatsRegularly Boolean Send stats regularly false

Example configuration file (Localazy.plist)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>readKey</key>
  <string>Your-Read-Key</string>
  <key>tag</key>
  <string>Your-Tag</string>
  <key>updateInterval</key>
  <integer>3600</integer>
  <key>statistics</key>
  <dict>
	  <key>statsEnabled</key>
	  <true/>
	  <key>sendStatsRegularly</key>
	  <true/>
	  <key>statsInterval</key>
	  <integer>900</integer>
  </dict>
</dict>
</plist>

πŸ€– Automatic strings upload πŸ”—

You can ensure that your local strings are uploaded on every build by creating a new Run Script Phase for your target:

localazy upload

For more info check Quick Start iOS – Localazy CLI & File Format iOS/macOS