Open csknns opened 1 year ago
I believe Xcode 14 added support for exporting localizations.
@neonichu You are correct! I missed that in the release notes
You can now export local Swift packages for localization. Xcode generates a single localizations catalog for all projects and Swift packages contained in a project or workspace. You can also use xcodebuild -importLocalizations and xcodebuild -exportLocalizations to export or import a Swift package. (56355281)
(Although it would be better I think to have a swift command for this in order not to exclude non-macos platforms).
Should I close this?
In case this helps anyone else:
One detail I didn't realize at first is that you have to add the defaultLocalization:
to your Package()
initializer in your Package.swift
file. Otherwise, it doesn't think your package is localizable, and skips it.
let package = Package(
name: "MyLocalPakcages",
defaultLocalization: "en",
platforms: [
.iOS(.v15),
[…]
And then, in Xcode 14, the export fails because by default it tries to build with an old macOS SDK, which doesn't know about all the new SwiftUI stuff. So I had to add this to my Package.swift
file too:
platforms: [
.iOS(.v15), // or whatever you might have
.macOS("99.0"), // <-- This is the important part to get it to not build with the old macOS SDK
],
And then, in Xcode 14, the export fails because by default it tries to build with an old macOS SDK, which doesn't know about all the new SwiftUI stuff. So I had to add this to my
Package.swift
file too:platforms: [ .iOS(.v15), // or whatever you might have .macOS("99.0"), // <-- This is the important part to get it to not build with the old macOS SDK ],
Did you also have to conditionalise all UIKit etc. imports for this to work? When I try to do this with Xcode 15.1, exports still fail with an error about UIKit not being available on macOS
Description
In SwiftPM packages there is no way to export the localized resources in XLIFF format. The option "Export Localizations" in the Xcode editor is not available for SwiftPM packages. If I generate a corresponding Xcode project with the command
swift package generate-xcodeproj
it does not contain any localization data, it seems a bug, also the 'generate-xcodeproj' option as reported by the swift tool as: "is no longer needed and will be deprecated soon". Developing either a public library or a modular iOS/MacOS app using local SwiftPM package has the issue that you can not export the localizations in XLIFF format.It should support:
.proccess
rule) & custom Sources/ folder locationExpected behavior
No response
Actual behavior
No response
Steps to reproduce
No response
Swift Package Manager version/commit hash
Any
Swift & OS version (output of
swift --version && uname -a
)Any