diff --git a/Jenkinsfile b/Jenkinsfile
index d43fb68..136be57 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -1,8 +1,10 @@
library "openiumpipeline"
-env.DEVELOPER_DIR="/Applications/Xcode-15.4.0.app/Contents/Developer"
-//env.SIMULATOR_DEVICE_TYPES="iPad--7th-generation-"
+env.DEVELOPER_DIR="/Applications/Xcode-16.3.0.app/Contents/Developer"
+// env.SIMULATOR_DEVICE_TYPES="iPhone-14-Pro"
+// env.SLACK_CHANNEL = "prj-skdevkit"
env.IS_PACKAGE_SWIFT=1
env.TARGETS_MACOS=1
+env.PACKAGE_NAME="ResgenSwift" // xcodebuild -list => Only 1 scheme
iOSpipeline()
diff --git a/SampleFiles/Fonts/Generated/test.plist b/SampleFiles/Fonts/Generated/test.plist
index 32c2b75..2033456 100644
--- a/SampleFiles/Fonts/Generated/test.plist
+++ b/SampleFiles/Fonts/Generated/test.plist
@@ -6,16 +6,16 @@
UIAppFonts
- Lato-Italic
- Lato-LightItalic
- Lato-Hairline
- Lato-Bold
- Lato-Black
- Lato-Regular
- Lato-BlackItalic
- Lato-BoldItalic
- Lato-Light
- Lato-HairlineItalic
+ Lato-Italic.ttf
+ Lato-LightItalic.ttf
+ Lato-Thin.ttf
+ Lato-Bold.ttf
+ Lato-Black.ttf
+ Lato-Regular.ttf
+ Lato-BlackItalic.ttf
+ Lato-BoldItalic.ttf
+ Lato-Light.ttf
+ Lato-ThinItalic.ttf
diff --git a/SampleFiles/Fonts/Generated/test2.plist b/SampleFiles/Fonts/Generated/test2.plist
index 32c2b75..2033456 100644
--- a/SampleFiles/Fonts/Generated/test2.plist
+++ b/SampleFiles/Fonts/Generated/test2.plist
@@ -6,16 +6,16 @@
UIAppFonts
- Lato-Italic
- Lato-LightItalic
- Lato-Hairline
- Lato-Bold
- Lato-Black
- Lato-Regular
- Lato-BlackItalic
- Lato-BoldItalic
- Lato-Light
- Lato-HairlineItalic
+ Lato-Italic.ttf
+ Lato-LightItalic.ttf
+ Lato-Thin.ttf
+ Lato-Bold.ttf
+ Lato-Black.ttf
+ Lato-Regular.ttf
+ Lato-BlackItalic.ttf
+ Lato-BoldItalic.ttf
+ Lato-Light.ttf
+ Lato-ThinItalic.ttf
diff --git a/SampleFiles/genAllRessources.sh b/SampleFiles/genAllRessources.sh
index 63c1949..425221d 100755
--- a/SampleFiles/genAllRessources.sh
+++ b/SampleFiles/genAllRessources.sh
@@ -3,12 +3,12 @@
FORCE_FLAG="$1"
## Font
-#swift run -c release ResgenSwift fonts $FORCE_FLAG "./Fonts/sampleFontsAll.txt" \
-# --extension-output-path "./Fonts/Generated" \
-# --extension-name "FontYolo" \
-# --extension-name-ui-kit "UIFontYolo" \
-# --extension-suffix "GenAllScript" \
-# --info-plist-paths "./Fonts/Generated/test.plist ./Fonts/Generated/test2.plist"
+swift run -c release ResgenSwift fonts $FORCE_FLAG "./Fonts/sampleFontsAll.txt" \
+ --extension-output-path "./Fonts/Generated" \
+ --extension-name "FontYolo" \
+ --extension-name-ui-kit "UIFontYolo" \
+ --extension-suffix "GenAllScript" \
+ --info-plist-paths "./Fonts/Generated/test.plist ./Fonts/Generated/test2.plist"
#
#echo "\n-------------------------\n"
#
diff --git a/Sources/ResgenSwift/Fonts/Fonts.swift b/Sources/ResgenSwift/Fonts/Fonts.swift
index fdcc166..e46a01a 100644
--- a/Sources/ResgenSwift/Fonts/Fonts.swift
+++ b/Sources/ResgenSwift/Fonts/Fonts.swift
@@ -43,22 +43,31 @@ struct Fonts: ParsableCommand {
let fontsToGenerate = FontFileParser.parse(options.inputFile)
// Get real font names
- let inputFolder = URL(fileURLWithPath: options.inputFile).deletingLastPathComponent().relativePath
- let fontsNames = FontsToolHelper.getFontPostScriptName(for: fontsToGenerate,
- inputFolder: inputFolder)
+ let inputFolder = URL(fileURLWithPath: options.inputFile)
+ .deletingLastPathComponent()
+ .relativePath
+
+ let fontsNames = FontsToolHelper.getFontPostScriptName(
+ for: fontsToGenerate,
+ inputFolder: inputFolder
+ )
// Generate extension
- FontExtensionGenerator.writeExtensionFile(fontsNames: fontsNames,
- staticVar: options.staticMembers,
- extensionName: options.extensionName,
- extensionFilePath: options.extensionFilePath,
- isSwiftUI: true)
+ FontExtensionGenerator.writeExtensionFile(
+ fontsNames: fontsNames,
+ staticVar: options.staticMembers,
+ extensionName: options.extensionName,
+ extensionFilePath: options.extensionFilePath,
+ isSwiftUI: true
+ )
- FontExtensionGenerator.writeExtensionFile(fontsNames: fontsNames,
- staticVar: options.staticMembers,
- extensionName: options.extensionNameUIKit,
- extensionFilePath: options.extensionFilePathUIKit,
- isSwiftUI: false)
+ FontExtensionGenerator.writeExtensionFile(
+ fontsNames: fontsNames,
+ staticVar: options.staticMembers,
+ extensionName: options.extensionNameUIKit,
+ extensionFilePath: options.extensionFilePathUIKit,
+ isSwiftUI: false
+ )
print("Info.plist has been updated with:")
print("\(FontPlistGenerator.generatePlistUIAppsFontContent(for: fontsNames, infoPlistPaths: options.infoPlistPaths))")
diff --git a/Sources/ResgenSwift/Fonts/FontsToolHelper.swift b/Sources/ResgenSwift/Fonts/FontsToolHelper.swift
index 02b3b8d..017278d 100644
--- a/Sources/ResgenSwift/Fonts/FontsToolHelper.swift
+++ b/Sources/ResgenSwift/Fonts/FontsToolHelper.swift
@@ -57,17 +57,26 @@ class FontsToolHelper {
return fontsFileNames
}
- private static func getFontName(atPath path: String) -> String {
+ private static func getFontName(atPath path: String) -> FontName {
//print("fc-scan --format %{postscriptname} \(path)")
// Get real font name
let task = Shell.shell(["fc-scan", "--format", "%{postscriptname}", path])
- guard let fontName = task.output, task.terminationStatus == 0 else {
+ guard let postscriptName = task.output, task.terminationStatus == 0 else {
let error = FontsToolError.fcScan(path, task.terminationStatus, task.output)
print(error.description)
Fonts.exit(withError: error)
}
-
- return fontName
+
+ let pathURL = URL(fileURLWithPath: path)
+ let filename = pathURL
+ .deletingPathExtension()
+ .lastPathComponent
+
+ return FontName(
+ postscriptName: postscriptName,
+ filename: filename,
+ fileExtension: pathURL.pathExtension
+ )
}
}
diff --git a/Sources/ResgenSwift/Fonts/Generator/FontPlistGenerator.swift b/Sources/ResgenSwift/Fonts/Generator/FontPlistGenerator.swift
index 37259c3..a9e5912 100644
--- a/Sources/ResgenSwift/Fonts/Generator/FontPlistGenerator.swift
+++ b/Sources/ResgenSwift/Fonts/Generator/FontPlistGenerator.swift
@@ -26,16 +26,16 @@ class FontPlistGenerator {
// Fill array with fonts
fontsToAddToPlist
- .forEach {
+ .forEach { fontName in
Shell.shell(launchPath: "/usr/libexec/PlistBuddy",
- ["-c", "add :UIAppFonts: string \($0)", infoPlist])
+ ["-c", "add :UIAppFonts: string \(fontName.filename).\(fontName.fileExtension)", infoPlist])
}
}
var plistData = "UIAppFonts\n\t\n"
fontsToAddToPlist
- .forEach {
- plistData += "\t\t\($0)\n"
+ .forEach { fontName in
+ plistData += "\t\t\(fontName.filename).\(fontName.fileExtension)\n"
}
plistData += "\t"
diff --git a/Sources/ResgenSwift/Fonts/Generator/FontToolContentGenerator.swift b/Sources/ResgenSwift/Fonts/Generator/FontToolContentGenerator.swift
index 6d9d228..cb52ca1 100644
--- a/Sources/ResgenSwift/Fonts/Generator/FontToolContentGenerator.swift
+++ b/Sources/ResgenSwift/Fonts/Generator/FontToolContentGenerator.swift
@@ -10,18 +10,18 @@ import ToolCore
class FontExtensionGenerator {
- private static func getFontNameEnum(fontsNames: [String]) -> String {
+ private static func getFontNameEnum(fontsNames: [FontName]) -> String {
var enumDefinition = " enum FontName: String {\n"
fontsNames.forEach {
- enumDefinition += " case \($0.fontNameSanitize) = \"\($0)\"\n"
+ enumDefinition += " case \($0.fontNameSanitize) = \"\($0.postscriptName)\"\n"
}
enumDefinition += " }\n"
return enumDefinition
}
- static func writeExtensionFile(fontsNames: [String],
+ static func writeExtensionFile(fontsNames: [FontName],
staticVar: Bool,
extensionName: String,
extensionFilePath: String,
@@ -43,7 +43,7 @@ class FontExtensionGenerator {
}
}
- static func getExtensionContent(fontsNames: [String],
+ static func getExtensionContent(fontsNames: [FontName],
staticVar: Bool,
extensionName: String,
isSwiftUI: Bool) -> String {
diff --git a/Sources/ResgenSwift/Fonts/Model/FontName.swift b/Sources/ResgenSwift/Fonts/Model/FontName.swift
index 39043f9..6feb518 100644
--- a/Sources/ResgenSwift/Fonts/Model/FontName.swift
+++ b/Sources/ResgenSwift/Fonts/Model/FontName.swift
@@ -7,11 +7,18 @@
import Foundation
-typealias FontName = String
+//typealias FontName = String
+
+struct FontName: Hashable {
+
+ let postscriptName: String
+ let filename: String
+ let fileExtension: String
+}
extension FontName {
var fontNameSanitize: String {
- self.removeCharacters(from: "[]+-_")
+ postscriptName.removeCharacters(from: "[]+-_")
}
func getProperty(isStatic: Bool, isSwiftUI: Bool) -> String {
diff --git a/Sources/ToolCore/Version.swift b/Sources/ToolCore/Version.swift
index b850b78..cdd646a 100644
--- a/Sources/ToolCore/Version.swift
+++ b/Sources/ToolCore/Version.swift
@@ -7,4 +7,4 @@
import Foundation
-public let ResgenSwiftVersion = "1.2"
+public let ResgenSwiftVersion = "2.1.0"
diff --git a/Tests/ResgenSwiftTests/Analytics/AnalyticsDefinitionTests.swift b/Tests/ResgenSwiftTests/Analytics/AnalyticsDefinitionTests.swift
index 756f79e..4ed4bbe 100644
--- a/Tests/ResgenSwiftTests/Analytics/AnalyticsDefinitionTests.swift
+++ b/Tests/ResgenSwiftTests/Analytics/AnalyticsDefinitionTests.swift
@@ -84,7 +84,7 @@ final class AnalyticsDefinitionTests: XCTestCase {
name: "Ecran un",
action: "",
category: "",
- params: []
+ params: [:]
)
}
"""
@@ -127,7 +127,7 @@ final class AnalyticsDefinitionTests: XCTestCase {
name: "Ecran un",
action: "",
category: "",
- params: []
+ params: [:]
)
}
"""
diff --git a/Tests/ResgenSwiftTests/Analytics/AnalyticsGeneratorTests.swift b/Tests/ResgenSwiftTests/Analytics/AnalyticsGeneratorTests.swift
index 7abe69f..6d98221 100644
--- a/Tests/ResgenSwiftTests/Analytics/AnalyticsGeneratorTests.swift
+++ b/Tests/ResgenSwiftTests/Analytics/AnalyticsGeneratorTests.swift
@@ -60,7 +60,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
let expect = """
// Generated by ResgenSwift.Analytics 1.2
- import Firebase
+ import FirebaseAnalytics
// MARK: - Protocol
@@ -79,7 +79,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
class FirebaseAnalyticsManager: AnalyticsManagerProtocol {
func logScreen(name: String, path: String) {
var parameters = [
- AnalyticsParameterScreenName: name
+ AnalyticsParameterScreenName: name as NSObject
]
Analytics.logEvent(
@@ -94,19 +94,25 @@ final class AnalyticsGeneratorTests: XCTestCase {
category: String,
params: [String: Any]?
) {
- var parameters: [String:Any] = [
- "action": action,
- "category": category,
+ var parameters: [String:NSObject] = [
+ "action": action as NSObject,
+ "category": category as NSObject,
]
-
+
if let supplementaryParameters = params {
- parameters.merge(supplementaryParameters) { (origin, new) -> Any in
- return origin
+ for (newKey, newValue) in supplementaryParameters {
+ if parameters.contains(where: { (key: String, value: NSObject) in
+ key == newKey
+ }) {
+ continue
+ }
+
+ parameters[newKey] = newValue as? NSObject
}
}
Analytics.logEvent(
- name,
+ name.replacingOccurrences(of: [" "], with: "_"),
parameters: parameters
)
}
@@ -135,7 +141,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
private func logScreen(name: String, path: String) {
guard isEnabled else { return }
-
+
managers.forEach { manager in
manager.logScreen(name: name, path: path)
}
@@ -173,7 +179,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
name: "s1 def two",
action: "",
category: "",
- params: []
+ params: [:]
)
}
@@ -366,7 +372,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
name: "s1 def two",
action: "test",
category: "test",
- params: []
+ params: [:]
)
}
@@ -419,7 +425,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
// Generated by ResgenSwift.Analytics 1.2
import MatomoTracker
- import Firebase
+ import FirebaseAnalytics
// MARK: - Protocol
@@ -499,7 +505,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
class FirebaseAnalyticsManager: AnalyticsManagerProtocol {
func logScreen(name: String, path: String) {
var parameters = [
- AnalyticsParameterScreenName: name
+ AnalyticsParameterScreenName: name as NSObject
]
Analytics.logEvent(
@@ -514,19 +520,25 @@ final class AnalyticsGeneratorTests: XCTestCase {
category: String,
params: [String: Any]?
) {
- var parameters: [String:Any] = [
- "action": action,
- "category": category,
+ var parameters: [String:NSObject] = [
+ "action": action as NSObject,
+ "category": category as NSObject,
]
-
+
if let supplementaryParameters = params {
- parameters.merge(supplementaryParameters) { (origin, new) -> Any in
- return origin
+ for (newKey, newValue) in supplementaryParameters {
+ if parameters.contains(where: { (key: String, value: NSObject) in
+ key == newKey
+ }) {
+ continue
+ }
+
+ parameters[newKey] = newValue as? NSObject
}
}
Analytics.logEvent(
- name,
+ name.replacingOccurrences(of: [" "], with: "_"),
parameters: parameters
)
}
@@ -599,7 +611,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
name: "s1 def two",
action: "test",
category: "test",
- params: []
+ params: [:]
)
}
diff --git a/Tests/ResgenSwiftTests/Fonts/FontExtensionGeneratorTests.swift b/Tests/ResgenSwiftTests/Fonts/FontExtensionGeneratorTests.swift
index 2093f09..5c2ec98 100644
--- a/Tests/ResgenSwiftTests/Fonts/FontExtensionGeneratorTests.swift
+++ b/Tests/ResgenSwiftTests/Fonts/FontExtensionGeneratorTests.swift
@@ -16,8 +16,8 @@ final class FontExtensionGeneratorTests: XCTestCase {
func test_uiKit_GeneratedExtensionContent() {
// Given
let fontNames: [FontName] = [
- "CircularStd-Regular",
- "CircularStd-Bold"
+ FontName(postscriptName: "CircularStd-Regular", filename: "CircularStd-Regular", fileExtension: "ttf"),
+ FontName(postscriptName: "CircularStd-Bold", filename: "CircularStd-Bold", fileExtension: "ttf")
]
// When
@@ -59,8 +59,8 @@ final class FontExtensionGeneratorTests: XCTestCase {
func test_swiftUI_GeneratedExtensionContent() {
// Given
let fontNames: [FontName] = [
- "CircularStd-Regular",
- "CircularStd-Bold"
+ FontName(postscriptName: "CircularStd-Regular", filename: "CircularStd-Regular", fileExtension: "ttf"),
+ FontName(postscriptName: "CircularStd-Bold", filename: "CircularStd-Bold", fileExtension: "ttf")
]
// When
diff --git a/Tests/ResgenSwiftTests/Fonts/FontNameTests.swift b/Tests/ResgenSwiftTests/Fonts/FontNameTests.swift
index 80f3883..0acc48c 100644
--- a/Tests/ResgenSwiftTests/Fonts/FontNameTests.swift
+++ b/Tests/ResgenSwiftTests/Fonts/FontNameTests.swift
@@ -14,8 +14,12 @@ final class FontNameTests: XCTestCase {
func test_uiKit_GeneratedProperty_noForbiddenCharacter() {
// Given
- let fontName: FontName = "CircularStdBold"
-
+ let fontName = FontName(
+ postscriptName: "CircularStdBold",
+ filename: "CircularStd-Bold",
+ fileExtension: "ttf"
+ )
+
// When
let property = fontName.getProperty(isStatic: true, isSwiftUI: false)
@@ -31,7 +35,11 @@ final class FontNameTests: XCTestCase {
func test_uiKit_GeneratedProperty_withForbiddenCharacter() {
// Given
- let fontName: FontName = "[Circular_Std+Bold-Underline]"
+ let fontName = FontName(
+ postscriptName: "[Circular_Std+Bold-Underline]",
+ filename: "Circular_Std+Bold-Underline",
+ fileExtension: "ttf"
+ )
// When
let property = fontName.getProperty(isStatic: true, isSwiftUI: false)
@@ -48,8 +56,12 @@ final class FontNameTests: XCTestCase {
func test_uiKit_GeneratedMethod_noForbiddenCharacter() {
// Given
- let fontName: FontName = "CircularStdBold"
-
+ let fontName = FontName(
+ postscriptName: "CircularStdBold",
+ filename: "CircularStd-Bold",
+ fileExtension: "ttf"
+ )
+
// When
let property = fontName.getProperty(isStatic: false, isSwiftUI: false)
@@ -65,8 +77,12 @@ final class FontNameTests: XCTestCase {
func test_uiKit_GeneratedMethod_withForbiddenCharacter() {
// Given
- let fontName: FontName = "[Circular_Std+Bold-Underline]"
-
+ let fontName = FontName(
+ postscriptName: "[Circular_Std+Bold-Underline]",
+ filename: "Circular_Std+Bold-Underline",
+ fileExtension: "ttf"
+ )
+
// When
let property = fontName.getProperty(isStatic: false, isSwiftUI: false)
@@ -82,8 +98,12 @@ final class FontNameTests: XCTestCase {
func test_swiftUI_GeneratedProperty_noForbiddenCharacter() {
// Given
- let fontName: FontName = "CircularStdBold"
-
+ let fontName = FontName(
+ postscriptName: "CircularStdBold",
+ filename: "CircularStd-Bold",
+ fileExtension: "ttf"
+ )
+
// When
let property = fontName.getProperty(isStatic: true, isSwiftUI: true)
@@ -99,8 +119,12 @@ final class FontNameTests: XCTestCase {
func test_swiftUI_GeneratedProperty_withForbiddenCharacter() {
// Given
- let fontName: FontName = "[Circular_Std+Bold-Underline]"
-
+ let fontName = FontName(
+ postscriptName: "[Circular_Std+Bold-Underline]",
+ filename: "Circular_Std+Bold-Underline",
+ fileExtension: "ttf"
+ )
+
// When
let property = fontName.getProperty(isStatic: true, isSwiftUI: true)
@@ -116,8 +140,12 @@ final class FontNameTests: XCTestCase {
func test_swiftUI_GeneratedMethod_noForbiddenCharacter() {
// Given
- let fontName: FontName = "CircularStdBold"
-
+ let fontName = FontName(
+ postscriptName: "CircularStdBold",
+ filename: "CircularStd-Bold",
+ fileExtension: "ttf"
+ )
+
// When
let property = fontName.getProperty(isStatic: false, isSwiftUI: true)
@@ -133,8 +161,12 @@ final class FontNameTests: XCTestCase {
func test_swiftUI_GeneratedMethod_withForbiddenCharacter() {
// Given
- let fontName: FontName = "[Circular_Std+Bold-Underline]"
-
+ let fontName = FontName(
+ postscriptName: "[Circular_Std+Bold-Underline]",
+ filename: "Circular_Std+Bold-Underline",
+ fileExtension: "ttf"
+ )
+
// When
let property = fontName.getProperty(isStatic: false, isSwiftUI: true)
diff --git a/Tests/ResgenSwiftTests/Fonts/FontPlistGeneratorTests.swift b/Tests/ResgenSwiftTests/Fonts/FontPlistGeneratorTests.swift
index 8c86ca5..a09236a 100644
--- a/Tests/ResgenSwiftTests/Fonts/FontPlistGeneratorTests.swift
+++ b/Tests/ResgenSwiftTests/Fonts/FontPlistGeneratorTests.swift
@@ -14,8 +14,8 @@ final class FontPlistGeneratorTests: XCTestCase {
func testGeneratedPlist() {
// Given
let fontNames: [FontName] = [
- "CircularStd-Regular",
- "CircularStd-Bold"
+ FontName(postscriptName: "CircularStd-Regular", filename: "CircularStd-Regular", fileExtension: "ttf"),
+ FontName(postscriptName: "CircularStd-Bold", filename: "CircularStd-Bold", fileExtension: "ttf")
]
// When
@@ -25,8 +25,8 @@ final class FontPlistGeneratorTests: XCTestCase {
let expect = """
UIAppFonts
- CircularStd-Regular
- CircularStd-Bold
+ CircularStd-Regular.ttf
+ CircularStd-Bold.ttf
"""
diff --git a/Tests/ResgenSwiftTests/Strings/TagsGeneratorTests.swift b/Tests/ResgenSwiftTests/Strings/TagsGeneratorTests.swift
index 561c70c..af34e68 100644
--- a/Tests/ResgenSwiftTests/Strings/TagsGeneratorTests.swift
+++ b/Tests/ResgenSwiftTests/Strings/TagsGeneratorTests.swift
@@ -57,12 +57,18 @@ final class TagsGeneratorTests: XCTestCase {
/// Translation in ium :
/// Some translation
+ ///
+ /// Comment :
+ /// No comment
var s1_def_one: String {
"Some translation"
}
/// Translation in ium :
/// Some translation
+ ///
+ /// Comment :
+ /// No comment
var s1_def_two: String {
"Some translation"
}
@@ -71,6 +77,9 @@ final class TagsGeneratorTests: XCTestCase {
/// Translation in ium :
/// Some translation
+ ///
+ /// Comment :
+ /// No comment
var s2_def_one: String {
"Some translation"
}