Optional generation of extension (R.xx)

Optional generation of Colors/Fonts/Images/Stringium extension

Fix swiftlint warning
This commit is contained in:
2025-07-17 09:39:43 +02:00
parent c3b8ebfb37
commit 3092376b65
34 changed files with 973 additions and 688 deletions

View File

@ -131,7 +131,7 @@ struct ColorsConfiguration: Codable, CustomDebugStringConvertible {
let inputFile: String
let style: String
let xcassetsPath: String
let extensionOutputPath: String
let extensionOutputPath: String?
let extensionName: String?
let extensionNameUIKit: String?
let extensionSuffix: String?
@ -148,7 +148,7 @@ struct ColorsConfiguration: Codable, CustomDebugStringConvertible {
inputFile: String,
style: String,
xcassetsPath: String,
extensionOutputPath: String,
extensionOutputPath: String?,
extensionName: String?,
extensionNameUIKit: String?,
extensionSuffix: String?,
@ -170,7 +170,7 @@ struct ColorsConfiguration: Codable, CustomDebugStringConvertible {
- Input file: \(inputFile)
- Style: \(style)
- Xcassets path: \(xcassetsPath)
- Extension output path: \(extensionOutputPath)
- Extension output path: \(extensionOutputPath ?? "-")
- Extension name: \(extensionName ?? "-")
- Extension name UIKit: \(extensionNameUIKit ?? "-")
- Extension suffix: \(extensionSuffix ?? "-")
@ -181,7 +181,7 @@ struct ColorsConfiguration: Codable, CustomDebugStringConvertible {
struct FontsConfiguration: Codable, CustomDebugStringConvertible {
let inputFile: String
let extensionOutputPath: String
let extensionOutputPath: String?
let extensionName: String?
let extensionNameUIKit: String?
let extensionSuffix: String?
@ -197,7 +197,7 @@ struct FontsConfiguration: Codable, CustomDebugStringConvertible {
internal init(
inputFile: String,
extensionOutputPath: String,
extensionOutputPath: String?,
extensionName: String?,
extensionNameUIKit: String?,
extensionSuffix: String?,
@ -217,7 +217,7 @@ struct FontsConfiguration: Codable, CustomDebugStringConvertible {
"""
Fonts configuration:
- Input file: \(inputFile)
- Extension output path: \(extensionOutputPath)
- Extension output path: \(extensionOutputPath ?? "-")
- Extension name: \(extensionName ?? "-")
- Extension name UIKit: \(extensionNameUIKit ?? "-")
- Extension suffix: \(extensionSuffix ?? "-")
@ -230,7 +230,7 @@ struct ImagesConfiguration: Codable, CustomDebugStringConvertible {
let inputFile: String
let xcassetsPath: String
let extensionOutputPath: String
let extensionOutputPath: String?
let extensionName: String?
let extensionNameUIKit: String?
let extensionSuffix: String?
@ -246,7 +246,7 @@ struct ImagesConfiguration: Codable, CustomDebugStringConvertible {
internal init(
inputFile: String,
xcassetsPath: String,
extensionOutputPath: String,
extensionOutputPath: String?,
extensionName: String?,
extensionNameUIKit: String?,
extensionSuffix: String?,
@ -266,7 +266,7 @@ struct ImagesConfiguration: Codable, CustomDebugStringConvertible {
Images configuration:
- Input file: \(inputFile)
- Xcassets path: \(xcassetsPath)
- Extension output path: \(extensionOutputPath)
- Extension output path: \(extensionOutputPath ?? "-")
- Extension name: \(extensionName ?? "-")
- Extension name UIKit: \(extensionNameUIKit ?? "-")
- Extension suffix: \(extensionSuffix ?? "-")
@ -280,7 +280,7 @@ struct StringsConfiguration: Codable, CustomDebugStringConvertible {
let outputPath: String
let langs: String
let defaultLang: String
let extensionOutputPath: String
let extensionOutputPath: String?
let extensionName: String?
let extensionSuffix: String?
private let staticMembers: Bool?
@ -305,7 +305,7 @@ struct StringsConfiguration: Codable, CustomDebugStringConvertible {
outputPath: String,
langs: String,
defaultLang: String,
extensionOutputPath: String,
extensionOutputPath: String?,
extensionName: String?,
extensionSuffix: String?,
staticMembers: Bool?,
@ -329,7 +329,7 @@ struct StringsConfiguration: Codable, CustomDebugStringConvertible {
- Output path: \(outputPath)
- Langs: \(langs)
- Default lang: \(defaultLang)
- Extension output path: \(extensionOutputPath)
- Extension output path: \(extensionOutputPath ?? "-")
- Extension name: \(extensionName ?? "-")
- Extension suffix: \(extensionSuffix ?? "-")
"""

View File

@ -27,29 +27,23 @@ extension ColorsConfiguration: Runnable {
style,
"--xcassets-path",
xcassetsPath.prependIfRelativePath(projectDirectory),
"--extension-output-path",
extensionOutputPath.prependIfRelativePath(projectDirectory),
"--static-members",
"\(staticMembersOptions)"
]
if let extensionName {
args += [
"--extension-name",
extensionName
]
}
if let extensionNameUIKit {
args += [
"--extension-name-ui-kit",
extensionNameUIKit
]
}
if let extensionSuffix {
args += [
"--extension-suffix",
extensionSuffix
]
// Add optional parameters
[
("--extension-output-path", extensionOutputPath?.prependIfRelativePath(projectDirectory)),
("--extension-name", extensionName),
("--extension-name-ui-kit", extensionNameUIKit),
("--extension-suffix", extensionSuffix)
].forEach { argumentName, argumentValue in
if let argumentValue {
args += [
argumentName,
argumentValue
]
}
}
return args

View File

@ -23,32 +23,26 @@ extension FontsConfiguration: Runnable {
args += [
inputFile.prependIfRelativePath(projectDirectory),
"--extension-output-path",
extensionOutputPath.prependIfRelativePath(projectDirectory),
"--static-members",
"\(staticMembersOptions)"
]
if let extensionName {
args += [
"--extension-name",
extensionName
]
}
if let extensionNameUIKit {
args += [
"--extension-name-ui-kit",
extensionNameUIKit
]
}
if let extensionSuffix {
args += [
"--extension-suffix",
extensionSuffix
]
// Add optional parameters
[
("--extension-output-path", extensionOutputPath?.prependIfRelativePath(projectDirectory)),
("--extension-name", extensionName),
("--extension-name-ui-kit", extensionNameUIKit),
("--extension-suffix", extensionSuffix)
].forEach { argumentName, argumentValue in
if let argumentValue {
args += [
argumentName,
argumentValue
]
}
}
// Add infoPlist paths
if let infoPlistPaths {
let adjustedPlistPaths = infoPlistPaths
.split(separator: " ")

View File

@ -25,31 +25,23 @@ extension ImagesConfiguration: Runnable {
inputFile.prependIfRelativePath(projectDirectory),
"--xcassets-path",
xcassetsPath.prependIfRelativePath(projectDirectory),
"--extension-output-path",
extensionOutputPath.prependIfRelativePath(projectDirectory),
"--static-members",
"\(staticMembersOptions)"
]
if let extensionName {
args += [
"--extension-name",
extensionName
]
}
if let extensionNameUIKit {
args += [
"--extension-name-ui-kit",
extensionNameUIKit
]
}
if let extensionSuffix {
args += [
"--extension-suffix",
extensionSuffix
]
// Add optional parameters
[
("--extension-output-path", extensionOutputPath?.prependIfRelativePath(projectDirectory)),
("--extension-name", extensionName),
("--extension-name-ui-kit", extensionNameUIKit),
("--extension-suffix", extensionSuffix)
].forEach { argumentName, argumentValue in
if let argumentValue {
args += [
argumentName,
argumentValue
]
}
}
return args

View File

@ -24,26 +24,24 @@ extension StringsConfiguration: Runnable {
langs,
"--default-lang",
defaultLang,
"--extension-output-path",
extensionOutputPath.prependIfRelativePath(projectDirectory),
"--static-members",
"\(staticMembersOptions)",
"--xc-strings",
"\(xcStringsOptions)"
]
if let extensionName {
args += [
"--extension-name",
extensionName
]
}
if let extensionSuffix {
args += [
"--extension-suffix",
extensionSuffix
]
// Add optional parameters
[
("--extension-output-path", extensionOutputPath?.prependIfRelativePath(projectDirectory)),
("--extension-name", extensionName),
("--extension-suffix", extensionSuffix)
].forEach { argumentName, argumentValue in
if let argumentValue {
args += [
argumentName,
argumentValue
]
}
}
Stringium.main(args)