Skip to main content

Setup

To configure iOS SDK integration you need to:

Distribution is a CDN vault that mirrors the translated content of your project and is required for integration with iOS app.

info
  • The download of translations happens asynchronously after the start of the application. The downloaded translations will be used the next time the app is launched, otherwise the previously cached translations will be used (or local translations if no cache exists).
  • The CDN feature does not update the localization files, if you want to add new translations to the localization files, you need to do it yourself.
  • Once the SDK receives the translations, they're stored on the device as application files for future sessions to minimize requests the next time the app is launched. The storage time can be configured using the intervalUpdatesEnabled option.
  • CDN will cache all translations in the release for up to 1 hour and even if new translations are released in Crowdin, CDN may return them with a delay.

Swift

Open the AppDelegate.swift file and add:

import CrowdinSDK

In the application method add:

let crowdinProviderConfig = CrowdinProviderConfig(hashString: "{distribution_hash}",
sourceLanguage: "{source_language}")

CrowdinSDK.startWithConfig(crowdinSDKConfig, completion: {
// SDK is ready to use, put code to change language, etc. here
})

Objective-C

In the AppDelegate.m add:

@import CrowdinSDK

or

#import<CrowdinSDK/CrowdinSDK.h>

In the application method add:

CrowdinProviderConfig *crowdinProviderConfig = [[CrowdinProviderConfig alloc] initWithHashString:@"" sourceLanguage:@""];
CrowdinSDKConfig *config = [[[CrowdinSDKConfig config] withCrowdinProviderConfig:crowdinProviderConfig]];

[CrowdinSDK startWithConfig:config completion:^{
// SDK is ready to use, put code to change language, etc. here
}];

If you have a pure Objective-C project, you will need to take some additional steps:

Add the following code to your Library Search Paths:

  1. Add to Library Search Paths:

    $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)
  2. Add use_frameworks! to your Podfile.

Alternative Setup: Info.plist

You can also configure basic SDK settings in Info.plist:

  1. Add these keys to Info.plist:

    • CrowdinDistributionHash (String) - Your Crowdin CDN hash
    • CrowdinSourceLanguage (String) - Source language code in ISO 639-1 format
  2. In AppDelegate call:

    • Swift: CrowdinSDK.start()
    • Objective-C: [CrowdinSDK start]
caution

Using the Info.plist setup method, you cannot configure Screenshots and Real-Time Preview features.

Additional Features

Translations Update Interval

By default, SDK searches for new translation once per application load, but not more often than 15 minutes. You can update translations in application every defined interval. To enable this feature add pod CrowdinSDK/IntervalUpdate to your pod file:

  1. Add to Podfile:

    pod 'CrowdinSDK/IntervalUpdate'
  2. Configure in SDK:

    .with(intervalUpdatesEnabled: true, interval: {interval})

    Where interval - defines translations update time interval in seconds. Minimum allowed interval is 15 minutes (900 seconds).

Change locale programmatically

By default, the SDK relies on the device locale. To change the SDK target language on the fly regardless of the device locale, use the following method:

CrowdinSDK.enableSDKLocalization(true, localization: "<language_code>")

Where <language_code> is the target language in ISO 639-1 format.

SwiftUI Support

SwiftUI support requires explicit localization calls. Use either:

Text(NSLocalizedString("key", comment: "comment"))

or the convenience extension:

Text("key".cw_localized)

View the Swift UI Localization guide for more information.

Apple Strings Catalog Support

The Crowdin SDK supports the Apple Strings Catalog (.xcstrings) format out of the box. It doesn't require any additional setup. Just upload your localization files to Crowdin, set up the distribution and start using the SDK.

caution

Only the CDN Content Delivery feature is available for the Apple Strings Catalog format. The Screenshots and Real-Time Preview features are not yet supported.

Config Options Reference

OptionDescriptionExample Value
hashStringDistribution Hash"7a0c1...o3b"
sourceLanguageSource language code (ISO 639-1)sourceLanguage: "en"
organizationNameOrganization domain (Enterprise only)"mycompany"
settingsEnabledEnable SDK Controlstrue
accessTokenCrowdin API access token"your_token"

OAuth Options

OptionDescriptionExample Value
clientIdOAuth Client ID"gpY2yT...x3TYB"
clientSecretOAuth Client Secret"Xz95t...EDx9T"
scopeOAuth scope (e.g., "project.screenshot", "project")"project"
redirectURICustom URL scheme for your app"crowdintest://"