5.8 KiB
ResgenSwift
ResgenSwift is a package, fully written in Swift, to help you automatize ressource update and generation.
🧐 For all commands, see samples files in
SampleFiles
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
.
Example
swift run -c release FontTool $FORCE_FLAG "./Fonts/fonts.txt" \
--extension-output-path "./Fonts/Generated" \
--extension-name "AppFont" \
--extension-suffix "GreatApp"
Parameters
-f
: force generation- Font input folder, it will search for every
.ttf
and.otf
files specified infonts.txt
--extension-output-path
: path where to generate generated extension--extension-name
(optional) : name of thee class to add the extension--extension-suffix
(optional) : additional text which is added to the filename (ex:AppFont+GreatApp.swift
)
⚠️ If extension name is not set or is
UIFont
, it will generate static property onUIFont
instead of method in your custom class.
Colors
Colors generator generates an extension of UIColor
(or a custom class) along with colorsets in specified xcassets.
swift run -c release ColorTool $FORCE_FLAG "./Colors/colors.txt" \
--style all \
--xcassets-path "./Colors/colors.xcassets" \
--extension-output-path "./Colors/Generated/" \
--extension-name "AppColor" \
--extension-suffix "GreatApp"
Parameters
-f
: force generation- Input colors file
--style
can beall
orlight
--extension-output-path
: path where to generate generated extension--extension-name
(optional) : name of class to add the extension--extension-suffix
(optional) : additional text which is added to filename (ex:AppColor+GreatApp.swift
)
⚠️ If extension name is not set or is
UIColor
, it will generate static property onUIColor
.
Strings
Strings command allows to generate strings
files along with extensions to access those strings easily. It can do it 2 ways: Twine and Stringium. It is not recommended to use Twine except on legacy projects or while migrating to ResgenSwift, because it use https://github.com/openium/twine. Using Stringium is recommended because it does not required external dependency and allow more customisation.
Twine (not recommended)
swift run -c release Strings twine $FORCE_FLAG "./Twine/strings.txt" \
--output-path "./Twine/Generated" \
--langs "fr en en-us" \
--default-lang "en" \
--extension-output-path "./Twine/Generated"
Parameters
-f
: force generation- Input translations file (must be Twine formatted)
--langs
: langs to generate (string with space between each lang)--default-lang
: default lang that will be inBase.lproj
. It must be inlangs
as well--extension-output-path
: path where to generate generated extension
Stringium (recommended)
swift run -c release Strings stringium $FORCE_FLAG "./Strings/strings.txt" \
--output-path "./Strings/Generated" \
--langs "fr en en-us" \
--default-lang "en" \
--extension-output-path "./Strings/Generated" \
--extension-name "AppString" \
--extension-suffix "GreatApp"
Parameters
-f
: force generation- Input translations file (must be Twine formatted)
--langs
: langs to generate (string with space between each lang)--default-lang
: default lang that will be inBase.lproj
. It must be inlangs
as well--extension-output-path
: path where to generate generated extension--extension-name
(optional) : name of class to add the extension--extension-suffix
(optional) : additional text which is added to filename (ex:AppString+GreatApp.swift
)
⚠️ If extension name is not set or is
String
, it will generate static property onString
.
Tags
Tags is also a subcommand of Strings
. Input files are formatted the same way. Tags will generate properties which return exactly what is specified in the input file. It was designed to be used for analytics purpose and to be shared with any other platform to have the same analytics keys.
swift run -c release Strings tags $FORCE_FLAG "./Tags/tags.txt" \
--lang "ium" \
--extension-output-path "./Tags/Generated" \
--extension-name "AppTags" \
--extension-suffix "GreatApp"
Parameters
-f
: force generation- Input tags file (must be Twine formatted)
--lang
: langs to look at in input file--extension-output-path
: path where to generate generated extension--extension-name
(optional) : name of class to add the extension--extension-suffix
(optional) : additional text which is added to filename (ex:AppTags+GreatApp.swift
)
⚠️ If extension name is not set or is
Tags
, it will generate static property onTags
. This class may not exists in your project, just create an empty class namedTags
is necessary.
Images
Images generator will generate images assets along with extensions to access those images easily.
swift run -c release Imagium $FORCE_FLAG "./Images/images.txt" \
--xcassets-path "./Images/app.xcassets" \
--extension-output-path "./Images/Generated" \
--extension-name "AppImage" \
--extension-suffix "GreatApp"
Parameters
-f
: force generation- Input images definitions file
--xcassets-path
: xcasset path where to generate imagesets--extension-output-path
: path where to generate generated extension--extension-name
(optional) : name of class to add the extension--extension-suffix
(optional) : additional text which is added to filename (ex:AppImage+GreatApp.swift
)
⚠️ If extension name is not set or is
UIImage
, it will generate static property onUIImage
.
TODO
[ ] Allow static variable generation on custom extension