Add support for stringsdicts.

This commit is contained in:
Marek Fořt 2020-11-03 15:28:58 +01:00
parent 2aa7fb12b9
commit 119155db3a
8 changed files with 90 additions and 34 deletions

View File

@ -15,8 +15,8 @@
"repositoryURL": "https://github.com/IBM-Swift/BlueSignals",
"state": {
"branch": null,
"revision": "b7331c8bef913f5f8b3cffa6ecfcce679f7c2531",
"version": "1.0.21"
"revision": "1f6c49e186c8a4eeef87ba14f2f97b8646559d13",
"version": "1.0.200"
}
},
{
@ -51,8 +51,8 @@
"repositoryURL": "https://github.com/krzyzanowskim/CryptoSwift",
"state": {
"branch": null,
"revision": "39f08ac5269361a50c08ce1e2f41989bfc4b1ec8",
"version": "1.3.1"
"revision": "af1b58fc569bfde777462349b9f7314b61762be0",
"version": "1.3.2"
}
},
{
@ -78,8 +78,8 @@
"repositoryURL": "https://github.com/tid-kijyun/Kanna.git",
"state": {
"branch": null,
"revision": "609367a2cd84827a33383cf7923cb4fe8f69ee0a",
"version": "5.2.2"
"revision": "4a80ebe93b6966d5083394fcaaaff57a2fcec935",
"version": "5.2.3"
}
},
{
@ -87,8 +87,8 @@
"repositoryURL": "https://github.com/kishikawakatsumi/KeychainAccess.git",
"state": {
"branch": null,
"revision": "3d0ea2c0806791abcc5d7f0d9f62f1cfd4a7264d",
"version": "4.2.0"
"revision": "654d52d30f3dd4592e944c3e0bccb53178c992f6",
"version": "4.2.1"
}
},
{
@ -129,11 +129,11 @@
},
{
"package": "Stencil",
"repositoryURL": "https://github.com/stencilproject/Stencil",
"repositoryURL": "https://github.com/stencilproject/Stencil.git",
"state": {
"branch": "master",
"revision": "22440c53690c84603cea018a5204c0f1e770461d",
"version": null
"branch": null,
"revision": "94197b3adbbf926348ad8765476a158aa4e54f8a",
"version": "0.14.0"
}
},
{
@ -141,7 +141,7 @@
"repositoryURL": "https://github.com/fortmarek/StencilSwiftKit.git",
"state": {
"branch": "stable",
"revision": "33cf26bc68f3aced91cb810bc0a4e5ce445a140f",
"revision": "99ac008eb7026e40af7fc882d5788f5de6eda47e",
"version": null
}
},
@ -195,7 +195,7 @@
"repositoryURL": "https://github.com/fortmarek/SwiftGen",
"state": {
"branch": "stable",
"revision": "db5c510ab89be880b5d7f9d6d43a19faa5f172de",
"revision": "ef8d6b186a03622cec8d228b18f0e2b3bb20b81c",
"version": null
}
},
@ -231,8 +231,8 @@
"repositoryURL": "https://github.com/jpsim/Yams.git",
"state": {
"branch": null,
"revision": "81a65c4069c28011ee432f2858ba0de49b086677",
"version": "3.0.1"
"revision": "88caa2e6fffdbef2e91c2022d038576062042907",
"version": "4.0.0"
}
},
{

View File

@ -34,7 +34,7 @@ let package = Package(
.package(url: "https://github.com/apple/swift-log.git", .upToNextMajor(from: "1.4.0")),
.package(url: "https://github.com/thii/xcbeautify.git", .upToNextMajor(from: "0.8.1")),
.package(url: "https://github.com/krzyzanowskim/CryptoSwift", .upToNextMajor(from: "1.3.0")),
.package(url: "https://github.com/stencilproject/Stencil", .branch("master")),
.package(url: "https://github.com/stencilproject/Stencil.git", .upToNextMajor(from: "0.14.0")),
.package(url: "https://github.com/kishikawakatsumi/KeychainAccess.git", .upToNextMajor(from: "4.1.0")),
.package(url: "https://github.com/httpswift/swifter.git", .upToNextMajor(from: "1.5.0")),
.package(url: "https://github.com/apple/swift-tools-support-core", .upToNextMinor(from: "0.1.12")),

View File

@ -191,7 +191,7 @@ public final class SynthesizedResourceInterfaceProjectMapper: ProjectMapping {
case .strings:
var seen: Set<String> = []
return resourcesPaths
.filter { $0.extension == "strings" }
.filter { $0.extension == "strings" || $0.extension == "stringsdict" }
.filter { seen.insert($0.basename).inserted }
case .plists:
return resourcesPaths

View File

@ -34,8 +34,10 @@ final class SynthesizedResourceInterfaceProjectMapperTests: TuistUnitTestCase {
func test_map() throws {
// Given
synthesizedResourceInterfacesGenerator.renderStub = { _, _, paths in
let content = paths.last?.basename
return content ?? ""
let content = paths.map(\.basename).joined(separator: ", ")
print(paths)
print(content)
return content
}
let projectPath = try temporaryPath()
@ -43,7 +45,9 @@ final class SynthesizedResourceInterfaceProjectMapperTests: TuistUnitTestCase {
let aAssets = targetAPath.appending(component: "a.xcassets")
let aAsset = aAssets.appending(component: "asset")
let frenchStrings = targetAPath.appending(components: "fr.lproj", "aStrings.strings")
let frenchStringsDict = targetAPath.appending(components: "fr.lproj", "aStrings.stringsdict")
let englishStrings = targetAPath.appending(components: "en.lproj", "aStrings.strings")
let englishStringsDict = targetAPath.appending(components: "en.lproj", "aStrings.stringsdict")
let environmentPlist = targetAPath.appending(component: "Environment.plist")
let emptyPlist = targetAPath.appending(component: "Empty.plist")
let ttfFont = targetAPath.appending(component: "ttfFont.ttf")
@ -53,9 +57,13 @@ final class SynthesizedResourceInterfaceProjectMapperTests: TuistUnitTestCase {
try fileHandler.createFolder(aAssets)
try fileHandler.touch(aAsset)
try fileHandler.touch(frenchStrings)
try fileHandler.touch(frenchStringsDict)
try fileHandler.touch(englishStrings)
try fileHandler.touch(englishStringsDict)
try fileHandler.write("a", path: frenchStrings, atomically: true)
try fileHandler.write("a", path: frenchStringsDict, atomically: true)
try fileHandler.write("a", path: englishStrings, atomically: true)
try fileHandler.write("a", path: englishStringsDict, atomically: true)
try fileHandler.touch(emptyPlist)
try fileHandler.write("a", path: environmentPlist, atomically: true)
try fileHandler.write("a", path: ttfFont, atomically: true)
@ -67,7 +75,9 @@ final class SynthesizedResourceInterfaceProjectMapperTests: TuistUnitTestCase {
resources: [
.folderReference(path: aAssets),
.file(path: frenchStrings),
.file(path: frenchStringsDict),
.file(path: englishStrings),
.file(path: englishStringsDict),
.file(path: emptyPlist),
.file(path: environmentPlist),
.file(path: ttfFont),
@ -103,7 +113,7 @@ final class SynthesizedResourceInterfaceProjectMapperTests: TuistUnitTestCase {
.file(
FileDescriptor(
path: derivedSourcesPath.appending(component: "Strings+TargetA.swift"),
contents: "aStrings.strings".data(using: .utf8)
contents: "aStrings.strings, aStrings.stringsdict".data(using: .utf8)
)
),
.file(
@ -115,7 +125,7 @@ final class SynthesizedResourceInterfaceProjectMapperTests: TuistUnitTestCase {
.file(
FileDescriptor(
path: derivedSourcesPath.appending(component: "Fonts+TargetA.swift"),
contents: "ttcFont.ttc".data(using: .utf8)
contents: "ttfFont.ttf, otfFont.otf, ttcFont.ttc".data(using: .utf8)
)
),
]
@ -135,7 +145,7 @@ final class SynthesizedResourceInterfaceProjectMapperTests: TuistUnitTestCase {
SourceFile(path: derivedSourcesPath
.appending(component: "Strings+TargetA.swift"),
compilerFlags: nil,
contentHash: try contentHasher.hash("aStrings.strings".data(using: .utf8)!)),
contentHash: try contentHasher.hash("aStrings.strings, aStrings.stringsdict".data(using: .utf8)!)),
SourceFile(path: derivedSourcesPath
.appending(component: "Environment.swift"),
compilerFlags: nil,
@ -143,7 +153,7 @@ final class SynthesizedResourceInterfaceProjectMapperTests: TuistUnitTestCase {
SourceFile(path: derivedSourcesPath
.appending(component: "Fonts+TargetA.swift"),
compilerFlags: nil,
contentHash: try contentHasher.hash("ttcFont.ttc".data(using: .utf8)!)),
contentHash: try contentHasher.hash("ttfFont.ttf, otfFont.otf, ttcFont.ttc".data(using: .utf8)!)),
],
resources: targetA.resources
),

View File

@ -15,6 +15,7 @@ let project = Project(
"Resources/*.xcassets",
"Resources/**/*.txt",
"Resources/**/*.strings",
"Resources/**/*.stringsdict",
"Resources/**/*.plist",
"Resources/**/*.otf",
"Resources/resource_without_extension",

View File

@ -0,0 +1,22 @@
<?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>apple_count</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@inner@</string>
<key>inner</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>d</string>
<key>one</key>
<string>%d apple</string>
<key>other</key>
<string>%d apples</string>
</dict>
</dict>
</dict>
</plist>

View File

@ -0,0 +1,22 @@
<?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>apple_count</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@inner@</string>
<key>inner</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>d</string>
<key>one</key>
<string>%d pomme</string>
<key>other</key>
<string>%d pommes</string>
</dict>
</dict>
</dict>
</plist>

View File

@ -23,6 +23,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
print("Main bundle image: \(String(describing: UIImage(named: "tuist")))")
print("Asset catalogue image: \(String(describing: AppAsset.assetCatalogLogo.image))")
print("Strings: \(AppStrings.Greetings.morning)")
print("String dicts: \(AppStrings.App.appleCount(1))")
print("Font: \(AppFontFamily.SFProDisplay.bold.name)")
print("StaticFrameworkResource image: \(String(describing: staticFrameworkResources.tuist))")
print("StaticFramework2Resource image: \(String(describing: staticFramework2Resources.loadImage()))")