diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..057f45c
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,63 @@
+SHELL = /bin/zsh
+
+#INSTALL_DIR ?= /usr/local/bin
+INSTALL_DIR = /tmp/ResgenYolo
+
+MAN_DIR := /usr/local/share/man
+MAN_PAGE_NAME = resgen-swift.1
+REPO_DIR = $(shell pwd)
+BUILD_DIR = $(REPO_DIR)/.build
+
+#
+# Man pages
+#
+
+# create-man-files:
+# swift package plugin generate-manual
+# cp $(BUILDDIR)/plugins/GenerateManualPlugin/outputs/ResgenSwift/resgen-swift.1 $(REPODIR)/man/resgen-swift.1
+
+# install-man-files:
+# mkdir -p ${DESTDIR}${mandir}/man1
+# cp $(REPODIR)/man/resgen-swift.1 ${DESTDIR}${mandir}/man1/resgen-swift.1
+
+create-and-install-man-files:
+ swift package plugin generate-manual
+ mkdir -p ${MAN_DIR}/man1
+ cp $(BUILD_DIR)/plugins/GenerateManualPlugin/outputs/ResgenSwift/${MAN_PAGE_NAME} ${MAN_DIR}/man1/${MAN_PAGE_NAME}
+
+#
+# Build and install
+#
+
+build-debug:
+ @swift build \
+ -c debug \
+ --build-path "$(BUILD_DIR)"
+
+build-release:
+ @swift build \
+ -c release \
+ --build-path "$(BUILD_DIR)"
+
+.PHONY: install
+install: build-release
+ @install -d "$(INSTALL_DIR)"
+ @install "$(wildcard $(BUILD_DIR)/**/release/ResgenSwift)" "$(INSTALL_DIR)/resgen-swift"
+ @make create-and-install-man-files
+
+#
+# Uninstall and cleaning
+#
+
+.PHONY: uninstall
+uninstall:
+ @rm -rf "$(INSTALL_DIR)/resgen-swift"
+ @rm -rf ${MAN_DIR}/man1/${MAN_PAGE_NAME}
+
+.PHONY: clean
+distclean:
+ @rm -f $(BUILD_DIR)/release
+
+.PHONY: clean
+clean: distclean
+ @rm -rf $(BUILD_DIR)
diff --git a/Package.resolved b/Package.resolved
index 1646468..6373e5f 100644
--- a/Package.resolved
+++ b/Package.resolved
@@ -1,25 +1,23 @@
{
- "object": {
- "pins": [
- {
- "package": "swift-argument-parser",
- "repositoryURL": "https://github.com/apple/swift-argument-parser",
- "state": {
- "branch": null,
- "revision": "e1465042f195f374b94f915ba8ca49de24300a0d",
- "version": "1.0.2"
- }
- },
- {
- "package": "Yams",
- "repositoryURL": "https://github.com/jpsim/Yams.git",
- "state": {
- "branch": null,
- "revision": "01835dc202670b5bb90d07f3eae41867e9ed29f6",
- "version": "5.0.1"
- }
+ "pins" : [
+ {
+ "identity" : "swift-argument-parser",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/apple/swift-argument-parser",
+ "state" : {
+ "revision" : "9f39744e025c7d377987f30b03770805dcb0bcd1",
+ "version" : "1.1.4"
}
- ]
- },
- "version": 1
+ },
+ {
+ "identity" : "yams",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/jpsim/Yams.git",
+ "state" : {
+ "revision" : "01835dc202670b5bb90d07f3eae41867e9ed29f6",
+ "version" : "5.0.1"
+ }
+ }
+ ],
+ "version" : 2
}
diff --git a/README.md b/README.md
index d8c9624..e139b43 100644
--- a/README.md
+++ b/README.md
@@ -6,8 +6,9 @@ ResgenSwift is a package, fully written in Swift, to help you automatize ressour
## Fonts
-Font generator generates an extension of `UIFont` (or a custom class). It also prints `UIAppFonts` to put in your project `.plist`.
-iOS required to use the **real name** of the font, this name can be different from its filename. To get the **real name**, it uses `fc-scan`.
+Font generator generates an extension of `UIFont` and `Font` (or custom classes). It also prints content of `UIAppFonts` from your project `.plist`. If project `.plist` is specified, it will update `UIAppFonts` content of all `.plist`.
+
+iOS required to use the **real name** of the font, this name can be different from its filename. To get the **real name**, it uses `fc-scan`. So, be sure that the `$PATH` contains path of `fc-scan`.
**Example**
@@ -15,8 +16,10 @@ iOS required to use the **real name** of the font, this name can be different fr
swift run -c release ResgenSwift fonts $FORCE_FLAG "./Fonts/fonts.txt" \
--extension-output-path "./Fonts/Generated" \
--extension-name "AppFont" \
+ --extension-name-swift-ui "SUIAppFont" \
--extension-suffix "GreatApp" \
- --static-members true
+ --static-members true \
+ --info-plist-paths "./path/one/to/Info.plist ./path/two/to/Info.plist"
```
**Parameters**
@@ -24,9 +27,11 @@ swift run -c release ResgenSwift fonts $FORCE_FLAG "./Fonts/fonts.txt" \
1. `-f`: force generation
2. Font input folder, it will search for every `.ttf` and `.otf` files specified in `fonts.txt`
3. `--extension-output-path`: path where to generate generated extension
-4. `--extension-name` *(optional)* : name of thee class to add the extension
-5. `--extension-suffix` *(optional)* : additional text which is added to the filename (ex: `AppFont+GreatApp.swift`)
-6. `--static-members` *(optional)*: generate static properties or not
+4. `--extension-name` *(optional)* : name of the class to add UIKit getters
+5. `--extension-name-swift-ui` *(optional)* : name of the class to add SwiftUI getters
+6. `--extension-suffix` *(optional)* : additional text which is added to the filename (ex: `AppFont+GreatApp.swift`)
+7. `--static-members` *(optional)*: generate static properties or not
+8. `--info-plist-paths` *(optional)*: array of `.plist`, you can specify multiple `Info.plist` for multiple targets
## Colors
@@ -39,6 +44,7 @@ swift run -c release ResgenSwift colors $FORCE_FLAG "./Colors/colors.txt" \
--xcassets-path "./Colors/colors.xcassets" \
--extension-output-path "./Colors/Generated/" \
--extension-name "AppColor" \
+ --extension-name-swift-ui "SUIAppColor" \
--extension-suffix "GreatApp" \
--static-members true
```
@@ -49,9 +55,10 @@ swift run -c release ResgenSwift colors $FORCE_FLAG "./Colors/colors.txt" \
2. Input colors file
3. `--style` can be `all` or `light`
4. `--extension-output-path`: path where to generate generated extension
-5. `--extension-name` *(optional)* : name of class to add the extension
-6. `--extension-suffix` *(optional)* : additional text which is added to filename (ex: `AppColor+GreatApp.swift`)
-7. `--static-members` *(optional)*: generate static properties or not
+5. `--extension-name` *(optional)* : name of the class to add UIKit getters
+6. `--extension-name-swift-ui` *(optional)* : name of the class to add SwiftUI getters
+7. `--extension-suffix` *(optional)* : additional text which is added to filename (ex: `AppColor+GreatApp.swift`)
+8. `--static-members` *(optional)*: generate static properties or not
## Strings
@@ -135,6 +142,7 @@ swift run -c release ResgenSwift images $FORCE_FLAG "./Images/images.txt" \
--xcassets-path "./Images/app.xcassets" \
--extension-output-path "./Images/Generated" \
--extension-name "AppImage" \
+ --extension-name-swift-ui "SUIAppImage" \
--extension-suffix "GreatApp" \
--static-members true
```
@@ -145,7 +153,8 @@ swift run -c release ResgenSwift images $FORCE_FLAG "./Images/images.txt" \
2. Input images definitions file
3. `--xcassets-path`: xcasset path where to generate imagesets
4. `--extension-output-path`: path where to generate generated extension
-5. `--extension-name` *(optional)* : name of class to add the extension
+5. `--extension-name` *(optional)* : name of the class to add UIKit getters
+6. `--extension-name-swift-ui` *(optional)* : name of the class to add SwiftUI getters
6. `--extension-suffix` *(optional)* : additional text which is added to filename (ex: `AppImage+GreatApp.swift`)
7. `--static-members` *(optional)*: generate static properties or not
@@ -167,6 +176,7 @@ colors:
xcassetsPath: String
extensionOutputPath: String
extensionName: String?
+ extensionNameSwiftUI: String?
extensionSuffix: String?
staticMembers: Bool?
@@ -175,15 +185,18 @@ fonts:
inputFile: String
extensionOutputPath: String
extensionName: String?
+ extensionNameSwiftUI: String?
extensionSuffix: String?
staticMembers: Bool?
-
+ infoPlistPaths: [String]
+
images:
-
inputFile: String
xcassetsPath: String
extensionOutputPath: String
extensionName: String?
+ extensionNameSwiftUI: String?
extensionSuffix: String?
staticMembers: Bool?
@@ -223,6 +236,7 @@ colors:
xcassetsPath: String
extensionOutputPath: String
extensionName: String?
+ extensionNameSwiftUI: String?
extensionSuffix: String?
staticMembers: Bool?
-
@@ -231,6 +245,7 @@ colors:
xcassetsPath: String
extensionOutputPath: String
extensionName: String?
+ extensionNameSwiftUI: String?
extensionSuffix: String?
staticMembers: Bool?
...
@@ -263,4 +278,4 @@ Example:
```sh
ResgenSwift generate path/to/configuration.yml --project-directory ${PROJECT_DIR}
-```
\ No newline at end of file
+```
diff --git a/SampleFiles/Colors/Generated/ColorYolo+GenAllScript.swift b/SampleFiles/Colors/Generated/ColorYolo+GenAllScript.swift
new file mode 100644
index 0000000..adf6ece
--- /dev/null
+++ b/SampleFiles/Colors/Generated/ColorYolo+GenAllScript.swift
@@ -0,0 +1,21 @@
+// Generated by ResgenSwift.Color 1.0
+
+import SwiftUI
+
+extension ColorYolo {
+
+ /// Color red is #FF0000 (light) or #FF0000 (dark)"
+ var red: Color {
+ Color("red")
+ }
+
+ /// Color green_alpha_50 is #A000FF00 (light) or #A000FF00 (dark)"
+ var green_alpha_50: Color {
+ Color("green_alpha_50")
+ }
+
+ /// Color blue_light_dark is #0000FF (light) or #0000AA (dark)"
+ var blue_light_dark: Color {
+ Color("blue_light_dark")
+ }
+}
\ No newline at end of file
diff --git a/SampleFiles/Colors/Generated/UIColor+Color.swift b/SampleFiles/Colors/Generated/UIColor+Color.swift
deleted file mode 100644
index 76d0ed0..0000000
--- a/SampleFiles/Colors/Generated/UIColor+Color.swift
+++ /dev/null
@@ -1,21 +0,0 @@
-// Generated from ColorToolCore at 2021-12-20 15:16:18 +0000
-
-import UIKit
-
-extension UIColor {
-
- /// Color red is #FF0000 (light) or #FF0000 (dark)"
- static var red: UIColor {
- UIColor(named: "red")!
- }
-
- /// Color green_alpha_50 is #A000FF00 (light) or #A000FF00 (dark)"
- static var green_alpha_50: UIColor {
- UIColor(named: "green_alpha_50")!
- }
-
- /// Color blue_light_dark is #0000FF (light) or #0000AA (dark)"
- static var blue_light_dark: UIColor {
- UIColor(named: "blue_light_dark")!
- }
-}
\ No newline at end of file
diff --git a/SampleFiles/Colors/Generated/UIColor+ColorGenAllScript.swift b/SampleFiles/Colors/Generated/UIColor+ColorGenAllScript.swift
deleted file mode 100644
index 23713af..0000000
--- a/SampleFiles/Colors/Generated/UIColor+ColorGenAllScript.swift
+++ /dev/null
@@ -1,21 +0,0 @@
-// Generated from ColorToolCore at 2022-02-14 09:30:19 +0000
-
-import UIKit
-
-extension UIColor {
-
- /// Color red is #FF0000 (light) or #FF0000 (dark)"
- static var red: UIColor {
- UIColor(named: "red")!
- }
-
- /// Color green_alpha_50 is #A000FF00 (light) or #A000FF00 (dark)"
- static var green_alpha_50: UIColor {
- UIColor(named: "green_alpha_50")!
- }
-
- /// Color blue_light_dark is #0000FF (light) or #0000AA (dark)"
- static var blue_light_dark: UIColor {
- UIColor(named: "blue_light_dark")!
- }
-}
\ No newline at end of file
diff --git a/SampleFiles/Colors/Generated/UIColor+ColorSampleApp.swift b/SampleFiles/Colors/Generated/UIColor+ColorSampleApp.swift
deleted file mode 100644
index 473f1c9..0000000
--- a/SampleFiles/Colors/Generated/UIColor+ColorSampleApp.swift
+++ /dev/null
@@ -1,21 +0,0 @@
-// Generated from ColorToolCore at 2021-12-20 15:17:10 +0000
-
-import UIKit
-
-extension UIColor {
-
- /// Color red is #FF0000 (light) or #FF0000 (dark)"
- static var red: UIColor {
- UIColor(named: "red")!
- }
-
- /// Color green_alpha_50 is #A000FF00 (light) or #A000FF00 (dark)"
- static var green_alpha_50: UIColor {
- UIColor(named: "green_alpha_50")!
- }
-
- /// Color blue_light_dark is #0000FF (light) or #0000AA (dark)"
- static var blue_light_dark: UIColor {
- UIColor(named: "blue_light_dark")!
- }
-}
\ No newline at end of file
diff --git a/SampleFiles/Colors/Generated/UIColor+GenAllScript.swift b/SampleFiles/Colors/Generated/UIColor+GenAllScript.swift
deleted file mode 100644
index b86c911..0000000
--- a/SampleFiles/Colors/Generated/UIColor+GenAllScript.swift
+++ /dev/null
@@ -1,21 +0,0 @@
-// Generated by ResgenSwift.ColorTool 1.0.0
-
-import UIKit
-
-extension UIColor {
-
- /// Color red is #FF0000 (light) or #FF0000 (dark)"
- static var red: UIColor {
- UIColor(named: "red")!
- }
-
- /// Color green_alpha_50 is #A000FF00 (light) or #A000FF00 (dark)"
- static var green_alpha_50: UIColor {
- UIColor(named: "green_alpha_50")!
- }
-
- /// Color blue_light_dark is #0000FF (light) or #0000AA (dark)"
- static var blue_light_dark: UIColor {
- UIColor(named: "blue_light_dark")!
- }
-}
\ No newline at end of file
diff --git a/SampleFiles/Colors/Generated/R2Color+Color.swift b/SampleFiles/Colors/Generated/UIColorYolo+GenAllScript.swift
similarity index 72%
rename from SampleFiles/Colors/Generated/R2Color+Color.swift
rename to SampleFiles/Colors/Generated/UIColorYolo+GenAllScript.swift
index 1d10e7b..5fedca1 100644
--- a/SampleFiles/Colors/Generated/R2Color+Color.swift
+++ b/SampleFiles/Colors/Generated/UIColorYolo+GenAllScript.swift
@@ -1,8 +1,8 @@
-// Generated from ColorToolCore at 2021-12-20 15:34:55 +0000
+// Generated by ResgenSwift.Color 1.0
import UIKit
-extension R2Color {
+extension UIColorYolo {
/// Color red is #FF0000 (light) or #FF0000 (dark)"
@objc var red: UIColor {
@@ -14,7 +14,7 @@ extension R2Color {
UIColor(named: "green_alpha_50")!
}
- /// Color blue_light_dark is #0000FF (light) or #0000FF (dark)"
+ /// Color blue_light_dark is #0000FF (light) or #0000AA (dark)"
@objc var blue_light_dark: UIColor {
UIColor(named: "blue_light_dark")!
}
diff --git a/SampleFiles/Fonts/Generated/FontYolo+GenAllScript.swift b/SampleFiles/Fonts/Generated/FontYolo+GenAllScript.swift
new file mode 100644
index 0000000..de0aa9c
--- /dev/null
+++ b/SampleFiles/Fonts/Generated/FontYolo+GenAllScript.swift
@@ -0,0 +1,61 @@
+// Generated by ResgenSwift.Fonts 1.0
+
+import SwiftUI
+
+extension FontYolo {
+
+ enum FontName: String {
+ case LatoItalic = "Lato-Italic"
+ case LatoLightItalic = "Lato-LightItalic"
+ case LatoHairline = "Lato-Hairline"
+ case LatoBold = "Lato-Bold"
+ case LatoBlack = "Lato-Black"
+ case LatoRegular = "Lato-Regular"
+ case LatoBlackItalic = "Lato-BlackItalic"
+ case LatoBoldItalic = "Lato-BoldItalic"
+ case LatoLight = "Lato-Light"
+ case LatoHairlineItalic = "Lato-HairlineItalic"
+ }
+
+ // MARK: - Getter
+
+ func LatoItalic(withSize size: CGFloat) -> Font {
+ Font.custom(FontName.LatoItalic.rawValue, size: size)
+ }
+
+ func LatoLightItalic(withSize size: CGFloat) -> Font {
+ Font.custom(FontName.LatoLightItalic.rawValue, size: size)
+ }
+
+ func LatoHairline(withSize size: CGFloat) -> Font {
+ Font.custom(FontName.LatoHairline.rawValue, size: size)
+ }
+
+ func LatoBold(withSize size: CGFloat) -> Font {
+ Font.custom(FontName.LatoBold.rawValue, size: size)
+ }
+
+ func LatoBlack(withSize size: CGFloat) -> Font {
+ Font.custom(FontName.LatoBlack.rawValue, size: size)
+ }
+
+ func LatoRegular(withSize size: CGFloat) -> Font {
+ Font.custom(FontName.LatoRegular.rawValue, size: size)
+ }
+
+ func LatoBlackItalic(withSize size: CGFloat) -> Font {
+ Font.custom(FontName.LatoBlackItalic.rawValue, size: size)
+ }
+
+ func LatoBoldItalic(withSize size: CGFloat) -> Font {
+ Font.custom(FontName.LatoBoldItalic.rawValue, size: size)
+ }
+
+ func LatoLight(withSize size: CGFloat) -> Font {
+ Font.custom(FontName.LatoLight.rawValue, size: size)
+ }
+
+ func LatoHairlineItalic(withSize size: CGFloat) -> Font {
+ Font.custom(FontName.LatoHairlineItalic.rawValue, size: size)
+ }
+}
\ No newline at end of file
diff --git a/SampleFiles/Fonts/Generated/R2Font+Font.swift b/SampleFiles/Fonts/Generated/R2Font+Font.swift
deleted file mode 100644
index 59b1101..0000000
--- a/SampleFiles/Fonts/Generated/R2Font+Font.swift
+++ /dev/null
@@ -1,62 +0,0 @@
-// Generated from FontToolCore
-
-import UIKit
-
-extension R2Font {
-
- enum FontName: String {
- case LatoItalic = "Lato-Italic"
- case LatoLightItalic = "Lato-LightItalic"
- case LatoHairline = "Lato-Hairline"
- case LatoBold = "Lato-Bold"
- case LatoBlack = "Lato-Black"
- case LatoRegular = "Lato-Regular"
- case LatoBlackItalic = "Lato-BlackItalic"
- case LatoBoldItalic = "Lato-BoldItalic"
- case LatoLight = "Lato-Light"
- case LatoHairlineItalic = "Lato-HairlineItalic"
- }
-
- // MARK: - Getter
-
- func LatoItalic(withSize size: CGFloat) -> UIFont {
- UIFont(name: FontName.LatoItalic.rawValue, size: size)!
- }
-
- func LatoLightItalic(withSize size: CGFloat) -> UIFont {
- UIFont(name: FontName.LatoLightItalic.rawValue, size: size)!
- }
-
- func LatoHairline(withSize size: CGFloat) -> UIFont {
- UIFont(name: FontName.LatoHairline.rawValue, size: size)!
- }
-
- func LatoBold(withSize size: CGFloat) -> UIFont {
- UIFont(name: FontName.LatoBold.rawValue, size: size)!
- }
-
- func LatoBlack(withSize size: CGFloat) -> UIFont {
- UIFont(name: FontName.LatoBlack.rawValue, size: size)!
- }
-
- func LatoRegular(withSize size: CGFloat) -> UIFont {
- UIFont(name: FontName.LatoRegular.rawValue, size: size)!
- }
-
- func LatoBlackItalic(withSize size: CGFloat) -> UIFont {
- UIFont(name: FontName.LatoBlackItalic.rawValue, size: size)!
- }
-
- func LatoBoldItalic(withSize size: CGFloat) -> UIFont {
- UIFont(name: FontName.LatoBoldItalic.rawValue, size: size)!
- }
-
- func LatoLight(withSize size: CGFloat) -> UIFont {
- UIFont(name: FontName.LatoLight.rawValue, size: size)!
- }
-
- func LatoHairlineItalic(withSize size: CGFloat) -> UIFont {
- UIFont(name: FontName.LatoHairlineItalic.rawValue, size: size)!
- }
-
-}
\ No newline at end of file
diff --git a/SampleFiles/Fonts/Generated/R2Font+FontGenAllScript.swift b/SampleFiles/Fonts/Generated/R2Font+FontGenAllScript.swift
deleted file mode 100644
index 59b1101..0000000
--- a/SampleFiles/Fonts/Generated/R2Font+FontGenAllScript.swift
+++ /dev/null
@@ -1,62 +0,0 @@
-// Generated from FontToolCore
-
-import UIKit
-
-extension R2Font {
-
- enum FontName: String {
- case LatoItalic = "Lato-Italic"
- case LatoLightItalic = "Lato-LightItalic"
- case LatoHairline = "Lato-Hairline"
- case LatoBold = "Lato-Bold"
- case LatoBlack = "Lato-Black"
- case LatoRegular = "Lato-Regular"
- case LatoBlackItalic = "Lato-BlackItalic"
- case LatoBoldItalic = "Lato-BoldItalic"
- case LatoLight = "Lato-Light"
- case LatoHairlineItalic = "Lato-HairlineItalic"
- }
-
- // MARK: - Getter
-
- func LatoItalic(withSize size: CGFloat) -> UIFont {
- UIFont(name: FontName.LatoItalic.rawValue, size: size)!
- }
-
- func LatoLightItalic(withSize size: CGFloat) -> UIFont {
- UIFont(name: FontName.LatoLightItalic.rawValue, size: size)!
- }
-
- func LatoHairline(withSize size: CGFloat) -> UIFont {
- UIFont(name: FontName.LatoHairline.rawValue, size: size)!
- }
-
- func LatoBold(withSize size: CGFloat) -> UIFont {
- UIFont(name: FontName.LatoBold.rawValue, size: size)!
- }
-
- func LatoBlack(withSize size: CGFloat) -> UIFont {
- UIFont(name: FontName.LatoBlack.rawValue, size: size)!
- }
-
- func LatoRegular(withSize size: CGFloat) -> UIFont {
- UIFont(name: FontName.LatoRegular.rawValue, size: size)!
- }
-
- func LatoBlackItalic(withSize size: CGFloat) -> UIFont {
- UIFont(name: FontName.LatoBlackItalic.rawValue, size: size)!
- }
-
- func LatoBoldItalic(withSize size: CGFloat) -> UIFont {
- UIFont(name: FontName.LatoBoldItalic.rawValue, size: size)!
- }
-
- func LatoLight(withSize size: CGFloat) -> UIFont {
- UIFont(name: FontName.LatoLight.rawValue, size: size)!
- }
-
- func LatoHairlineItalic(withSize size: CGFloat) -> UIFont {
- UIFont(name: FontName.LatoHairlineItalic.rawValue, size: size)!
- }
-
-}
\ No newline at end of file
diff --git a/SampleFiles/Fonts/Generated/UIFont+Font.swift b/SampleFiles/Fonts/Generated/UIFont+Font.swift
deleted file mode 100644
index 627da99..0000000
--- a/SampleFiles/Fonts/Generated/UIFont+Font.swift
+++ /dev/null
@@ -1,63 +0,0 @@
-// Lato/Lato-Italic.ttf Lato/Lato-LightItalic.ttf Lato/Lato-Thin.ttf Lato/Lato-Bold.ttf Lato/Lato-Black.ttf Lato/Lato-Regular.ttf Lato/Lato-BlackItalic.ttf Lato/Lato-BoldItalic.ttf Lato/Lato-Light.ttf Lato/Lato-ThinItalic.ttf
-// Generated from FontToolCore
-
-import UIKit
-
-extension UIFont {
-
- enum FontName: String {
- case LatoItalic = "Lato-Italic"
- case LatoLightItalic = "Lato-LightItalic"
- case LatoHairline = "Lato-Hairline"
- case LatoBold = "Lato-Bold"
- case LatoBlack = "Lato-Black"
- case LatoRegular = "Lato-Regular"
- case LatoBlackItalic = "Lato-BlackItalic"
- case LatoBoldItalic = "Lato-BoldItalic"
- case LatoLight = "Lato-Light"
- case LatoHairlineItalic = "Lato-HairlineItalic"
- }
-
- // MARK: - Getter
-
- static let LatoItalic: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoItalic.rawValue, size: size)!
- }
-
- static let LatoLightItalic: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoLightItalic.rawValue, size: size)!
- }
-
- static let LatoHairline: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoHairline.rawValue, size: size)!
- }
-
- static let LatoBold: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoBold.rawValue, size: size)!
- }
-
- static let LatoBlack: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoBlack.rawValue, size: size)!
- }
-
- static let LatoRegular: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoRegular.rawValue, size: size)!
- }
-
- static let LatoBlackItalic: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoBlackItalic.rawValue, size: size)!
- }
-
- static let LatoBoldItalic: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoBoldItalic.rawValue, size: size)!
- }
-
- static let LatoLight: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoLight.rawValue, size: size)!
- }
-
- static let LatoHairlineItalic: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoHairlineItalic.rawValue, size: size)!
- }
-
-}
\ No newline at end of file
diff --git a/SampleFiles/Fonts/Generated/UIFont+FontGenAllScript.swift b/SampleFiles/Fonts/Generated/UIFont+FontGenAllScript.swift
deleted file mode 100644
index 398823b..0000000
--- a/SampleFiles/Fonts/Generated/UIFont+FontGenAllScript.swift
+++ /dev/null
@@ -1,62 +0,0 @@
-// Generated from FontToolCore
-
-import UIKit
-
-extension UIFont {
-
- enum FontName: String {
- case LatoItalic = "Lato-Italic"
- case LatoLightItalic = "Lato-LightItalic"
- case LatoHairline = "Lato-Hairline"
- case LatoBold = "Lato-Bold"
- case LatoBlack = "Lato-Black"
- case LatoRegular = "Lato-Regular"
- case LatoBlackItalic = "Lato-BlackItalic"
- case LatoBoldItalic = "Lato-BoldItalic"
- case LatoLight = "Lato-Light"
- case LatoHairlineItalic = "Lato-HairlineItalic"
- }
-
- // MARK: - Getter
-
- static let LatoItalic: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoItalic.rawValue, size: size)!
- }
-
- static let LatoLightItalic: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoLightItalic.rawValue, size: size)!
- }
-
- static let LatoHairline: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoHairline.rawValue, size: size)!
- }
-
- static let LatoBold: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoBold.rawValue, size: size)!
- }
-
- static let LatoBlack: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoBlack.rawValue, size: size)!
- }
-
- static let LatoRegular: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoRegular.rawValue, size: size)!
- }
-
- static let LatoBlackItalic: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoBlackItalic.rawValue, size: size)!
- }
-
- static let LatoBoldItalic: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoBoldItalic.rawValue, size: size)!
- }
-
- static let LatoLight: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoLight.rawValue, size: size)!
- }
-
- static let LatoHairlineItalic: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoHairlineItalic.rawValue, size: size)!
- }
-
-}
\ No newline at end of file
diff --git a/SampleFiles/Fonts/Generated/UIFont+GenAllScript.swift b/SampleFiles/Fonts/Generated/UIFont+GenAllScript.swift
deleted file mode 100644
index 8ea97fa..0000000
--- a/SampleFiles/Fonts/Generated/UIFont+GenAllScript.swift
+++ /dev/null
@@ -1,61 +0,0 @@
-// Generated by ResgenSwift.FontTool 1.0.0
-
-import UIKit
-
-extension UIFont {
-
- enum FontName: String {
- case LatoItalic = "Lato-Italic"
- case LatoLightItalic = "Lato-LightItalic"
- case LatoHairline = "Lato-Hairline"
- case LatoBold = "Lato-Bold"
- case LatoBlack = "Lato-Black"
- case LatoRegular = "Lato-Regular"
- case LatoBlackItalic = "Lato-BlackItalic"
- case LatoBoldItalic = "Lato-BoldItalic"
- case LatoLight = "Lato-Light"
- case LatoHairlineItalic = "Lato-HairlineItalic"
- }
-
- // MARK: - Getter
-
- static let LatoItalic: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoItalic.rawValue, size: size)!
- }
-
- static let LatoLightItalic: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoLightItalic.rawValue, size: size)!
- }
-
- static let LatoHairline: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoHairline.rawValue, size: size)!
- }
-
- static let LatoBold: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoBold.rawValue, size: size)!
- }
-
- static let LatoBlack: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoBlack.rawValue, size: size)!
- }
-
- static let LatoRegular: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoRegular.rawValue, size: size)!
- }
-
- static let LatoBlackItalic: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoBlackItalic.rawValue, size: size)!
- }
-
- static let LatoBoldItalic: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoBoldItalic.rawValue, size: size)!
- }
-
- static let LatoLight: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoLight.rawValue, size: size)!
- }
-
- static let LatoHairlineItalic: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoHairlineItalic.rawValue, size: size)!
- }
-}
\ No newline at end of file
diff --git a/SampleFiles/Fonts/Generated/UIFontYolo+GenAllScript.swift b/SampleFiles/Fonts/Generated/UIFontYolo+GenAllScript.swift
new file mode 100644
index 0000000..5ba0759
--- /dev/null
+++ b/SampleFiles/Fonts/Generated/UIFontYolo+GenAllScript.swift
@@ -0,0 +1,61 @@
+// Generated by ResgenSwift.Fonts 1.0
+
+import UIKit
+
+extension UIFontYolo {
+
+ enum FontName: String {
+ case LatoItalic = "Lato-Italic"
+ case LatoLightItalic = "Lato-LightItalic"
+ case LatoHairline = "Lato-Hairline"
+ case LatoBold = "Lato-Bold"
+ case LatoBlack = "Lato-Black"
+ case LatoRegular = "Lato-Regular"
+ case LatoBlackItalic = "Lato-BlackItalic"
+ case LatoBoldItalic = "Lato-BoldItalic"
+ case LatoLight = "Lato-Light"
+ case LatoHairlineItalic = "Lato-HairlineItalic"
+ }
+
+ // MARK: - Getter
+
+ func LatoItalic(withSize size: CGFloat) -> UIFont {
+ UIFont(name: FontName.LatoItalic.rawValue, size: size)!
+ }
+
+ func LatoLightItalic(withSize size: CGFloat) -> UIFont {
+ UIFont(name: FontName.LatoLightItalic.rawValue, size: size)!
+ }
+
+ func LatoHairline(withSize size: CGFloat) -> UIFont {
+ UIFont(name: FontName.LatoHairline.rawValue, size: size)!
+ }
+
+ func LatoBold(withSize size: CGFloat) -> UIFont {
+ UIFont(name: FontName.LatoBold.rawValue, size: size)!
+ }
+
+ func LatoBlack(withSize size: CGFloat) -> UIFont {
+ UIFont(name: FontName.LatoBlack.rawValue, size: size)!
+ }
+
+ func LatoRegular(withSize size: CGFloat) -> UIFont {
+ UIFont(name: FontName.LatoRegular.rawValue, size: size)!
+ }
+
+ func LatoBlackItalic(withSize size: CGFloat) -> UIFont {
+ UIFont(name: FontName.LatoBlackItalic.rawValue, size: size)!
+ }
+
+ func LatoBoldItalic(withSize size: CGFloat) -> UIFont {
+ UIFont(name: FontName.LatoBoldItalic.rawValue, size: size)!
+ }
+
+ func LatoLight(withSize size: CGFloat) -> UIFont {
+ UIFont(name: FontName.LatoLight.rawValue, size: size)!
+ }
+
+ func LatoHairlineItalic(withSize size: CGFloat) -> UIFont {
+ UIFont(name: FontName.LatoHairlineItalic.rawValue, size: size)!
+ }
+}
\ No newline at end of file
diff --git a/SampleFiles/Fonts/Generated/UIFontoptions.+FontGenAllScript.swift b/SampleFiles/Fonts/Generated/UIFontoptions.+FontGenAllScript.swift
deleted file mode 100644
index 398823b..0000000
--- a/SampleFiles/Fonts/Generated/UIFontoptions.+FontGenAllScript.swift
+++ /dev/null
@@ -1,62 +0,0 @@
-// Generated from FontToolCore
-
-import UIKit
-
-extension UIFont {
-
- enum FontName: String {
- case LatoItalic = "Lato-Italic"
- case LatoLightItalic = "Lato-LightItalic"
- case LatoHairline = "Lato-Hairline"
- case LatoBold = "Lato-Bold"
- case LatoBlack = "Lato-Black"
- case LatoRegular = "Lato-Regular"
- case LatoBlackItalic = "Lato-BlackItalic"
- case LatoBoldItalic = "Lato-BoldItalic"
- case LatoLight = "Lato-Light"
- case LatoHairlineItalic = "Lato-HairlineItalic"
- }
-
- // MARK: - Getter
-
- static let LatoItalic: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoItalic.rawValue, size: size)!
- }
-
- static let LatoLightItalic: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoLightItalic.rawValue, size: size)!
- }
-
- static let LatoHairline: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoHairline.rawValue, size: size)!
- }
-
- static let LatoBold: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoBold.rawValue, size: size)!
- }
-
- static let LatoBlack: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoBlack.rawValue, size: size)!
- }
-
- static let LatoRegular: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoRegular.rawValue, size: size)!
- }
-
- static let LatoBlackItalic: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoBlackItalic.rawValue, size: size)!
- }
-
- static let LatoBoldItalic: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoBoldItalic.rawValue, size: size)!
- }
-
- static let LatoLight: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoLight.rawValue, size: size)!
- }
-
- static let LatoHairlineItalic: ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.LatoHairlineItalic.rawValue, size: size)!
- }
-
-}
\ No newline at end of file
diff --git a/SampleFiles/Fonts/Generated/test.plist b/SampleFiles/Fonts/Generated/test.plist
new file mode 100644
index 0000000..32c2b75
--- /dev/null
+++ b/SampleFiles/Fonts/Generated/test.plist
@@ -0,0 +1,21 @@
+
+
+
+
+ NewArr
+
+ UIAppFonts
+
+ Lato-Italic
+ Lato-LightItalic
+ Lato-Hairline
+ Lato-Bold
+ Lato-Black
+ Lato-Regular
+ Lato-BlackItalic
+ Lato-BoldItalic
+ Lato-Light
+ Lato-HairlineItalic
+
+
+
diff --git a/SampleFiles/Fonts/Generated/test2.plist b/SampleFiles/Fonts/Generated/test2.plist
new file mode 100644
index 0000000..32c2b75
--- /dev/null
+++ b/SampleFiles/Fonts/Generated/test2.plist
@@ -0,0 +1,21 @@
+
+
+
+
+ NewArr
+
+ UIAppFonts
+
+ Lato-Italic
+ Lato-LightItalic
+ Lato-Hairline
+ Lato-Bold
+ Lato-Black
+ Lato-Regular
+ Lato-BlackItalic
+ Lato-BoldItalic
+ Lato-Light
+ Lato-HairlineItalic
+
+
+
diff --git a/SampleFiles/Images/Generated/ImageYolo+GenAllScript.swift b/SampleFiles/Images/Generated/ImageYolo+GenAllScript.swift
new file mode 100644
index 0000000..9961903
--- /dev/null
+++ b/SampleFiles/Images/Generated/ImageYolo+GenAllScript.swift
@@ -0,0 +1,31 @@
+// Generated by ResgenSwift.Images 1.0
+// Images from sampleImages
+
+import SwiftUI
+
+extension ImageYolo {
+
+ var article_notification_pull_detail: Image {
+ Image("article_notification_pull_detail")
+ }
+
+ var article_notification_pull: Image {
+ Image("article_notification_pull")
+ }
+
+ var new_article: Image {
+ Image("new_article")
+ }
+
+ var welcome_background: Image {
+ Image("welcome_background")
+ }
+
+ var article_trash: Image {
+ Image("article_trash")
+ }
+
+ var ic_close_article: Image {
+ Image("ic_close_article")
+ }
+}
\ No newline at end of file
diff --git a/SampleFiles/Images/Generated/UIImage+GenAllScript.swift b/SampleFiles/Images/Generated/UIImage+GenAllScript.swift
index 0d1bf02..20dc6ea 100644
--- a/SampleFiles/Images/Generated/UIImage+GenAllScript.swift
+++ b/SampleFiles/Images/Generated/UIImage+GenAllScript.swift
@@ -1,32 +1,31 @@
-// Generated by ResgenSwift.Imagium 1.0.0
+// Generated by ResgenSwift.Images 1.0
// Images from sampleImages
import UIKit
extension UIImage {
- static var article_notification_pull_detail: UIImage {
+ var article_notification_pull_detail: UIImage {
UIImage(named: "article_notification_pull_detail")!
}
-
- static var article_notification_pull: UIImage {
+
+ var article_notification_pull: UIImage {
UIImage(named: "article_notification_pull")!
}
-
- static var new_article: UIImage {
+
+ var new_article: UIImage {
UIImage(named: "new_article")!
}
-
- static var welcome_background: UIImage {
+
+ var welcome_background: UIImage {
UIImage(named: "welcome_background")!
}
-
- static var article_trash: UIImage {
+
+ var article_trash: UIImage {
UIImage(named: "article_trash")!
}
-
- static var ic_close_article: UIImage {
+
+ var ic_close_article: UIImage {
UIImage(named: "ic_close_article")!
}
-
}
\ No newline at end of file
diff --git a/SampleFiles/Images/Generated/UIImage+ImageGenAllScript.swift b/SampleFiles/Images/Generated/UIImage+ImageGenAllScript.swift
deleted file mode 100644
index ca3752e..0000000
--- a/SampleFiles/Images/Generated/UIImage+ImageGenAllScript.swift
+++ /dev/null
@@ -1,32 +0,0 @@
-// Generated from Imagium at 2022-02-14 09:30:23 +0000
-// Images from sampleImages
-
-import UIKit
-
-extension UIImage {
-
- static var article_notification_pull_detail: UIImage {
- UIImage(named: "article_notification_pull_detail")!
- }
-
- static var article_notification_pull: UIImage {
- UIImage(named: "article_notification_pull")!
- }
-
- static var new_article: UIImage {
- UIImage(named: "new_article")!
- }
-
- static var welcome_background: UIImage {
- UIImage(named: "welcome_background")!
- }
-
- static var article_trash: UIImage {
- UIImage(named: "article_trash")!
- }
-
- static var ic_close_article: UIImage {
- UIImage(named: "ic_close_article")!
- }
-
-}
\ No newline at end of file
diff --git a/SampleFiles/Strings/Generated/MyString+TargetSuffix.swift b/SampleFiles/Strings/Generated/MyString+TargetSuffix.swift
deleted file mode 100644
index 38795d5..0000000
--- a/SampleFiles/Strings/Generated/MyString+TargetSuffix.swift
+++ /dev/null
@@ -1,37 +0,0 @@
-// Generated from StringToolCore at 2022-01-10 08:27:11 +0000
-
-import UIKit
-
-fileprivate let kStringsFileName = "sampleStrings"
-
-extension MyString {
-
- // MARK: - Webservice
-
- /// Translation in en :
- /// en
- var param_lang: String {
- NSLocalizedString("param_lang", tableName: kStringsFileName, bundle: Bundle.main, value: "en", comment: "")
- }
-
- // MARK: - Generic
-
- /// Translation in en :
- /// Back
- var generic_back: String {
- NSLocalizedString("generic_back", tableName: kStringsFileName, bundle: Bundle.main, value: "Back", comment: "")
- }
-
- /// Translation in en :
- /// Loading data...
- var generic_loading_data: String {
- NSLocalizedString("generic_loading_data", tableName: kStringsFileName, bundle: Bundle.main, value: "Loading data...", comment: "")
- }
-
- /// Translation in en :
- /// Welcome %@ !
- var generic_welcome_firstname_format: String {
- NSLocalizedString("generic_welcome_firstname_format", tableName: kStringsFileName, bundle: Bundle.main, value: "Welcome %@ !", comment: "")
- }
-
-}
\ No newline at end of file
diff --git a/SampleFiles/Strings/Generated/String+GenAllScript.swift b/SampleFiles/Strings/Generated/String+GenAllScript.swift
index 98cb8ef..c5decf4 100644
--- a/SampleFiles/Strings/Generated/String+GenAllScript.swift
+++ b/SampleFiles/Strings/Generated/String+GenAllScript.swift
@@ -1,4 +1,4 @@
-// Generated by ResgenSwift.Strings.Stringium 1.0.0
+// Generated by ResgenSwift.Strings.Stringium 1.0
import UIKit
@@ -6,60 +6,59 @@ fileprivate let kStringsFileName = "sampleStrings"
extension String {
- // MARK: - Webservice
+ // MARK: - Webservice
/// Translation in en :
/// en
- static var param_lang: String {
+ var param_lang: String {
NSLocalizedString("param_lang", tableName: kStringsFileName, bundle: Bundle.main, value: "en", comment: "")
}
- // MARK: - Generic
+ // MARK: - Generic
/// Translation in en :
/// Back
- static var generic_back: String {
+ var generic_back: String {
NSLocalizedString("generic_back", tableName: kStringsFileName, bundle: Bundle.main, value: "Back", comment: "")
}
/// Translation in en :
/// Loading data...
- static var generic_loading_data: String {
+ var generic_loading_data: String {
NSLocalizedString("generic_loading_data", tableName: kStringsFileName, bundle: Bundle.main, value: "Loading data...", comment: "")
}
/// Translation in en :
/// Welcome \"%@\" !
- static var generic_welcome_firstname_format: String {
+ var generic_welcome_firstname_format: String {
NSLocalizedString("generic_welcome_firstname_format", tableName: kStringsFileName, bundle: Bundle.main, value: "Welcome \"%@\" !", comment: "")
}
/// Translation in en :
/// Welcome \"%@\" !
- static func generic_welcome_firstname_format(arg0: String) -> String {
- String(format: Self.generic_welcome_firstname_format, arg0)
+ func generic_welcome_firstname_format(arg0: String) -> String {
+ String(format: self.generic_welcome_firstname_format, arg0)
}
- // MARK: - EqualSymbol
+ // MARK: - EqualSymbol
/// Translation in en :
/// 1€ = 1 point !
- static var test_equal_symbol: String {
+ var test_equal_symbol: String {
NSLocalizedString("test_equal_symbol", tableName: kStringsFileName, bundle: Bundle.main, value: "1€ = 1 point !", comment: "")
}
- // MARK: - Placeholders
+ // MARK: - Placeholders
/// Translation in en :
/// You %%: %2$@ %1$@ Age: %3$d
- static var placeholders_test_one: String {
+ var placeholders_test_one: String {
NSLocalizedString("placeholders_test_one", tableName: kStringsFileName, bundle: Bundle.main, value: "You %%: %2$@ %1$@ Age: %3$d", comment: "")
}
/// Translation in en :
/// You %%: %2$@ %1$@ Age: %3$d
- static func placeholders_test_one(arg0: String, arg1: String, arg2: Int) -> String {
- String(format: Self.placeholders_test_one, arg0, arg1, arg2)
+ func placeholders_test_one(arg0: String, arg1: String, arg2: Int) -> String {
+ String(format: self.placeholders_test_one, arg0, arg1, arg2)
}
-
}
\ No newline at end of file
diff --git a/SampleFiles/Strings/Generated/String+Placeholders.swift b/SampleFiles/Strings/Generated/String+Placeholders.swift
deleted file mode 100644
index 31c8470..0000000
--- a/SampleFiles/Strings/Generated/String+Placeholders.swift
+++ /dev/null
@@ -1,57 +0,0 @@
-// Generated from Strings-Stringium at 2022-03-07 11:02:15 +0000
-
-import UIKit
-
-fileprivate let kStringsFileName = "sampleStrings"
-
-extension String {
-
- // MARK: - Webservice
-
- /// Translation in en :
- /// en
- static var param_lang: String {
- NSLocalizedString("param_lang", tableName: kStringsFileName, bundle: Bundle.main, value: "en", comment: "")
- }
-
- // MARK: - Generic
-
- /// Translation in en :
- /// Back
- static var generic_back: String {
- NSLocalizedString("generic_back", tableName: kStringsFileName, bundle: Bundle.main, value: "Back", comment: "")
- }
-
- /// Translation in en :
- /// Loading data...
- static var generic_loading_data: String {
- NSLocalizedString("generic_loading_data", tableName: kStringsFileName, bundle: Bundle.main, value: "Loading data...", comment: "")
- }
-
- /// Translation in en :
- /// Welcome \"%@\" !
- static var generic_welcome_firstname_format: String {
- NSLocalizedString("generic_welcome_firstname_format", tableName: kStringsFileName, bundle: Bundle.main, value: "Welcome \"%@\" !", comment: "")
- }
-
- /// Translation in en :
- /// Welcome \"%@\" !
- static func generic_welcome_firstname_format(arg0: String) -> String {
- String(format: Self.generic_welcome_firstname_format, arg0)
- }
-
- // MARK: - Placeholders
-
- /// Translation in en :
- /// You %%: %2$@ %1$@ Age: %3$d
- static var placeholders_test_one: String {
- NSLocalizedString("placeholders_test_one", tableName: kStringsFileName, bundle: Bundle.main, value: "You %%: %2$@ %1$@ Age: %3$d", comment: "")
- }
-
- /// Translation in en :
- /// You %%: %2$@ %1$@ Age: %3$d
- static func placeholders_test_one(arg0: String, arg1: String, arg2: Int) -> String {
- String(format: Self.placeholders_test_one, arg0, arg1, arg2)
- }
-
-}
\ No newline at end of file
diff --git a/SampleFiles/Strings/Generated/String+TargetSuffix.swift b/SampleFiles/Strings/Generated/String+TargetSuffix.swift
deleted file mode 100644
index fcf6786..0000000
--- a/SampleFiles/Strings/Generated/String+TargetSuffix.swift
+++ /dev/null
@@ -1,37 +0,0 @@
-// Generated from StringToolCore at 2022-01-10 08:39:52 +0000
-
-import UIKit
-
-fileprivate let kStringsFileName = "sampleStrings"
-
-extension String {
-
- // MARK: - Webservice
-
- /// Translation in en :
- /// en
- static var param_lang: String {
- NSLocalizedString("param_lang", tableName: kStringsFileName, bundle: Bundle.main, value: "en", comment: "")
- }
-
- // MARK: - Generic
-
- /// Translation in en :
- /// Back
- static var generic_back: String {
- NSLocalizedString("generic_back", tableName: kStringsFileName, bundle: Bundle.main, value: "Back", comment: "")
- }
-
- /// Translation in en :
- /// Loading data...
- static var generic_loading_data: String {
- NSLocalizedString("generic_loading_data", tableName: kStringsFileName, bundle: Bundle.main, value: "Loading data...", comment: "")
- }
-
- /// Translation in en :
- /// Welcome \"%@\" !
- static var generic_welcome_firstname_format: String {
- NSLocalizedString("generic_welcome_firstname_format", tableName: kStringsFileName, bundle: Bundle.main, value: "Welcome \"%@\" !", comment: "")
- }
-
-}
\ No newline at end of file
diff --git a/SampleFiles/Strings/Generated/StringTest+Placeholders.swift b/SampleFiles/Strings/Generated/StringTest+Placeholders.swift
deleted file mode 100644
index 327d76d..0000000
--- a/SampleFiles/Strings/Generated/StringTest+Placeholders.swift
+++ /dev/null
@@ -1,57 +0,0 @@
-// Generated from Strings-Stringium at 2022-03-07 11:00:52 +0000
-
-import UIKit
-
-fileprivate let kStringsFileName = "sampleStrings"
-
-extension StringTest {
-
- // MARK: - Webservice
-
- /// Translation in en :
- /// en
- var param_lang: String {
- NSLocalizedString("param_lang", tableName: kStringsFileName, bundle: Bundle.main, value: "en", comment: "")
- }
-
- // MARK: - Generic
-
- /// Translation in en :
- /// Back
- var generic_back: String {
- NSLocalizedString("generic_back", tableName: kStringsFileName, bundle: Bundle.main, value: "Back", comment: "")
- }
-
- /// Translation in en :
- /// Loading data...
- var generic_loading_data: String {
- NSLocalizedString("generic_loading_data", tableName: kStringsFileName, bundle: Bundle.main, value: "Loading data...", comment: "")
- }
-
- /// Translation in en :
- /// Welcome \"%@\" !
- var generic_welcome_firstname_format: String {
- NSLocalizedString("generic_welcome_firstname_format", tableName: kStringsFileName, bundle: Bundle.main, value: "Welcome \"%@\" !", comment: "")
- }
-
- /// Translation in en :
- /// Welcome \"%@\" !
- func generic_welcome_firstname_format(arg0: String) -> String {
- String(format: self.generic_welcome_firstname_format, arg0)
- }
-
- // MARK: - Placeholders
-
- /// Translation in en :
- /// You %%: %2$@ %1$@ Age: %3$d
- var placeholders_test_one: String {
- NSLocalizedString("placeholders_test_one", tableName: kStringsFileName, bundle: Bundle.main, value: "You %%: %2$@ %1$@ Age: %3$d", comment: "")
- }
-
- /// Translation in en :
- /// You %%: %2$@ %1$@ Age: %3$d
- func placeholders_test_one(arg0: String, arg1: String, arg2: Int) -> String {
- String(format: self.placeholders_test_one, arg0, arg1, arg2)
- }
-
-}
\ No newline at end of file
diff --git a/SampleFiles/Strings/Generated/en-us.lproj/sampleStrings.strings b/SampleFiles/Strings/Generated/en-us.lproj/sampleStrings.strings
index be59eba..2f6f597 100644
--- a/SampleFiles/Strings/Generated/en-us.lproj/sampleStrings.strings
+++ b/SampleFiles/Strings/Generated/en-us.lproj/sampleStrings.strings
@@ -1,6 +1,6 @@
/**
* Apple Strings File
- * Generated by ResgenSwift 1.0.0
+ * Generated by ResgenSwift 1.0
* Language: en-us
*/
diff --git a/SampleFiles/Strings/Generated/en.lproj/sampleStrings.strings b/SampleFiles/Strings/Generated/en.lproj/sampleStrings.strings
index a0e6800..f92618a 100644
--- a/SampleFiles/Strings/Generated/en.lproj/sampleStrings.strings
+++ b/SampleFiles/Strings/Generated/en.lproj/sampleStrings.strings
@@ -1,6 +1,6 @@
/**
* Apple Strings File
- * Generated by ResgenSwift 1.0.0
+ * Generated by ResgenSwift 1.0
* Language: en
*/
diff --git a/SampleFiles/Strings/Generated/fr.lproj/sampleStrings.strings b/SampleFiles/Strings/Generated/fr.lproj/sampleStrings.strings
index 06df8fb..cfc520a 100644
--- a/SampleFiles/Strings/Generated/fr.lproj/sampleStrings.strings
+++ b/SampleFiles/Strings/Generated/fr.lproj/sampleStrings.strings
@@ -1,6 +1,6 @@
/**
* Apple Strings File
- * Generated by ResgenSwift 1.0.0
+ * Generated by ResgenSwift 1.0
* Language: fr
*/
diff --git a/SampleFiles/Tags/Generated/Tags+GenAllScript.swift b/SampleFiles/Tags/Generated/Tags+GenAllScript.swift
index 01fc191..f53f115 100644
--- a/SampleFiles/Tags/Generated/Tags+GenAllScript.swift
+++ b/SampleFiles/Tags/Generated/Tags+GenAllScript.swift
@@ -1,23 +1,20 @@
-// Generated by ResgenSwift.Strings.Tags 1.0.0
-
-// typelias Tags = String
+// Generated by ResgenSwift.Strings.Tags 1.0
import UIKit
extension Tags {
- // MARK: - ScreenTag
+ // MARK: - ScreenTag
/// Translation in ium :
/// Ecran un
- static var screen_one: String {
+ var screen_one: String {
"Ecran un"
}
/// Translation in ium :
/// Ecran deux
- static var screen_two: String {
+ var screen_two: String {
"Ecran deux"
}
-
}
\ No newline at end of file
diff --git a/SampleFiles/Tags/Generated/Tags+TagGenAllScript.swift b/SampleFiles/Tags/Generated/Tags+TagGenAllScript.swift
deleted file mode 100644
index 0881d01..0000000
--- a/SampleFiles/Tags/Generated/Tags+TagGenAllScript.swift
+++ /dev/null
@@ -1,23 +0,0 @@
-// Generated from Strings-Tags at 2022-02-14 09:30:20 +0000
-
-// typelias Tags = String
-
-import UIKit
-
-extension Tags {
-
- // MARK: - ScreenTag
-
- /// Translation in ium :
- /// Ecran un
- static var screen_one: String {
- "Ecran un"
- }
-
- /// Translation in ium :
- /// Ecran deux
- static var screen_two: String {
- "Ecran deux"
- }
-
-}
\ No newline at end of file
diff --git a/SampleFiles/genAllRessources.sh b/SampleFiles/genAllRessources.sh
index 2c94a16..a9d8550 100755
--- a/SampleFiles/genAllRessources.sh
+++ b/SampleFiles/genAllRessources.sh
@@ -3,25 +3,28 @@
FORCE_FLAG="$1"
# Font
-swift run -c release FontTool $FORCE_FLAG "./Fonts/sampleFontsAll.txt" \
+swift run -c release ResgenSwift fonts $FORCE_FLAG "./Fonts/sampleFontsAll.txt" \
--extension-output-path "./Fonts/Generated" \
- --extension-name "UIFont" \
- --extension-suffix "GenAllScript"
+ --extension-name "UIFontYolo" \
+ --extension-name-swift-ui "FontYolo" \
+ --extension-suffix "GenAllScript" \
+ --info-plist-paths "./Fonts/Generated/test.plist ./Fonts/Generated/test2.plist"
echo "\n-------------------------\n"
# Color
-swift run -c release ColorTool $FORCE_FLAG "./Colors/sampleColors1.txt" \
+swift run -c release ResgenSwift colors $FORCE_FLAG "./Colors/sampleColors1.txt" \
--style all \
--xcassets-path "./Colors/colors.xcassets" \
--extension-output-path "./Colors/Generated/" \
- --extension-name "UIColor" \
+ --extension-name "UIColorYolo" \
+ --extension-name-swift-ui "ColorYolo" \
--extension-suffix "GenAllScript"
echo "\n-------------------------\n"
# Twine
-swift run -c release Strings twine $FORCE_FLAG "./Twine/sampleStrings.txt" \
+swift run -c release ResgenSwift strings twine $FORCE_FLAG "./Twine/sampleStrings.txt" \
--output-path "./Twine/Generated" \
--langs "fr en en-us" \
--default-lang "en" \
@@ -30,7 +33,7 @@ swift run -c release Strings twine $FORCE_FLAG "./Twine/sampleStrings.txt" \
echo "\n-------------------------\n"
# Strings
-swift run -c release Strings stringium $FORCE_FLAG "./Strings/sampleStrings.txt" \
+swift run -c release ResgenSwift strings stringium $FORCE_FLAG "./Strings/sampleStrings.txt" \
--output-path "./Strings/Generated" \
--langs "fr en en-us" \
--default-lang "en" \
@@ -41,7 +44,7 @@ swift run -c release Strings stringium $FORCE_FLAG "./Strings/sampleStrings.txt"
echo "\n-------------------------\n"
# Tags
-swift run -c release Strings tags $FORCE_FLAG "./Tags/sampleTags.txt" \
+swift run -c release ResgenSwift strings tags $FORCE_FLAG "./Tags/sampleTags.txt" \
--lang "ium" \
--extension-output-path "./Tags/Generated" \
--extension-name "Tags" \
@@ -50,8 +53,9 @@ swift run -c release Strings tags $FORCE_FLAG "./Tags/sampleTags.txt" \
echo "\n-------------------------\n"
# Images
-swift run -c release Imagium $FORCE_FLAG "./Images/sampleImages.txt" \
+swift run -c release ResgenSwift images $FORCE_FLAG "./Images/sampleImages.txt" \
--xcassets-path "./Images/imagium.xcassets" \
--extension-output-path "./Images/Generated" \
--extension-name "UIImage" \
+ --extension-name-swift-ui "ImageYolo" \
--extension-suffix "GenAllScript"
diff --git a/SampleFiles/resgenConfiguration.yml b/SampleFiles/resgenConfiguration.yml
new file mode 100644
index 0000000..726e978
--- /dev/null
+++ b/SampleFiles/resgenConfiguration.yml
@@ -0,0 +1,65 @@
+---
+#
+# Strings
+#
+strings:
+-
+ inputFile: ./Strings/sampleStrings.txt
+ outputPath: ./Strings/Generated
+ langs: "fr en en-us"
+ defaultLang: en
+ extensionOutputPath: ./Strings/Generated
+ extensionName: String
+ extensionSuffix: GenAllScript
+
+
+#
+# Images
+#
+images:
+-
+ inputFile: ./Images/sampleImages.txt
+ xcassetsPath: ./Images/imagium.xcassets
+ extensionOutputPath: ./Images/Generated
+ extensionName: UIImage
+ extensionNameSwiftUI: ImageYolo
+ extensionSuffix: GenAllScript
+
+
+#
+# Colors
+#
+colors:
+-
+ inputFile: ./Colors/sampleColors1.txt
+ style: all
+ xcassetsPath: ./Colors/colors.xcassets
+ extensionOutputPath: ./Colors/Generated/
+ extensionName: UIColorYolo
+ extensionNameSwiftUI: ColorYolo
+ extensionSuffix: GenAllScript
+
+
+#
+# Tags
+#
+tags:
+-
+ inputFile: ./Tags/sampleTags.txt
+ lang: ium
+ extensionOutputPath: ./Tags/Generated
+ extensionName: Tags
+ extensionSuffix: GenAllScript
+
+
+#
+# Fonts
+#
+fonts:
+-
+ inputFile: ./Fonts/sampleFontsAll.txt
+ extensionOutputPath: ./Fonts/Generated
+ extensionName: UIFontYolo
+ extensionNameSwiftUI: FontYolo
+ extensionSuffix: GenAllScript
+ infoPlistPaths: "./Fonts/Generated/test.plist ./Fonts/Generated/test2.plist"
diff --git a/Sources/ResgenSwift/Colors/Colors.swift b/Sources/ResgenSwift/Colors/Colors.swift
index b0cc2c8..0ffc881 100644
--- a/Sources/ResgenSwift/Colors/Colors.swift
+++ b/Sources/ResgenSwift/Colors/Colors.swift
@@ -22,6 +22,7 @@ struct Colors: ParsableCommand {
static let toolName = "Color"
static let defaultExtensionName = "UIColor"
+ static let defaultExtensionNameSUI = "Color"
static let assetsColorsFolderName = "Colors"
// MARK: - Command options
@@ -43,7 +44,7 @@ struct Colors: ParsableCommand {
// Get colors to generate
let parsedColors = ColorFileParser.parse(options.inputFile,
- colorStyle: options.colorStyle)
+ colorStyle: options.style)
// -> Time: 0.0020350217819213867 seconds
// Generate all colors in xcassets
@@ -55,9 +56,16 @@ struct Colors: ParsableCommand {
ColorExtensionGenerator.writeExtensionFile(colors: parsedColors,
staticVar: options.staticMembers,
extensionName: options.extensionName,
- extensionFilePath: options.extensionFilePath)
- // -> Time: 0.0010340213775634766 seconds
-
+ extensionFilePath: options.extensionFilePath,
+ isSwiftUI: false)
+
+ // Generate extension
+ ColorExtensionGenerator.writeExtensionFile(colors: parsedColors,
+ staticVar: options.staticMembers,
+ extensionName: options.extensionNameSwiftUI,
+ extensionFilePath: options.extensionFilePathSwiftUI,
+ isSwiftUI: true)
+
print("[\(Self.toolName)] Colors generated")
}
@@ -80,6 +88,13 @@ struct Colors: ParsableCommand {
Colors.exit(withError: error)
}
+ // Extension for UIKit and SwiftUI should have different name
+ guard options.extensionName != options.extensionNameSwiftUI else {
+ let error = ColorsToolError.extensionNamesCollision(options.extensionName)
+ print(error.localizedDescription)
+ Colors.exit(withError: error)
+ }
+
// Check if needed to regenerate
guard GeneratorChecker.shouldGenerate(force: options.forceGeneration,
inputFilePath: options.inputFile,
diff --git a/Sources/ResgenSwift/Colors/ColorsToolError.swift b/Sources/ResgenSwift/Colors/ColorsToolError.swift
index a4310e5..0397fa7 100644
--- a/Sources/ResgenSwift/Colors/ColorsToolError.swift
+++ b/Sources/ResgenSwift/Colors/ColorsToolError.swift
@@ -8,6 +8,7 @@
import Foundation
enum ColorsToolError: Error {
+ case extensionNamesCollision(String)
case badFormat(String)
case writeAsset(String)
case createAssetFolder(String)
@@ -18,6 +19,9 @@ enum ColorsToolError: Error {
var description: String {
switch self {
+ case .extensionNamesCollision(let extensionName):
+ return "error:[\(Fonts.toolName)] Error on extension names, extension name and SwiftUI extension name should be different (\(extensionName) is used on both)"
+
case .badFormat(let info):
return "error:[\(Colors.toolName)] Bad line format: \(info). Accepted format are: colorName=\"#RGB/#ARGB\"; colorName \"#RGB/#ARGB\"; colorName \"#RGB/#ARGB\" \"#RGB/#ARGB\""
diff --git a/Sources/ResgenSwift/Colors/ColorsToolOptions.swift b/Sources/ResgenSwift/Colors/ColorsToolOptions.swift
index 9f5ae80..5c9144e 100644
--- a/Sources/ResgenSwift/Colors/ColorsToolOptions.swift
+++ b/Sources/ResgenSwift/Colors/ColorsToolOptions.swift
@@ -16,7 +16,7 @@ struct ColorsToolOptions: ParsableArguments {
var inputFile: String
@Option(help: "Color style to generate: light for light colors only, or all for dark and light colors")
- fileprivate var style: String
+ var style: ColorStyle
@Option(help: "Path of xcassets where to generate colors", transform: { $0.replaceTiltWithHomeDirectoryPath() })
var xcassetsPath: String
@@ -27,9 +27,12 @@ struct ColorsToolOptions: ParsableArguments {
@Option(help: "Tell if it will generate static properties or not")
var staticMembers: Bool = false
- @Option(help: "Extension name. If not specified, it will generate an UIColor extension. Using default extension name will generate static property.")
+ @Option(help: "Extension name. If not specified, it will generate an UIColor extension.")
var extensionName: String = Colors.defaultExtensionName
+ @Option(help: "SwiftUI Extension name. If not specified, it will generate an Color extension.")
+ var extensionNameSwiftUI: String = Colors.defaultExtensionNameSUI
+
@Option(help: "Extension suffix. Ex: MyApp, it will generate {extensionName}+ColorsMyApp.swift")
var extensionSuffix: String?
}
@@ -37,9 +40,8 @@ struct ColorsToolOptions: ParsableArguments {
// MARK: - Computed var
extension ColorsToolOptions {
- var colorStyle: ColorStyle {
- ColorStyle(rawValue: style) ?? .all
- }
+
+ // MARK: - UIKit
var extensionFileName: String {
if let extensionSuffix = extensionSuffix {
@@ -51,4 +53,17 @@ extension ColorsToolOptions {
var extensionFilePath: String {
"\(extensionOutputPath)/\(extensionFileName)"
}
+
+ // MARK: - SwiftUI
+
+ var extensionFileNameSwiftUI: String {
+ if let extensionSuffix = extensionSuffix {
+ return "\(extensionNameSwiftUI)+\(extensionSuffix).swift"
+ }
+ return "\(extensionNameSwiftUI).swift"
+ }
+
+ var extensionFilePathSwiftUI: String {
+ "\(extensionOutputPath)/\(extensionFileNameSwiftUI)"
+ }
}
diff --git a/Sources/ResgenSwift/Colors/Generator/ColorExtensionGenerator.swift b/Sources/ResgenSwift/Colors/Generator/ColorExtensionGenerator.swift
index 6221896..fb32aa5 100644
--- a/Sources/ResgenSwift/Colors/Generator/ColorExtensionGenerator.swift
+++ b/Sources/ResgenSwift/Colors/Generator/ColorExtensionGenerator.swift
@@ -13,11 +13,18 @@ struct ColorExtensionGenerator {
let colors: [ParsedColor]
let extensionClassname: String
- static func writeExtensionFile(colors: [ParsedColor], staticVar: Bool, extensionName: String, extensionFilePath: String) {
+ // MARK: - UIKit
+
+ static func writeExtensionFile(colors: [ParsedColor],
+ staticVar: Bool,
+ extensionName: String,
+ extensionFilePath: String,
+ isSwiftUI: Bool) {
// Create extension content
let extensionContent = Self.getExtensionContent(colors: colors,
staticVar: staticVar,
- extensionName: extensionName)
+ extensionName: extensionName,
+ isSwiftUI: isSwiftUI)
// Write content
let extensionFilePathURL = URL(fileURLWithPath: extensionFilePath)
@@ -30,20 +37,23 @@ struct ColorExtensionGenerator {
}
}
- static func getExtensionContent(colors: [ParsedColor], staticVar: Bool, extensionName: String) -> String {
+ static func getExtensionContent(colors: [ParsedColor],
+ staticVar: Bool,
+ extensionName: String,
+ isSwiftUI: Bool) -> String {
[
- Self.getHeader(extensionClassname: extensionName),
- Self.getProperties(for: colors, withStaticVar: staticVar),
+ Self.getHeader(extensionClassname: extensionName, isSwiftUI: isSwiftUI),
+ Self.getProperties(for: colors, withStaticVar: staticVar, isSwiftUI: isSwiftUI),
Self.getFooter()
]
.joined(separator: "\n")
}
- private static func getHeader(extensionClassname: String) -> String {
+ private static func getHeader(extensionClassname: String, isSwiftUI: Bool) -> String {
"""
// Generated by ResgenSwift.\(Colors.toolName) \(ResgenSwiftVersion)
- import UIKit
+ import \(isSwiftUI ? "SwiftUI" : "UIKit")
extension \(extensionClassname) {\n
"""
@@ -52,15 +62,15 @@ struct ColorExtensionGenerator {
private static func getFooter() -> String {
"""
}
+
"""
}
- private static func getProperties(for colors: [ParsedColor], withStaticVar staticVar: Bool) -> String {
+ private static func getProperties(for colors: [ParsedColor],
+ withStaticVar staticVar: Bool,
+ isSwiftUI: Bool) -> String {
colors.map {
- if staticVar {
- return $0.getColorStaticProperty()
- }
- return $0.getColorProperty()
+ $0.getColorProperty(isStatic: staticVar, isSwiftUI: isSwiftUI)
}
.joined(separator: "\n\n")
}
diff --git a/Sources/ResgenSwift/Colors/Model/ColorStyle.swift b/Sources/ResgenSwift/Colors/Model/ColorStyle.swift
index 8e1521a..78948aa 100644
--- a/Sources/ResgenSwift/Colors/Model/ColorStyle.swift
+++ b/Sources/ResgenSwift/Colors/Model/ColorStyle.swift
@@ -6,8 +6,16 @@
//
import Foundation
+import ArgumentParser
-enum ColorStyle: String, Decodable {
+enum ColorStyle: String, Decodable, ExpressibleByArgument {
case light
case all
+
+ static var allValueStrings: [String] {
+ [
+ Self.light.rawValue,
+ Self.all.rawValue
+ ]
+ }
}
diff --git a/Sources/ResgenSwift/Colors/Model/ParsedColor.swift b/Sources/ResgenSwift/Colors/Model/ParsedColor.swift
index 2bfe56c..951f206 100644
--- a/Sources/ResgenSwift/Colors/Model/ParsedColor.swift
+++ b/Sources/ResgenSwift/Colors/Model/ParsedColor.swift
@@ -72,19 +72,20 @@ struct ParsedColor {
"""
}
- func getColorProperty() -> String {
- """
+ // MARK: - UIKit
+
+ func getColorProperty(isStatic: Bool, isSwiftUI: Bool) -> String {
+ if isSwiftUI {
+ return """
+ /// Color \(name) is \(light) (light) or \(dark) (dark)"
+ \(isStatic ? "static " : "")var \(name): Color {
+ Color("\(name)")
+ }
+ """
+ }
+ return """
/// Color \(name) is \(light) (light) or \(dark) (dark)"
- @objc var \(name): UIColor {
- UIColor(named: "\(name)")!
- }
- """
- }
-
- func getColorStaticProperty() -> String {
- """
- /// Color \(name) is \(light) (light) or \(dark) (dark)"
- static var \(name): UIColor {
+ \(isStatic ? "static " : "@objc ")var \(name): UIColor {
UIColor(named: "\(name)")!
}
"""
diff --git a/Sources/ResgenSwift/Fonts/FontOptions.swift b/Sources/ResgenSwift/Fonts/FontOptions.swift
index 983f00d..ae53624 100644
--- a/Sources/ResgenSwift/Fonts/FontOptions.swift
+++ b/Sources/ResgenSwift/Fonts/FontOptions.swift
@@ -21,16 +21,25 @@ struct FontsOptions: ParsableArguments {
@Option(help: "Tell if it will generate static properties or methods")
var staticMembers: Bool = false
- @Option(help: "Extension name. If not specified, it will generate an UIFont extension. Using default extension name will generate static property.")
+ @Option(help: "Extension name. If not specified, it will generate an UIFont extension.")
var extensionName: String = Fonts.defaultExtensionName
+ @Option(help: "Extension name. If not specified, it will generate an Font extension.")
+ var extensionNameSwiftUI: String = Fonts.defaultExtensionNameSUI
+
@Option(help: "Extension suffix. Ex: MyApp, it will generate {extensionName}+FontsMyApp.swift")
var extensionSuffix: String = ""
+
+ @Option(name: .customLong("info-plist-paths"), help: "Info.plist paths (array). Will be used to update UIAppFonts content")
+ fileprivate var infoPlistPathsRaw: String = ""
}
// MARK: - Computed var
extension FontsOptions {
+
+ // MARK: - UIKit
+
var extensionFileName: String {
if extensionSuffix.isEmpty == false {
return "\(extensionName)+\(extensionSuffix).swift"
@@ -41,4 +50,25 @@ extension FontsOptions {
var extensionFilePath: String {
"\(extensionOutputPath)/\(extensionFileName)"
}
+
+ // MARK: - SwiftUI
+
+ var extensionFileNameSwiftUI: String {
+ if extensionSuffix.isEmpty == false {
+ return "\(extensionNameSwiftUI)+\(extensionSuffix).swift"
+ }
+ return "\(extensionNameSwiftUI).swift"
+ }
+
+ var extensionFilePathSwiftUI: String {
+ "\(extensionOutputPath)/\(extensionFileNameSwiftUI)"
+ }
+
+ // MARK: -
+
+ var infoPlistPaths: [String] {
+ infoPlistPathsRaw
+ .split(separator: " ")
+ .map { String($0) }
+ }
}
diff --git a/Sources/ResgenSwift/Fonts/Fonts.swift b/Sources/ResgenSwift/Fonts/Fonts.swift
index 3fa963d..0cf494d 100644
--- a/Sources/ResgenSwift/Fonts/Fonts.swift
+++ b/Sources/ResgenSwift/Fonts/Fonts.swift
@@ -22,6 +22,7 @@ struct Fonts: ParsableCommand {
static let toolName = "Fonts"
static let defaultExtensionName = "UIFont"
+ static let defaultExtensionNameSUI = "Font"
// MARK: - Command Options
@@ -50,10 +51,17 @@ struct Fonts: ParsableCommand {
FontExtensionGenerator.writeExtensionFile(fontsNames: fontsNames,
staticVar: options.staticMembers,
extensionName: options.extensionName,
- extensionFilePath: options.extensionFilePath)
+ extensionFilePath: options.extensionFilePath,
+ isSwiftUI: false)
- print("Info.plist information:")
- print("\(FontPlistGenerator.generatePlistUIAppsFontContent(for: fontsNames))")
+ FontExtensionGenerator.writeExtensionFile(fontsNames: fontsNames,
+ staticVar: options.staticMembers,
+ extensionName: options.extensionNameSwiftUI,
+ extensionFilePath: options.extensionFilePathSwiftUI,
+ isSwiftUI: true)
+
+ print("Info.plist has been updated with:")
+ print("\(FontPlistGenerator.generatePlistUIAppsFontContent(for: fontsNames, infoPlistPaths: options.infoPlistPaths))")
print("[\(Self.toolName)] Fonts generated")
}
@@ -70,6 +78,13 @@ struct Fonts: ParsableCommand {
Fonts.exit(withError: error)
}
+ // Extension for UIKit and SwiftUI should have different name
+ guard options.extensionName != options.extensionNameSwiftUI else {
+ let error = FontsToolError.extensionNamesCollision(options.extensionName)
+ print(error.localizedDescription)
+ Fonts.exit(withError: error)
+ }
+
// Check if needed to regenerate
guard GeneratorChecker.shouldGenerate(force: options.forceGeneration,
inputFilePath: options.inputFile,
diff --git a/Sources/ResgenSwift/Fonts/FontsToolError.swift b/Sources/ResgenSwift/Fonts/FontsToolError.swift
index e979ca6..30a8a22 100644
--- a/Sources/ResgenSwift/Fonts/FontsToolError.swift
+++ b/Sources/ResgenSwift/Fonts/FontsToolError.swift
@@ -8,6 +8,7 @@
import Foundation
enum FontsToolError: Error {
+ case extensionNamesCollision(String)
case fcScan(String, Int32, String?)
case inputFolderNotFound(String)
case fileNotExists(String)
@@ -15,6 +16,9 @@ enum FontsToolError: Error {
var localizedDescription: String {
switch self {
+ case .extensionNamesCollision(let extensionName):
+ return "error:[\(Fonts.toolName)] Error on extension names, extension name and SwiftUI extension name should be different (\(extensionName) is used on both)"
+
case .fcScan(let path, let code, let output):
return "error:[\(Fonts.toolName)] Error while getting fontName (fc-scan --format %{postscriptname} \(path). fc-scan exit with \(code) and output is: \(output ?? "no output")"
diff --git a/Sources/ResgenSwift/Fonts/Generator/FontPlistGenerator.swift b/Sources/ResgenSwift/Fonts/Generator/FontPlistGenerator.swift
index b02de76..37259c3 100644
--- a/Sources/ResgenSwift/Fonts/Generator/FontPlistGenerator.swift
+++ b/Sources/ResgenSwift/Fonts/Generator/FontPlistGenerator.swift
@@ -6,12 +6,34 @@
//
import Foundation
+import ToolCore
class FontPlistGenerator {
- static func generatePlistUIAppsFontContent(for fonts: [FontName]) -> String {
- var plistData = "UIAppFonts\n\t\n"
- fonts
+ static func generatePlistUIAppsFontContent(for fonts: [FontName], infoPlistPaths: [String]) -> String {
+ let fontsToAddToPlist = fonts
.compactMap { $0 }
+
+ // Update each plist
+ infoPlistPaths.forEach { infoPlist in
+ // Remove UIAppFonts value
+ Shell.shell(launchPath: "/usr/libexec/PlistBuddy",
+ ["-c", "delete :UIAppFonts", infoPlist])
+
+ // Add UIAppFonts empty array
+ debugPrint("Will PlistBuddy -c add :UIAppFonts array \(infoPlist)")
+ Shell.shell(launchPath: "/usr/libexec/PlistBuddy",
+ ["-c", "add :UIAppFonts array", infoPlist])
+
+ // Fill array with fonts
+ fontsToAddToPlist
+ .forEach {
+ Shell.shell(launchPath: "/usr/libexec/PlistBuddy",
+ ["-c", "add :UIAppFonts: string \($0)", infoPlist])
+ }
+ }
+
+ var plistData = "UIAppFonts\n\t\n"
+ fontsToAddToPlist
.forEach {
plistData += "\t\t\($0)\n"
}
diff --git a/Sources/ResgenSwift/Fonts/Generator/FontToolContentGenerator.swift b/Sources/ResgenSwift/Fonts/Generator/FontToolContentGenerator.swift
index 992e55d..eff2dea 100644
--- a/Sources/ResgenSwift/Fonts/Generator/FontToolContentGenerator.swift
+++ b/Sources/ResgenSwift/Fonts/Generator/FontToolContentGenerator.swift
@@ -9,12 +9,28 @@ import Foundation
import ToolCore
class FontExtensionGenerator {
+
+ private static func getFontNameEnum(fontsNames: [String]) -> String {
+ var enumDefinition = " enum FontName: String {\n"
+
+ fontsNames.forEach {
+ enumDefinition += " case \($0.fontNameSanitize) = \"\($0)\"\n"
+ }
+ enumDefinition += " }\n"
+
+ return enumDefinition
+ }
- static func writeExtensionFile(fontsNames: [String], staticVar: Bool, extensionName: String, extensionFilePath: String) {
+ static func writeExtensionFile(fontsNames: [String],
+ staticVar: Bool,
+ extensionName: String,
+ extensionFilePath: String,
+ isSwiftUI: Bool) {
// Create extension content
let extensionContent = Self.getExtensionContent(fontsNames: fontsNames,
staticVar: staticVar,
- extensionName: extensionName)
+ extensionName: extensionName,
+ isSwiftUI: isSwiftUI)
// Write content
let extensionFilePathURL = URL(fileURLWithPath: extensionFilePath)
@@ -27,48 +43,36 @@ class FontExtensionGenerator {
}
}
- static func getExtensionContent(fontsNames: [String], staticVar: Bool, extensionName: String) -> String {
+ static func getExtensionContent(fontsNames: [String],
+ staticVar: Bool,
+ extensionName: String,
+ isSwiftUI: Bool) -> String {
[
- Self.getHeader(extensionClassname: extensionName),
+ Self.getHeader(extensionClassname: extensionName, isSwiftUI: isSwiftUI),
Self.getFontNameEnum(fontsNames: fontsNames),
- Self.getFontMethods(fontsNames: fontsNames, staticVar: staticVar),
+ Self.getFontMethods(fontsNames: fontsNames, staticVar: staticVar, isSwiftUI: isSwiftUI),
Self.getFooter()
]
.joined(separator: "\n")
}
- private static func getHeader(extensionClassname: String) -> String {
+ private static func getHeader(extensionClassname: String, isSwiftUI: Bool) -> String {
"""
// Generated by ResgenSwift.\(Fonts.toolName) \(ResgenSwiftVersion)
- import UIKit
+ import \(isSwiftUI ? "SwiftUI" : "UIKit")
extension \(extensionClassname) {\n
"""
}
- private static func getFontNameEnum(fontsNames: [String]) -> String {
- var enumDefinition = " enum FontName: String {\n"
-
- fontsNames.forEach {
- enumDefinition += " case \($0.fontNameSanitize) = \"\($0)\"\n"
- }
- enumDefinition += " }\n"
-
- return enumDefinition
- }
-
- private static func getFontMethods(fontsNames: [FontName], staticVar: Bool) -> String {
+ private static func getFontMethods(fontsNames: [FontName], staticVar: Bool, isSwiftUI: Bool) -> String {
let pragma = " // MARK: - Getter"
var propertiesOrMethods: [String] = fontsNames
.unique()
.map {
- if staticVar {
- return $0.staticProperty
- } else {
- return $0.method
- }
+ $0.getProperty(isStatic: staticVar, isSwiftUI: isSwiftUI)
}
propertiesOrMethods.insert(pragma, at: 0)
@@ -78,6 +82,7 @@ class FontExtensionGenerator {
private static func getFooter() -> String {
"""
}
+
"""
}
}
diff --git a/Sources/ResgenSwift/Fonts/Model/FontName.swift b/Sources/ResgenSwift/Fonts/Model/FontName.swift
index 7667a07..39043f9 100644
--- a/Sources/ResgenSwift/Fonts/Model/FontName.swift
+++ b/Sources/ResgenSwift/Fonts/Model/FontName.swift
@@ -14,19 +14,33 @@ extension FontName {
self.removeCharacters(from: "[]+-_")
}
- var method: String {
- """
+ func getProperty(isStatic: Bool, isSwiftUI: Bool) -> String {
+ if isSwiftUI {
+ if isStatic {
+ return """
+ static let \(fontNameSanitize): ((_ size: CGFloat) -> Font) = { size in
+ Font.custom(FontName.\(fontNameSanitize).rawValue, size: size)
+ }
+ """
+ }
+ return """
+ func \(fontNameSanitize)(withSize size: CGFloat) -> Font {
+ Font.custom(FontName.\(fontNameSanitize).rawValue, size: size)
+ }
+ """
+ }
+ // UIKit
+ if isStatic {
+ return """
+ static let \(fontNameSanitize): ((_ size: CGFloat) -> UIFont) = { size in
+ UIFont(name: FontName.\(fontNameSanitize).rawValue, size: size)!
+ }
+ """
+ }
+ return """
func \(fontNameSanitize)(withSize size: CGFloat) -> UIFont {
UIFont(name: FontName.\(fontNameSanitize).rawValue, size: size)!
}
"""
}
-
- var staticProperty: String {
- """
- static let \(fontNameSanitize): ((_ size: CGFloat) -> UIFont) = { size in
- UIFont(name: FontName.\(fontNameSanitize).rawValue, size: size)!
- }
- """
- }
}
diff --git a/Sources/ResgenSwift/Generate/Extensions/StringExtensions.swift b/Sources/ResgenSwift/Generate/Extensions/StringExtensions.swift
index 7d0468f..faa5acd 100644
--- a/Sources/ResgenSwift/Generate/Extensions/StringExtensions.swift
+++ b/Sources/ResgenSwift/Generate/Extensions/StringExtensions.swift
@@ -10,6 +10,7 @@ import Foundation
extension String {
func prependIfRelativePath(_ prependPath: String) -> String {
+ // If path starts with "/", it's an absolute path
if self.hasPrefix("/") {
return self
}
diff --git a/Sources/ResgenSwift/Generate/Generate.swift b/Sources/ResgenSwift/Generate/Generate.swift
index 54ffc43..6604ff8 100644
--- a/Sources/ResgenSwift/Generate/Generate.swift
+++ b/Sources/ResgenSwift/Generate/Generate.swift
@@ -34,11 +34,11 @@ struct Generate: ParsableCommand {
// Parse
let configuration = ConfigurationFileParser.parse(options.configurationFile)
print("Found configurations :")
- print(" - \(configuration.colors.count) colors configuration")
- print(" - \(configuration.fonts.count) fonts configuration")
- print(" - \(configuration.images.count) images configuration")
- print(" - \(configuration.strings.count) strings configuration")
- print(" - \(configuration.tags.count) tags configuration")
+ print(" - \(configuration.colors.count) colors configuration(s)")
+ print(" - \(configuration.fonts.count) fonts configuration(s)")
+ print(" - \(configuration.images.count) images configuration(s)")
+ print(" - \(configuration.strings.count) strings configuration(s)")
+ print(" - \(configuration.tags.count) tags configuration(s)")
print()
print("Input file: \(configuration.colors.first?.inputFile ?? "no input file")")
diff --git a/Sources/ResgenSwift/Generate/Model/ConfigurationFile.swift b/Sources/ResgenSwift/Generate/Model/ConfigurationFile.swift
index 7ba457f..bc405e9 100644
--- a/Sources/ResgenSwift/Generate/Model/ConfigurationFile.swift
+++ b/Sources/ResgenSwift/Generate/Model/ConfigurationFile.swift
@@ -45,6 +45,7 @@ struct ColorsConfiguration: Codable, CustomDebugStringConvertible {
let xcassetsPath: String
let extensionOutputPath: String
let extensionName: String?
+ let extensionNameSwiftUI: String?
let extensionSuffix: String?
private let staticMembers: Bool?
@@ -55,6 +56,24 @@ struct ColorsConfiguration: Codable, CustomDebugStringConvertible {
return false
}
+ internal init(inputFile: String,
+ style: String,
+ xcassetsPath: String,
+ extensionOutputPath: String,
+ extensionName: String?,
+ extensionNameSwiftUI: String?,
+ extensionSuffix: String?,
+ staticMembers: Bool?) {
+ self.inputFile = inputFile
+ self.style = style
+ self.xcassetsPath = xcassetsPath
+ self.extensionOutputPath = extensionOutputPath
+ self.extensionName = extensionName
+ self.extensionNameSwiftUI = extensionNameSwiftUI
+ self.extensionSuffix = extensionSuffix
+ self.staticMembers = staticMembers
+ }
+
var debugDescription: String {
"""
Colors configuration:
@@ -63,6 +82,7 @@ struct ColorsConfiguration: Codable, CustomDebugStringConvertible {
- Xcassets path: \(xcassetsPath)
- Extension output path: \(extensionOutputPath)
- Extension name: \(extensionName ?? "-")
+ - Extension name SwiftUI: \(extensionNameSwiftUI ?? "-")
- Extension suffix: \(extensionSuffix ?? "-")
"""
}
@@ -72,7 +92,9 @@ struct FontsConfiguration: Codable, CustomDebugStringConvertible {
let inputFile: String
let extensionOutputPath: String
let extensionName: String?
+ let extensionNameSwiftUI: String?
let extensionSuffix: String?
+ let infoPlistPaths: String?
private let staticMembers: Bool?
var staticMembersOptions: Bool {
@@ -82,13 +104,31 @@ struct FontsConfiguration: Codable, CustomDebugStringConvertible {
return false
}
+ internal init(inputFile: String,
+ extensionOutputPath: String,
+ extensionName: String?,
+ extensionNameSwiftUI: String?,
+ extensionSuffix: String?,
+ infoPlistPaths: String?,
+ staticMembers: Bool?) {
+ self.inputFile = inputFile
+ self.extensionOutputPath = extensionOutputPath
+ self.extensionName = extensionName
+ self.extensionNameSwiftUI = extensionNameSwiftUI
+ self.extensionSuffix = extensionSuffix
+ self.infoPlistPaths = infoPlistPaths
+ self.staticMembers = staticMembers
+ }
+
var debugDescription: String {
"""
Fonts configuration:
- Input file: \(inputFile)
- Extension output path: \(extensionOutputPath)
- Extension name: \(extensionName ?? "-")
+ - Extension name SwiftUI: \(extensionNameSwiftUI ?? "-")
- Extension suffix: \(extensionSuffix ?? "-")
+ - InfoPlistPaths: \(infoPlistPaths ?? "-")
"""
}
}
@@ -98,6 +138,7 @@ struct ImagesConfiguration: Codable, CustomDebugStringConvertible {
let xcassetsPath: String
let extensionOutputPath: String
let extensionName: String?
+ let extensionNameSwiftUI: String?
let extensionSuffix: String?
private let staticMembers: Bool?
@@ -108,6 +149,22 @@ struct ImagesConfiguration: Codable, CustomDebugStringConvertible {
return false
}
+ internal init(inputFile: String,
+ xcassetsPath: String,
+ extensionOutputPath: String,
+ extensionName: String?,
+ extensionNameSwiftUI: String?,
+ extensionSuffix: String?,
+ staticMembers: Bool?) {
+ self.inputFile = inputFile
+ self.xcassetsPath = xcassetsPath
+ self.extensionOutputPath = extensionOutputPath
+ self.extensionName = extensionName
+ self.extensionNameSwiftUI = extensionNameSwiftUI
+ self.extensionSuffix = extensionSuffix
+ self.staticMembers = staticMembers
+ }
+
var debugDescription: String {
"""
Images configuration:
@@ -115,6 +172,7 @@ struct ImagesConfiguration: Codable, CustomDebugStringConvertible {
- Xcassets path: \(xcassetsPath)
- Extension output path: \(extensionOutputPath)
- Extension name: \(extensionName ?? "-")
+ - Extension name SwiftUI: \(extensionNameSwiftUI ?? "-")
- Extension suffix: \(extensionSuffix ?? "-")
"""
}
@@ -137,6 +195,24 @@ struct StringsConfiguration: Codable, CustomDebugStringConvertible {
return false
}
+ internal init(inputFile: String,
+ outputPath: String,
+ langs: String,
+ defaultLang: String,
+ extensionOutputPath: String,
+ extensionName: String?,
+ extensionSuffix: String?,
+ staticMembers: Bool?) {
+ self.inputFile = inputFile
+ self.outputPath = outputPath
+ self.langs = langs
+ self.defaultLang = defaultLang
+ self.extensionOutputPath = extensionOutputPath
+ self.extensionName = extensionName
+ self.extensionSuffix = extensionSuffix
+ self.staticMembers = staticMembers
+ }
+
var debugDescription: String {
"""
Strings configuration:
@@ -166,6 +242,20 @@ struct TagsConfiguration: Codable, CustomDebugStringConvertible {
return false
}
+ internal init(inputFile: String,
+ lang: String,
+ extensionOutputPath: String,
+ extensionName: String?,
+ extensionSuffix: String?,
+ staticMembers: Bool?) {
+ self.inputFile = inputFile
+ self.lang = lang
+ self.extensionOutputPath = extensionOutputPath
+ self.extensionName = extensionName
+ self.extensionSuffix = extensionSuffix
+ self.staticMembers = staticMembers
+ }
+
var debugDescription: String {
"""
Tags configuration:
diff --git a/Sources/ResgenSwift/Generate/Runnable/ColorsConfiguration+ShellCommandable.swift b/Sources/ResgenSwift/Generate/Runnable/ColorsConfiguration+Runnable.swift
similarity index 74%
rename from Sources/ResgenSwift/Generate/Runnable/ColorsConfiguration+ShellCommandable.swift
rename to Sources/ResgenSwift/Generate/Runnable/ColorsConfiguration+Runnable.swift
index 49639b0..1965373 100644
--- a/Sources/ResgenSwift/Generate/Runnable/ColorsConfiguration+ShellCommandable.swift
+++ b/Sources/ResgenSwift/Generate/Runnable/ColorsConfiguration+Runnable.swift
@@ -9,6 +9,11 @@ import Foundation
extension ColorsConfiguration: Runnable {
func run(projectDirectory: String, force: Bool) {
+ let args = getArguments(projectDirectory: projectDirectory, force: force)
+ Colors.main(args)
+ }
+
+ func getArguments(projectDirectory: String, force: Bool) -> [String] {
var args = [String]()
if force {
@@ -33,6 +38,12 @@ extension ColorsConfiguration: Runnable {
extensionName
]
}
+ if let extensionNameSwiftUI = extensionNameSwiftUI {
+ args += [
+ "--extension-name-swift-ui",
+ extensionNameSwiftUI
+ ]
+ }
if let extensionSuffix = extensionSuffix {
args += [
"--extension-suffix",
@@ -40,6 +51,6 @@ extension ColorsConfiguration: Runnable {
]
}
- Colors.main(args)
+ return args
}
}
diff --git a/Sources/ResgenSwift/Generate/Runnable/FontsConfiguration+ShellCommandable.swift b/Sources/ResgenSwift/Generate/Runnable/FontsConfiguration+Runnable.swift
similarity index 55%
rename from Sources/ResgenSwift/Generate/Runnable/FontsConfiguration+ShellCommandable.swift
rename to Sources/ResgenSwift/Generate/Runnable/FontsConfiguration+Runnable.swift
index 4ef8aa2..2a220ac 100644
--- a/Sources/ResgenSwift/Generate/Runnable/FontsConfiguration+ShellCommandable.swift
+++ b/Sources/ResgenSwift/Generate/Runnable/FontsConfiguration+Runnable.swift
@@ -9,6 +9,11 @@ import Foundation
extension FontsConfiguration: Runnable {
func run(projectDirectory: String, force: Bool) {
+ let args = getArguments(projectDirectory: projectDirectory, force: force)
+ Fonts.main(args)
+ }
+
+ func getArguments(projectDirectory: String, force: Bool) -> [String] {
var args = [String]()
if force {
@@ -29,6 +34,12 @@ extension FontsConfiguration: Runnable {
extensionName
]
}
+ if let extensionNameSwiftUI = extensionNameSwiftUI {
+ args += [
+ "--extension-name-swift-ui",
+ extensionNameSwiftUI
+ ]
+ }
if let extensionSuffix = extensionSuffix {
args += [
@@ -37,6 +48,18 @@ extension FontsConfiguration: Runnable {
]
}
- Fonts.main(args)
+ if let infoPlistPaths = infoPlistPaths {
+ let adjustedPlistPaths = infoPlistPaths
+ .split(separator: " ")
+ .map { String($0).prependIfRelativePath(projectDirectory) }
+ .joined(separator: " ")
+
+ args += [
+ "--info-plist-paths",
+ adjustedPlistPaths
+ ]
+ }
+
+ return args
}
}
diff --git a/Sources/ResgenSwift/Generate/Runnable/ImagesConfiguration+ShellCommandable.swift b/Sources/ResgenSwift/Generate/Runnable/ImagesConfiguration+Runnable.swift
similarity index 74%
rename from Sources/ResgenSwift/Generate/Runnable/ImagesConfiguration+ShellCommandable.swift
rename to Sources/ResgenSwift/Generate/Runnable/ImagesConfiguration+Runnable.swift
index db1bb4d..03069c5 100644
--- a/Sources/ResgenSwift/Generate/Runnable/ImagesConfiguration+ShellCommandable.swift
+++ b/Sources/ResgenSwift/Generate/Runnable/ImagesConfiguration+Runnable.swift
@@ -9,6 +9,11 @@ import Foundation
extension ImagesConfiguration: Runnable {
func run(projectDirectory: String, force: Bool) {
+ let args = getArguments(projectDirectory: projectDirectory, force: force)
+ Images.main(args)
+ }
+
+ func getArguments(projectDirectory: String, force: Bool) -> [String] {
var args = [String]()
if force {
@@ -31,6 +36,12 @@ extension ImagesConfiguration: Runnable {
extensionName
]
}
+ if let extensionNameSwiftUI = extensionNameSwiftUI {
+ args += [
+ "--extension-name-swift-ui",
+ extensionNameSwiftUI
+ ]
+ }
if let extensionSuffix = extensionSuffix {
args += [
"--extension-suffix",
@@ -38,6 +49,6 @@ extension ImagesConfiguration: Runnable {
]
}
- Images.main(args)
+ return args
}
}
diff --git a/Sources/ResgenSwift/Generate/Runnable/StringsConfiguration+ShellCommandable.swift b/Sources/ResgenSwift/Generate/Runnable/StringsConfiguration+Runnable.swift
similarity index 100%
rename from Sources/ResgenSwift/Generate/Runnable/StringsConfiguration+ShellCommandable.swift
rename to Sources/ResgenSwift/Generate/Runnable/StringsConfiguration+Runnable.swift
diff --git a/Sources/ResgenSwift/Generate/Runnable/TagsConfiguration+ShellCommandable.swift b/Sources/ResgenSwift/Generate/Runnable/TagsConfiguration+Runnable.swift
similarity index 100%
rename from Sources/ResgenSwift/Generate/Runnable/TagsConfiguration+ShellCommandable.swift
rename to Sources/ResgenSwift/Generate/Runnable/TagsConfiguration+Runnable.swift
diff --git a/Sources/ResgenSwift/Images/Generator/ImageExtensionGenerator.swift b/Sources/ResgenSwift/Images/Generator/ImageExtensionGenerator.swift
index d5a9901..5edce9f 100644
--- a/Sources/ResgenSwift/Images/Generator/ImageExtensionGenerator.swift
+++ b/Sources/ResgenSwift/Images/Generator/ImageExtensionGenerator.swift
@@ -10,18 +10,20 @@ import Foundation
class ImageExtensionGenerator {
- // MARK: - pragm
+ // MARK: - UIKit
static func generateExtensionFile(images: [ParsedImage],
staticVar: Bool,
inputFilename: String,
extensionName: String,
- extensionFilePath: String) {
+ extensionFilePath: String,
+ isSwiftUI: Bool) {
// Create extension conten1t
let extensionContent = Self.getExtensionContent(images: images,
staticVar: staticVar,
extensionName: extensionName,
- inputFilename: inputFilename)
+ inputFilename: inputFilename,
+ isSwiftUI: isSwiftUI)
// Write content
let extensionFilePathURL = URL(fileURLWithPath: extensionFilePath)
@@ -34,44 +36,42 @@ class ImageExtensionGenerator {
}
}
- // MARK: - Extension content
-
- static func getExtensionContent(images: [ParsedImage], staticVar: Bool, extensionName: String, inputFilename: String) -> String {
+ static func getExtensionContent(images: [ParsedImage],
+ staticVar: Bool,
+ extensionName: String,
+ inputFilename: String,
+ isSwiftUI: Bool) -> String {
[
- Self.getHeader(inputFilename: inputFilename, extensionClassname: extensionName),
- Self.getProperties(images: images, staticVar: staticVar),
+ Self.getHeader(inputFilename: inputFilename, extensionClassname: extensionName, isSwiftUI: isSwiftUI),
+ Self.getProperties(images: images, staticVar: staticVar, isSwiftUI: isSwiftUI),
Self.getFooter()
]
.joined(separator: "\n")
}
- // MARK: - Extension part
-
- private static func getHeader(inputFilename: String, extensionClassname: String) -> String {
+ private static func getHeader(inputFilename: String,
+ extensionClassname: String,
+ isSwiftUI: Bool) -> String {
"""
// Generated by ResgenSwift.\(Images.toolName) \(ResgenSwiftVersion)
// Images from \(inputFilename)
- import UIKit
+ import \(isSwiftUI ? "SwiftUI" : "UIKit")
extension \(extensionClassname) {
"""
}
- private static func getProperties(images: [ParsedImage], staticVar: Bool) -> String {
- if staticVar {
- return images
- .map { "\n\($0.getStaticImageProperty())" }
- .joined(separator: "\n")
- }
- return images
- .map { "\n\($0.getImageProperty())" }
+ private static func getProperties(images: [ParsedImage], staticVar: Bool, isSwiftUI: Bool) -> String {
+ images
+ .map { "\n\($0.getImageProperty(isStatic: staticVar, isSwiftUI: isSwiftUI))" }
.joined(separator: "\n")
}
private static func getFooter() -> String {
"""
}
+
"""
}
}
diff --git a/Sources/ResgenSwift/Images/Images.swift b/Sources/ResgenSwift/Images/Images.swift
index f419e06..e0264aa 100644
--- a/Sources/ResgenSwift/Images/Images.swift
+++ b/Sources/ResgenSwift/Images/Images.swift
@@ -22,6 +22,7 @@ struct Images: ParsableCommand {
static let toolName = "Images"
static let defaultExtensionName = "UIImage"
+ static let defaultExtensionNameSUI = "Image"
// MARK: - Command Options
@@ -56,8 +57,15 @@ struct Images: ParsableCommand {
staticVar: options.staticMembers,
inputFilename: options.inputFilenameWithoutExt,
extensionName: options.extensionName,
- extensionFilePath: options.extensionFilePath)
+ extensionFilePath: options.extensionFilePath,
+ isSwiftUI: false)
+ ImageExtensionGenerator.generateExtensionFile(images: imagesToGenerate,
+ staticVar: options.staticMembers,
+ inputFilename: options.inputFilenameWithoutExt,
+ extensionName: options.extensionNameSwiftUI,
+ extensionFilePath: options.extensionFilePathSwiftUI,
+ isSwiftUI: true)
print("[\(Self.toolName)] Images generated")
}
@@ -81,6 +89,13 @@ struct Images: ParsableCommand {
// RSVG-Converter
_ = Images.getSvgConverterPath()
+ // Extension for UIKit and SwiftUI should have different name
+ guard options.extensionName != options.extensionNameSwiftUI else {
+ let error = ImagesError.extensionNamesCollision(options.extensionName)
+ print(error.localizedDescription)
+ Images.exit(withError: error)
+ }
+
// Check if needed to regenerate
guard GeneratorChecker.shouldGenerate(force: options.forceExecution,
inputFilePath: options.inputFile,
diff --git a/Sources/ResgenSwift/Images/ImagesError.swift b/Sources/ResgenSwift/Images/ImagesError.swift
index a425fc4..7f879ee 100644
--- a/Sources/ResgenSwift/Images/ImagesError.swift
+++ b/Sources/ResgenSwift/Images/ImagesError.swift
@@ -8,6 +8,7 @@
import Foundation
enum ImagesError: Error {
+ case extensionNamesCollision(String)
case inputFolderNotFound(String)
case fileNotExists(String)
case unknownImageExtension(String)
@@ -19,6 +20,9 @@ enum ImagesError: Error {
var localizedDescription: String {
switch self {
+ case .extensionNamesCollision(let extensionName):
+ return "error:[\(Fonts.toolName)] Error on extension names, extension name and SwiftUI extension name should be different (\(extensionName) is used on both)"
+
case .inputFolderNotFound(let inputFolder):
return " error:[\(Images.toolName)] Input folder not found: \(inputFolder)"
diff --git a/Sources/ResgenSwift/Images/ImagesOptions.swift b/Sources/ResgenSwift/Images/ImagesOptions.swift
index b36001d..453725f 100644
--- a/Sources/ResgenSwift/Images/ImagesOptions.swift
+++ b/Sources/ResgenSwift/Images/ImagesOptions.swift
@@ -27,9 +27,12 @@ struct ImagesOptions: ParsableArguments {
@Option(help: "Tell if it will generate static properties or not")
var staticMembers: Bool = false
- @Option(help: "Extension name. If not specified, it will generate an UIImage extension. Using default extension name will generate static property.")
+ @Option(help: "Extension name. If not specified, it will generate an UIImage extension.")
var extensionName: String = Images.defaultExtensionName
+ @Option(help: "Extension name. If not specified, it will generate an Image extension.")
+ var extensionNameSwiftUI: String = Images.defaultExtensionNameSUI
+
@Option(help: "Extension suffix. Ex: MyApp, it will generate {extensionName}+Image{extensionSuffix}.swift")
var extensionSuffix: String?
}
@@ -37,6 +40,9 @@ struct ImagesOptions: ParsableArguments {
// MARK: - Computed var
extension ImagesOptions {
+
+ // MARK: - UIKit
+
var extensionFileName: String {
if let extensionSuffix = extensionSuffix {
return "\(extensionName)+\(extensionSuffix).swift"
@@ -48,6 +54,21 @@ extension ImagesOptions {
"\(extensionOutputPath)/\(extensionFileName)"
}
+ // MARK: - SwiftUI
+
+ var extensionFileNameSwiftUI: String {
+ if let extensionSuffix = extensionSuffix {
+ return "\(extensionNameSwiftUI)+\(extensionSuffix).swift"
+ }
+ return "\(extensionNameSwiftUI).swift"
+ }
+
+ var extensionFilePathSwiftUI: String {
+ "\(extensionOutputPath)/\(extensionFileNameSwiftUI)"
+ }
+
+ // MARK: -
+
var inputFilenameWithoutExt: String {
URL(fileURLWithPath: inputFile)
.deletingPathExtension()
diff --git a/Sources/ResgenSwift/Images/Model/ParsedImage.swift b/Sources/ResgenSwift/Images/Model/ParsedImage.swift
index 800facb..2c42916 100644
--- a/Sources/ResgenSwift/Images/Model/ParsedImage.swift
+++ b/Sources/ResgenSwift/Images/Model/ParsedImage.swift
@@ -72,17 +72,16 @@ struct ParsedImage {
// MARK: - Extension property
- func getImageProperty() -> String {
- """
- var \(name): UIImage {
- UIImage(named: "\(name)")!
- }
- """
- }
-
- func getStaticImageProperty() -> String {
- """
- static var \(name): UIImage {
+ func getImageProperty(isStatic: Bool, isSwiftUI: Bool) -> String {
+ if isSwiftUI {
+ return """
+ \(isStatic ? "static ": "")var \(name): Image {
+ Image("\(name)")
+ }
+ """
+ }
+ return """
+ \(isStatic ? "static ": "")var \(name): UIImage {
UIImage(named: "\(name)")!
}
"""
diff --git a/Sources/ResgenSwift/Strings/Generator/StringsFileGenerator.swift b/Sources/ResgenSwift/Strings/Generator/StringsFileGenerator.swift
index 30f5009..27edcd9 100644
--- a/Sources/ResgenSwift/Strings/Generator/StringsFileGenerator.swift
+++ b/Sources/ResgenSwift/Strings/Generator/StringsFileGenerator.swift
@@ -158,6 +158,7 @@ class StringsFileGenerator {
private static func getFooter() -> String {
"""
}
+
"""
}
}
diff --git a/Sources/ResgenSwift/Strings/Generator/TagsGenerator.swift b/Sources/ResgenSwift/Strings/Generator/TagsGenerator.swift
index 2756935..15dff7f 100644
--- a/Sources/ResgenSwift/Strings/Generator/TagsGenerator.swift
+++ b/Sources/ResgenSwift/Strings/Generator/TagsGenerator.swift
@@ -80,6 +80,7 @@ class TagsGenerator {
private static func getFooter() -> String {
"""
}
+
"""
}
}
diff --git a/Sources/ResgenSwift/Strings/Stringium/StringiumOptions.swift b/Sources/ResgenSwift/Strings/Stringium/StringiumOptions.swift
index ab9e0cd..42549ba 100644
--- a/Sources/ResgenSwift/Strings/Stringium/StringiumOptions.swift
+++ b/Sources/ResgenSwift/Strings/Stringium/StringiumOptions.swift
@@ -33,7 +33,7 @@ struct StringiumOptions: ParsableArguments {
@Option(help: "Tell if it will generate static properties or not")
var staticMembers: Bool = false
- @Option(help: "Extension name. If not specified, it will generate an String extension. Using default extension name will generate static property.")
+ @Option(help: "Extension name. If not specified, it will generate an String extension.")
var extensionName: String = Stringium.defaultExtensionName
@Option(help: "Extension suffix. Ex: MyApp, it will generate {extensionName}+{extensionSuffix}.swift")
diff --git a/Sources/ResgenSwift/Strings/Tag/TagsOptions.swift b/Sources/ResgenSwift/Strings/Tag/TagsOptions.swift
index 3618ce0..e5372b9 100644
--- a/Sources/ResgenSwift/Strings/Tag/TagsOptions.swift
+++ b/Sources/ResgenSwift/Strings/Tag/TagsOptions.swift
@@ -24,7 +24,7 @@ struct TagsOptions: ParsableArguments {
@Option(help: "Tell if it will generate static properties or not")
var staticMembers: Bool = false
- @Option(help: "Extension name. If not specified, it will generate a Tag extension. Using default extension name will generate static property.")
+ @Option(help: "Extension name. If not specified, it will generate a Tag extension.")
var extensionName: String = Tags.defaultExtensionName
@Option(help: "Extension suffix. Ex: MyApp, it will generate {extensionName}+Tag{extensionSuffix}.swift")
diff --git a/Tests/ResgenSwiftTests/Colors/ColorExtensionGeneratorTests.swift b/Tests/ResgenSwiftTests/Colors/ColorExtensionGeneratorTests.swift
index 54bbded..1cf7341 100644
--- a/Tests/ResgenSwiftTests/Colors/ColorExtensionGeneratorTests.swift
+++ b/Tests/ResgenSwiftTests/Colors/ColorExtensionGeneratorTests.swift
@@ -13,7 +13,7 @@ import ToolCore
final class ColorExtensionGeneratorTests: XCTestCase {
- func testGeneratedExtensionContent() {
+ func test_uiKit_GeneratedExtensionContent() {
// Given
let colors = [
ParsedColor(name: "colorOne", light: "#FF00FF", dark: "#00FF00"),
@@ -23,7 +23,8 @@ final class ColorExtensionGeneratorTests: XCTestCase {
// When
let extensionContent = ColorExtensionGenerator.getExtensionContent(colors: colors,
staticVar: false,
- extensionName: "GenColors")
+ extensionName: "GenColors",
+ isSwiftUI: false)
// Expect
let expect = """
@@ -48,7 +49,7 @@ final class ColorExtensionGeneratorTests: XCTestCase {
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
}
- func testGeneratedExtensionContentForStaticVar() {
+ func test_uiKit_GeneratedExtensionContentForStaticVar() {
// Given
let colors = [
ParsedColor(name: "colorOne", light: "#FF00FF", dark: "#00FF00"),
@@ -58,7 +59,8 @@ final class ColorExtensionGeneratorTests: XCTestCase {
// When
let extensionContent = ColorExtensionGenerator.getExtensionContent(colors: colors,
staticVar: true,
- extensionName: "GenColor")
+ extensionName: "GenColor",
+ isSwiftUI: false)
// Expect
let expect = """
@@ -82,4 +84,76 @@ final class ColorExtensionGeneratorTests: XCTestCase {
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
}
+
+ func test_swiftUI_GeneratedExtensionContent() {
+ // Given
+ let colors = [
+ ParsedColor(name: "colorOne", light: "#FF00FF", dark: "#00FF00"),
+ ParsedColor(name: "colorTwo", light: "#F0F0F0", dark: "#0F0F0F")
+ ]
+
+ // When
+ let extensionContent = ColorExtensionGenerator.getExtensionContent(colors: colors,
+ staticVar: false,
+ extensionName: "GenColors",
+ isSwiftUI: true)
+
+ // Expect
+ let expect = """
+ // Generated by ResgenSwift.Color \(ResgenSwiftVersion)
+
+ import SwiftUI
+
+ extension GenColors {
+
+ /// Color colorOne is #FF00FF (light) or #00FF00 (dark)"
+ var colorOne: Color {
+ Color("colorOne")
+ }
+
+ /// Color colorTwo is #F0F0F0 (light) or #0F0F0F (dark)"
+ var colorTwo: Color {
+ Color("colorTwo")
+ }
+ }
+ """
+
+ XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
+ }
+
+ func test_swiftUI_GeneratedExtensionContentForStaticVar() {
+ // Given
+ let colors = [
+ ParsedColor(name: "colorOne", light: "#FF00FF", dark: "#00FF00"),
+ ParsedColor(name: "colorTwo", light: "#F0F0F0", dark: "#0F0F0F")
+ ]
+
+ // When
+ let extensionContent = ColorExtensionGenerator.getExtensionContent(colors: colors,
+ staticVar: true,
+ extensionName: "GenColor",
+ isSwiftUI: true)
+
+ // Expect
+ let expect = """
+ // Generated by ResgenSwift.Color \(ResgenSwiftVersion)
+
+ import SwiftUI
+
+ extension GenColor {
+
+ /// Color colorOne is #FF00FF (light) or #00FF00 (dark)"
+ static var colorOne: Color {
+ Color("colorOne")
+ }
+
+ /// Color colorTwo is #F0F0F0 (light) or #0F0F0F (dark)"
+ static var colorTwo: Color {
+ Color("colorTwo")
+ }
+ }
+ """
+
+ XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
+ }
}
diff --git a/Tests/ResgenSwiftTests/Colors/ParsedColorTests.swift b/Tests/ResgenSwiftTests/Colors/ParsedColorTests.swift
index ec1f16c..cd9e45e 100644
--- a/Tests/ResgenSwiftTests/Colors/ParsedColorTests.swift
+++ b/Tests/ResgenSwiftTests/Colors/ParsedColorTests.swift
@@ -12,12 +12,12 @@ import XCTest
final class ParsedColorTests: XCTestCase {
- func testGeneratedProperty() {
+ func test_uiKit_GeneratedProperty() {
// Given
let color = ParsedColor(name: "red", light: "#FF0000", dark: "#0000FF")
// When
- let property = color.getColorProperty()
+ let property = color.getColorProperty(isStatic: false, isSwiftUI: false)
// Expect
let expect = """
@@ -30,12 +30,12 @@ final class ParsedColorTests: XCTestCase {
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
}
- func testGeneratedStaticProperty() {
+ func test_uiKit_GeneratedStaticProperty() {
// Given
let color = ParsedColor(name: "red", light: "#FF0000", dark: "#0000FF")
// When
- let property = color.getColorStaticProperty()
+ let property = color.getColorProperty(isStatic: true, isSwiftUI: false)
// Expect
let expect = """
@@ -48,6 +48,42 @@ final class ParsedColorTests: XCTestCase {
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
}
+ func test_swiftUI_GeneratedProperty() {
+ // Given
+ let color = ParsedColor(name: "red", light: "#FF0000", dark: "#0000FF")
+
+ // When
+ let property = color.getColorProperty(isStatic: false, isSwiftUI: true)
+
+ // Expect
+ let expect = """
+ /// Color red is #FF0000 (light) or #0000FF (dark)"
+ var red: Color {
+ Color("red")
+ }
+ """
+
+ XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
+ }
+
+ func test_swiftUI_GeneratedStaticProperty() {
+ // Given
+ let color = ParsedColor(name: "red", light: "#FF0000", dark: "#0000FF")
+
+ // When
+ let property = color.getColorProperty(isStatic: true, isSwiftUI: true)
+
+ // Expect
+ let expect = """
+ /// Color red is #FF0000 (light) or #0000FF (dark)"
+ static var red: Color {
+ Color("red")
+ }
+ """
+
+ XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
+ }
+
func testGeneratedColorAsset() {
// Given
let color = ParsedColor(name: "red", light: "#FF0000", dark: "#0000FF")
diff --git a/Tests/ResgenSwiftTests/Fonts/FontExtensionGeneratorTests.swift b/Tests/ResgenSwiftTests/Fonts/FontExtensionGeneratorTests.swift
index 8ea70f1..2093f09 100644
--- a/Tests/ResgenSwiftTests/Fonts/FontExtensionGeneratorTests.swift
+++ b/Tests/ResgenSwiftTests/Fonts/FontExtensionGeneratorTests.swift
@@ -13,7 +13,7 @@ import ToolCore
final class FontExtensionGeneratorTests: XCTestCase {
- func testGeneratedExtensionContent() {
+ func test_uiKit_GeneratedExtensionContent() {
// Given
let fontNames: [FontName] = [
"CircularStd-Regular",
@@ -23,7 +23,8 @@ final class FontExtensionGeneratorTests: XCTestCase {
// When
let extensionContent = FontExtensionGenerator.getExtensionContent(fontsNames: fontNames,
staticVar: false,
- extensionName: "GenFonts")
+ extensionName: "GenFonts",
+ isSwiftUI: false)
// Expect
let expect = """
@@ -53,5 +54,47 @@ final class FontExtensionGeneratorTests: XCTestCase {
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
}
+
+ func test_swiftUI_GeneratedExtensionContent() {
+ // Given
+ let fontNames: [FontName] = [
+ "CircularStd-Regular",
+ "CircularStd-Bold"
+ ]
+
+ // When
+ let extensionContent = FontExtensionGenerator.getExtensionContent(fontsNames: fontNames,
+ staticVar: false,
+ extensionName: "GenFonts",
+ isSwiftUI: true)
+
+ // Expect
+ let expect = """
+ // Generated by ResgenSwift.Fonts \(ResgenSwiftVersion)
+
+ import SwiftUI
+
+ extension GenFonts {
+
+ enum FontName: String {
+ case CircularStdRegular = "CircularStd-Regular"
+ case CircularStdBold = "CircularStd-Bold"
+ }
+
+ // MARK: - Getter
+
+ func CircularStdRegular(withSize size: CGFloat) -> Font {
+ Font.custom(FontName.CircularStdRegular.rawValue, size: size)
+ }
+
+ func CircularStdBold(withSize size: CGFloat) -> Font {
+ Font.custom(FontName.CircularStdBold.rawValue, size: size)
+ }
+
+ }
+ """
+
+ XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
+ }
}
diff --git a/Tests/ResgenSwiftTests/Fonts/FontNameTests.swift b/Tests/ResgenSwiftTests/Fonts/FontNameTests.swift
index 03a09a2..80f3883 100644
--- a/Tests/ResgenSwiftTests/Fonts/FontNameTests.swift
+++ b/Tests/ResgenSwiftTests/Fonts/FontNameTests.swift
@@ -12,12 +12,12 @@ import XCTest
final class FontNameTests: XCTestCase {
- func testGeneratedProperty_noForbiddenCharacter() {
+ func test_uiKit_GeneratedProperty_noForbiddenCharacter() {
// Given
let fontName: FontName = "CircularStdBold"
// When
- let property = fontName.staticProperty
+ let property = fontName.getProperty(isStatic: true, isSwiftUI: false)
// Expect
let expect = """
@@ -29,12 +29,12 @@ final class FontNameTests: XCTestCase {
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
}
- func testGeneratedProperty_withForbiddenCharacter() {
+ func test_uiKit_GeneratedProperty_withForbiddenCharacter() {
// Given
let fontName: FontName = "[Circular_Std+Bold-Underline]"
// When
- let property = fontName.staticProperty
+ let property = fontName.getProperty(isStatic: true, isSwiftUI: false)
// Expect
let expect = """
@@ -46,12 +46,12 @@ final class FontNameTests: XCTestCase {
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
}
- func testGeneratedMethod_noForbiddenCharacter() {
+ func test_uiKit_GeneratedMethod_noForbiddenCharacter() {
// Given
let fontName: FontName = "CircularStdBold"
// When
- let property = fontName.method
+ let property = fontName.getProperty(isStatic: false, isSwiftUI: false)
// Expect
let expect = """
@@ -63,12 +63,12 @@ final class FontNameTests: XCTestCase {
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
}
- func testGeneratedMethod_withForbiddenCharacter() {
+ func test_uiKit_GeneratedMethod_withForbiddenCharacter() {
// Given
let fontName: FontName = "[Circular_Std+Bold-Underline]"
// When
- let property = fontName.method
+ let property = fontName.getProperty(isStatic: false, isSwiftUI: false)
// Expect
let expect = """
@@ -79,5 +79,72 @@ final class FontNameTests: XCTestCase {
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
}
+
+ func test_swiftUI_GeneratedProperty_noForbiddenCharacter() {
+ // Given
+ let fontName: FontName = "CircularStdBold"
+
+ // When
+ let property = fontName.getProperty(isStatic: true, isSwiftUI: true)
+
+ // Expect
+ let expect = """
+ static let CircularStdBold: ((_ size: CGFloat) -> Font) = { size in
+ Font.custom(FontName.CircularStdBold.rawValue, size: size)
+ }
+ """
+
+ XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
+ }
+ func test_swiftUI_GeneratedProperty_withForbiddenCharacter() {
+ // Given
+ let fontName: FontName = "[Circular_Std+Bold-Underline]"
+
+ // When
+ let property = fontName.getProperty(isStatic: true, isSwiftUI: true)
+
+ // Expect
+ let expect = """
+ static let CircularStdBoldUnderline: ((_ size: CGFloat) -> Font) = { size in
+ Font.custom(FontName.CircularStdBoldUnderline.rawValue, size: size)
+ }
+ """
+
+ XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
+ }
+
+ func test_swiftUI_GeneratedMethod_noForbiddenCharacter() {
+ // Given
+ let fontName: FontName = "CircularStdBold"
+
+ // When
+ let property = fontName.getProperty(isStatic: false, isSwiftUI: true)
+
+ // Expect
+ let expect = """
+ func CircularStdBold(withSize size: CGFloat) -> Font {
+ Font.custom(FontName.CircularStdBold.rawValue, size: size)
+ }
+ """
+
+ XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
+ }
+
+ func test_swiftUI_GeneratedMethod_withForbiddenCharacter() {
+ // Given
+ let fontName: FontName = "[Circular_Std+Bold-Underline]"
+
+ // When
+ let property = fontName.getProperty(isStatic: false, isSwiftUI: true)
+
+ // Expect
+ let expect = """
+ func CircularStdBoldUnderline(withSize size: CGFloat) -> Font {
+ Font.custom(FontName.CircularStdBoldUnderline.rawValue, size: size)
+ }
+ """
+
+ XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
+ }
}
diff --git a/Tests/ResgenSwiftTests/Fonts/FontPlistGeneratorTests.swift b/Tests/ResgenSwiftTests/Fonts/FontPlistGeneratorTests.swift
index 0bab9f0..8c86ca5 100644
--- a/Tests/ResgenSwiftTests/Fonts/FontPlistGeneratorTests.swift
+++ b/Tests/ResgenSwiftTests/Fonts/FontPlistGeneratorTests.swift
@@ -19,7 +19,7 @@ final class FontPlistGeneratorTests: XCTestCase {
]
// When
- let plistContent = FontPlistGenerator.generatePlistUIAppsFontContent(for: fontNames)
+ let plistContent = FontPlistGenerator.generatePlistUIAppsFontContent(for: fontNames, infoPlistPaths: [String]())
// Expect
let expect = """
diff --git a/Tests/ResgenSwiftTests/Generate/ColorsConfigurationTests.swift b/Tests/ResgenSwiftTests/Generate/ColorsConfigurationTests.swift
new file mode 100644
index 0000000..ded33fc
--- /dev/null
+++ b/Tests/ResgenSwiftTests/Generate/ColorsConfigurationTests.swift
@@ -0,0 +1,81 @@
+//
+// ColorsConfigurationTests.swift
+//
+//
+// Created by Thibaut Schmitt on 04/11/2022.
+//
+
+import Foundation
+import XCTest
+
+@testable import ResgenSwift
+
+final class ColorsConfigurationTests: XCTestCase {
+
+ let projectDirectory = "projectDirectory/"
+
+ func test_argsGeneration_requiredArgs() {
+ // Given
+ let testingConfiguration = ColorsConfiguration(inputFile: "path/to/colors.txt",
+ style: ColorStyle.all.rawValue,
+ xcassetsPath: "path/to/assets.xcassets",
+ extensionOutputPath: "Colors/Generated",
+ extensionName: nil,
+ extensionNameSwiftUI: nil,
+ extensionSuffix: nil,
+ staticMembers: false)
+ // When
+ let arguments = testingConfiguration.getArguments(projectDirectory: projectDirectory, force: false)
+
+ // Expect
+ let expectedArguments = [
+ "projectDirectory/path/to/colors.txt",
+ "--style",
+ "all",
+ "--xcassets-path",
+ "projectDirectory/path/to/assets.xcassets",
+ "--extension-output-path",
+ "projectDirectory/Colors/Generated",
+ "--static-members",
+ "false"
+ ]
+
+ XCTAssertEqual(arguments, expectedArguments)
+ }
+
+ func test_argsGeneration_allArguments() {
+ // Given
+ let testingConfiguration = ColorsConfiguration(inputFile: "path/to/colors.txt",
+ style: ColorStyle.all.rawValue,
+ xcassetsPath: "path/to/assets.xcassets",
+ extensionOutputPath: "Colors/Generated",
+ extensionName: "AppUIColor",
+ extensionNameSwiftUI: "AppColor",
+ extensionSuffix: "Testing",
+ staticMembers: false)
+ // When
+ let arguments = testingConfiguration.getArguments(projectDirectory: projectDirectory, force: true)
+
+ // Expect
+ let expectedArguments = [
+ "-f",
+ "projectDirectory/path/to/colors.txt",
+ "--style",
+ "all",
+ "--xcassets-path",
+ "projectDirectory/path/to/assets.xcassets",
+ "--extension-output-path",
+ "projectDirectory/Colors/Generated",
+ "--static-members",
+ "false",
+ "--extension-name",
+ "AppUIColor",
+ "--extension-name-swift-ui",
+ "AppColor",
+ "--extension-suffix",
+ "Testing",
+ ]
+
+ XCTAssertEqual(arguments, expectedArguments)
+ }
+}
diff --git a/Tests/ResgenSwiftTests/Generate/FontsConfigurationTests.swift b/Tests/ResgenSwiftTests/Generate/FontsConfigurationTests.swift
new file mode 100644
index 0000000..1c9757d
--- /dev/null
+++ b/Tests/ResgenSwiftTests/Generate/FontsConfigurationTests.swift
@@ -0,0 +1,73 @@
+//
+// FontsConfigurationTests.swift
+//
+//
+// Created by Thibaut Schmitt on 04/11/2022.
+//
+
+import Foundation
+import XCTest
+
+@testable import ResgenSwift
+
+final class FontsConfigurationTests: XCTestCase {
+
+ let projectDirectory = "projectDirectory/"
+
+ func test_argsGeneration_requiredArgs() {
+ // Given
+ let testingConfiguration = FontsConfiguration(inputFile: "path/to/fonts.txt",
+ extensionOutputPath: "Fonts/Generated",
+ extensionName: nil,
+ extensionNameSwiftUI: nil,
+ extensionSuffix: nil,
+ infoPlistPaths: nil,
+ staticMembers: nil)
+ // When
+ let arguments = testingConfiguration.getArguments(projectDirectory: projectDirectory, force: false)
+
+ // Expect
+ let expectedArguments = [
+ "projectDirectory/path/to/fonts.txt",
+ "--extension-output-path",
+ "projectDirectory/Fonts/Generated",
+ "--static-members",
+ "false"
+ ]
+
+ XCTAssertEqual(arguments, expectedArguments)
+ }
+
+ func test_argsGeneration_allArguments() {
+ // Given
+ let testingConfiguration = FontsConfiguration(inputFile: "path/to/fonts.txt",
+ extensionOutputPath: "Fonts/Generated",
+ extensionName: "AppUIFont",
+ extensionNameSwiftUI: "AppFont",
+ extensionSuffix: "Testing",
+ infoPlistPaths: "path/to/plist1.plist path/to/plist2.plist",
+ staticMembers: true)
+ // When
+ let arguments = testingConfiguration.getArguments(projectDirectory: projectDirectory, force: true)
+
+ // Expect
+ let expectedArguments = [
+ "-f",
+ "projectDirectory/path/to/fonts.txt",
+ "--extension-output-path",
+ "projectDirectory/Fonts/Generated",
+ "--static-members",
+ "true",
+ "--extension-name",
+ "AppUIFont",
+ "--extension-name-swift-ui",
+ "AppFont",
+ "--extension-suffix",
+ "Testing",
+ "--info-plist-paths",
+ "projectDirectory/path/to/plist1.plist projectDirectory/path/to/plist2.plist"
+ ]
+
+ XCTAssertEqual(arguments, expectedArguments)
+ }
+}
diff --git a/Tests/ResgenSwiftTests/Generate/ImagesConfigurationTests.swift b/Tests/ResgenSwiftTests/Generate/ImagesConfigurationTests.swift
new file mode 100644
index 0000000..84c94e1
--- /dev/null
+++ b/Tests/ResgenSwiftTests/Generate/ImagesConfigurationTests.swift
@@ -0,0 +1,78 @@
+//
+// ImagesConfigurationTests.swift
+//
+//
+// Created by Thibaut Schmitt on 04/11/2022.
+//
+
+import Foundation
+import XCTest
+
+@testable import ResgenSwift
+
+final class ImagesConfigurationTests: XCTestCase {
+
+ let projectDirectory = "projectDirectory/"
+
+ func test_argsGeneration_requiredArgs() {
+ // Given
+ let testingConfiguration = ImagesConfiguration(inputFile: "path/to/images.txt",
+ xcassetsPath: "path/to/assets.xcassets",
+ extensionOutputPath: "Images/Generated",
+ extensionName: nil,
+ extensionNameSwiftUI: nil,
+ extensionSuffix: nil,
+ staticMembers: nil)
+
+ // When
+ let arguments = testingConfiguration.getArguments(projectDirectory: projectDirectory, force: false)
+
+ // Expect
+ let expectedArguments = [
+ "projectDirectory/path/to/images.txt",
+ "--xcassets-path",
+ "projectDirectory/path/to/assets.xcassets",
+ "--extension-output-path",
+ "projectDirectory/Images/Generated",
+ "--static-members",
+ "false"
+ ]
+
+ XCTAssertEqual(arguments, expectedArguments)
+ }
+
+ func test_argsGeneration_allArguments() {
+ // Given
+ let testingConfiguration = ImagesConfiguration(inputFile: "path/to/images.txt",
+ xcassetsPath: "path/to/assets.xcassets",
+ extensionOutputPath: "Images/Generated",
+ extensionName: "AppUIImage",
+ extensionNameSwiftUI: "AppImage",
+ extensionSuffix: "Testing",
+ staticMembers: true)
+
+ // When
+ let arguments = testingConfiguration.getArguments(projectDirectory: projectDirectory, force: true)
+
+ // Expect
+ let expectedArguments = [
+ "-f",
+ "projectDirectory/path/to/images.txt",
+ "--xcassets-path",
+ "projectDirectory/path/to/assets.xcassets",
+ "--extension-output-path",
+ "projectDirectory/Images/Generated",
+ "--static-members",
+ "true",
+ "--extension-name",
+ "AppUIImage",
+ "--extension-name-swift-ui",
+ "AppImage",
+ "--extension-suffix",
+ "Testing",
+ ]
+
+ XCTAssertEqual(arguments, expectedArguments)
+ }
+}
+
diff --git a/Tests/ResgenSwiftTests/Images/ImageExtensionGeneratorTests.swift b/Tests/ResgenSwiftTests/Images/ImageExtensionGeneratorTests.swift
index c8bf707..2e2fd7d 100644
--- a/Tests/ResgenSwiftTests/Images/ImageExtensionGeneratorTests.swift
+++ b/Tests/ResgenSwiftTests/Images/ImageExtensionGeneratorTests.swift
@@ -13,7 +13,7 @@ import ToolCore
final class ImageExtensionGeneratorTests: XCTestCase {
- func testGeneratedExtensionContent() {
+ func test_uiKit_GeneratedExtensionContent() {
// Given
let images = [
ParsedImage(name: "image_one", tags: "id", width: 10, height: 10),
@@ -24,7 +24,8 @@ final class ImageExtensionGeneratorTests: XCTestCase {
let extensionContent = ImageExtensionGenerator.getExtensionContent(images: images,
staticVar: false,
extensionName: "GenImages",
- inputFilename: "myInputFilename")
+ inputFilename: "myInputFilename",
+ isSwiftUI: false)
// Expect
let expect = """
@@ -48,7 +49,7 @@ final class ImageExtensionGeneratorTests: XCTestCase {
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
}
- func testGeneratedExtensionContentForStaticVar() {
+ func test_uiKit_GeneratedExtensionContentForStaticVar() {
// Given
let images = [
ParsedImage(name: "image_one", tags: "id", width: 10, height: 10),
@@ -59,7 +60,8 @@ final class ImageExtensionGeneratorTests: XCTestCase {
let extensionContent = ImageExtensionGenerator.getExtensionContent(images: images,
staticVar: true,
extensionName: "GenImages",
- inputFilename: "myInputFilename")
+ inputFilename: "myInputFilename",
+ isSwiftUI: false)
// Expect
let expect = """
@@ -82,4 +84,76 @@ final class ImageExtensionGeneratorTests: XCTestCase {
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
}
+
+ func test_swiftUI_GeneratedExtensionContent() {
+ // Given
+ let images = [
+ ParsedImage(name: "image_one", tags: "id", width: 10, height: 10),
+ ParsedImage(name: "image_two", tags: "id", width: 180, height: 90),
+ ]
+
+ // When
+ let extensionContent = ImageExtensionGenerator.getExtensionContent(images: images,
+ staticVar: false,
+ extensionName: "GenImages",
+ inputFilename: "myInputFilename",
+ isSwiftUI: true)
+
+ // Expect
+ let expect = """
+ // Generated by ResgenSwift.Images \(ResgenSwiftVersion)
+ // Images from myInputFilename
+
+ import SwiftUI
+
+ extension GenImages {
+
+ var image_one: Image {
+ Image("image_one")
+ }
+
+ var image_two: Image {
+ Image("image_two")
+ }
+ }
+ """
+
+ XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
+ }
+
+ func test_swiftUI_GeneratedExtensionContentForStaticVar() {
+ // Given
+ let images = [
+ ParsedImage(name: "image_one", tags: "id", width: 10, height: 10),
+ ParsedImage(name: "image_two", tags: "id", width: 180, height: 90),
+ ]
+
+ // When
+ let extensionContent = ImageExtensionGenerator.getExtensionContent(images: images,
+ staticVar: true,
+ extensionName: "GenImages",
+ inputFilename: "myInputFilename",
+ isSwiftUI: true)
+
+ // Expect
+ let expect = """
+ // Generated by ResgenSwift.Images \(ResgenSwiftVersion)
+ // Images from myInputFilename
+
+ import SwiftUI
+
+ extension GenImages {
+
+ static var image_one: Image {
+ Image("image_one")
+ }
+
+ static var image_two: Image {
+ Image("image_two")
+ }
+ }
+ """
+
+ XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
+ }
}
diff --git a/Tests/ResgenSwiftTests/Images/ParsedImageTests.swift b/Tests/ResgenSwiftTests/Images/ParsedImageTests.swift
index a45be87..b4a8093 100644
--- a/Tests/ResgenSwiftTests/Images/ParsedImageTests.swift
+++ b/Tests/ResgenSwiftTests/Images/ParsedImageTests.swift
@@ -34,7 +34,7 @@ final class ParsedImageTests: XCTestCase {
XCTAssertEqual(convertArguments.x3.height, "30")
}
- func testGeneratedProperty() {
+ func test_uiKit_GeneratedProperty() {
// Given
let imageName = "the_name"
let parsedImage = ParsedImage(name: imageName,
@@ -43,7 +43,7 @@ final class ParsedImageTests: XCTestCase {
height: 10)
// When
- let property = parsedImage.getImageProperty()
+ let property = parsedImage.getImageProperty(isStatic: false, isSwiftUI: false)
// Expect
let expect = """
@@ -55,7 +55,7 @@ final class ParsedImageTests: XCTestCase {
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
}
- func testGeneratedStaticProperty() {
+ func test_uiKit_GeneratedStaticProperty() {
// Given
let imageName = "the_name"
let parsedImage = ParsedImage(name: imageName,
@@ -64,7 +64,7 @@ final class ParsedImageTests: XCTestCase {
height: 10)
// When
- let property = parsedImage.getStaticImageProperty()
+ let property = parsedImage.getImageProperty(isStatic: true, isSwiftUI: false)
// Expect
let expect = """
@@ -76,6 +76,48 @@ final class ParsedImageTests: XCTestCase {
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
}
+ func test_swiftUI_GeneratedProperty() {
+ // Given
+ let imageName = "the_name"
+ let parsedImage = ParsedImage(name: imageName,
+ tags: "id",
+ width: 10,
+ height: 10)
+
+ // When
+ let property = parsedImage.getImageProperty(isStatic: false, isSwiftUI: true)
+
+ // Expect
+ let expect = """
+ var \(imageName): Image {
+ Image("\(imageName)")
+ }
+ """
+
+ XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
+ }
+
+ func test_swiftUI_GeneratedStaticProperty() {
+ // Given
+ let imageName = "the_name"
+ let parsedImage = ParsedImage(name: imageName,
+ tags: "id",
+ width: 10,
+ height: 10)
+
+ // When
+ let property = parsedImage.getImageProperty(isStatic: true, isSwiftUI: true)
+
+ // Expect
+ let expect = """
+ static var \(imageName): Image {
+ Image("\(imageName)")
+ }
+ """
+
+ XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
+ }
+
func testAssetContentJson() {
// Given
let imageName = "the_name"
diff --git a/install-completion.sh b/install-completion.sh
new file mode 100755
index 0000000..de8cd5d
--- /dev/null
+++ b/install-completion.sh
@@ -0,0 +1,13 @@
+#!/bin/zsh
+
+if [[ $SHELL == "/bin/zsh" ]]
+then
+ if [ ! -d "~/.oh-my-zsh/completions" ]
+ then
+ mkdir -p ~/.oh-my-zsh/completions
+ fi
+ resgen-swift --generate-completion-script zsh > ~/.oh-my-zsh/completions/_resgen-swift
+else
+ echo "Completion file can only be installed automaticaly for oh-my-zsh shell. See https://apple.github.io/swift-argument-parser/documentation/argumentparser/installingcompletionscripts to install it ti your shell"
+fi
+
diff --git a/install.sh b/install.sh
deleted file mode 100755
index 361f03a..0000000
--- a/install.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/zsh
-
-swift build -c release
-cp .build/release/ResgenSwift /usr/local/bin/ResgenSwift
\ No newline at end of file