Swift Package manifest property 'defaultLocalization' not set
Asked Answered
A

1

8

Experimenting with Swift Packages, I created a new package. Source files and resources from an existing Xcode project framework target were moved over into the new structure.

Attempting to build, the transcript shows an error:

manifest property 'defaultLocalization' not set; it is required in the presence of localized resources

How can this be solved so I can create a Swift package?

Adieu answered 7/6, 2021 at 12:49 Comment(0)
A
27

This is explained in WWDC2020 session 10169.

At around eleven and a half minutes into the video, Anders Bertelrud, Apple engineer Developer Tools introduces the topic. An example is shown using Xcode 12 to add a default localisation parameter to the package manifest.

This declares the language I'm using during development and will be used as the fallback localization at runtime if no better match is available. This is needed for any package that contains resources.

An example manifest including the defaultLocalization parameter can be seen as follows:

// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "MyPackageUI",
    defaultLocalization: "en",
    platforms: [
        .iOS(.v13)
    ],
    products: [
        .library(
            name: "MyPackageUI",
            targets: ["MyPackageUI"]),
    ],
    targets: [
        .target(
            name: "MyPackageUI",
            dependencies: []),
        .testTarget(
            name: "MyPackageUITests",
            dependencies: ["MyPackageUI"]),
   ]
)
Adieu answered 7/6, 2021 at 12:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.