Код: Выделить всё
// swift-tools-version: 6.2
import PackageDescription
let package = Package(
name: "Library",
defaultLocalization: "en",
platforms: [
.iOS(.v26),
.watchOS(.v26),
.macOS(.v26),
],
products: [
.library(name: "Localisation", targets: ["Localisation"]),
.library(name: "FeatureA", targets: ["FeatureA"]),
],
targets: [
.target(
name: "Localisation",
path: "Sources/Localisation",
sources: ["Sources"],
resources: [
.process("Resources/Localizable.xcstrings")
]
),
.target(
name: "FeatureA",
dependencies: [
"Localisation",
],
path: "Sources/Features/FeatureA",
sources: ["Sources"]
),
]
)
Код: Выделить всё
cd /Users/andrew/Library/Developer/Xcode/DerivedData/MY_PROJECT_REDACTED/Index.noindex/Build/Intermediates.noindex/Library.build/Debug-iphonesimulator/Localisation.build/DerivedSources/
cat GeneratedStringSymbols_Localizable.swift
< /code>
Я вижу < /p>
//
// GeneratedStringSymbols_Localizable.swift
// Auto-Generated symbols for localized strings defined in “Localizable.xcstrings”.
//
import Foundation
#if SWIFT_PACKAGE
private let resourceBundle = Foundation.Bundle.module
@available(macOS 13, iOS 16, tvOS 16, watchOS 9, *)
private let resourceBundleDescription = LocalizedStringResource.BundleDescription.atURL(resourceBundle.bundleURL)
#else
private class ResourceBundleClass {}
@available(macOS 13, iOS 16, tvOS 16, watchOS 9, *)
private let resourceBundleDescription = LocalizedStringResource.BundleDescription.forClass(ResourceBundleClass.self)
#endif
@available(macOS 13, iOS 16, tvOS 16, watchOS 9, *)
extension LocalizedStringResource {
/**
Localized string for key “close” in table “Localizable.xcstrings”.
*/
static var close: LocalizedStringResource {
LocalizedStringResource("close", table: "Localizable", bundle: resourceBundleDescription)
}
/**
Localized string for key “confirm” in table “Localizable.xcstrings”.
*/
static var confirm: LocalizedStringResource {
LocalizedStringResource("confirm", table: "Localizable", bundle: resourceBundleDescription)
}
}
< /code>
, что здорово, и он работает локально в модуле. Но уровень доступа делает его невозможным, и я не могу получить доступ к этим символам в других модулях.extension LocalizedStringResource {
public enum General {
public static let close: LocalizedStringResource = .close
public static let confirm: LocalizedStringResource = .confirm
}
}
Подробнее здесь: https://stackoverflow.com/questions/796 ... os-26-xcod