$ ibgenerate help
Available commands:
help Display general or command-specific help
generate Generate code (default command)
version Display the current version of ibgenerate
Generate command
In your working directory, or by passing the path option, launch the command to see the generated code.
You can redirect the ouput to a Storyboards.swift file, like done in next step.
Xcode integration
Add a Run Script Phase to integrate IBGenerate with Xcode to generate the Storyboards.swift
if which ibgenerate >/dev/null; then
echo "ibgenerate: Determining if generated Swift file is up-to-date."
BASE_PATH="$PROJECT_DIR/$PROJECT_NAME"
OUTPUT_PATH="$BASE_PATH/Storyboards.swift"
if [ ! -e "$OUTPUT_PATH" ] || [ -n "$(find "$BASE_PATH" -type f -name "*.storyboard" -newer "$OUTPUT_PATH" -print -quit)" ]; then
echo "ibgenerate: Generated Swift is out-of-date; re-generating..."
/usr/bin/chflags nouchg "$OUTPUT_PATH"
ibgenerate > "$OUTPUT_PATH"
/usr/bin/chflags uchg "$OUTPUT_PATH"
echo "ibgenerate: Done."
else
echo "ibgenerate: Generated Swift is up-to-date; skipping re-generation."
fi
else
echo "warning: IBGenerate not installed, download from https://github.com/IBDecodable/IBGenerate"
fi
You can configure to generate a swift file by target using the storyboard referenced in build phases targets.
xcodeTarget: true
Requirements
IBGenerate requires Swift5.0 runtime. Please satisfy at least one of following requirements.
IBGenerate
A tool to generate a code from your
.storyboardfiles to reduce the usage ofStringas identifiers for Segues or Storyboards.ibgeneratework only foriOSfor the moment.What the command generate exactly?
Storyboards list
A
Storyboardsstruct with convenient functions to instanciate your view controllers.Instantiate initial view controller for storyboard
Enumeration for segues
Enum that you can use with
IBStoryboardfunctionEnumeration for named colors
Storyboard could use named colors, and sometimes you need it also in your code and do not want to use the string. So an enum is generated.
Could be desactivated in configuration file
This also could be generated by reading xcode assets.
Install ibgenerate
Using sources
Using Homebrew (swiftbrew)
If not already installed yet, install Swiftbrew with Homebrew
then type
Usage
You can see all description by
ibgenerate helpGenerate command
In your working directory, or by passing the
pathoption, launch the command to see the generated code.You can redirect the ouput to a
Storyboards.swiftfile, like done in next step.Xcode integration
Add a
Run Script Phaseto integrate IBGenerate with Xcode to generate theStoryboards.swiftYou can configure to generate a swift file by target using the storyboard referenced in build phases targets.
Requirements
IBGenerate requires Swift5.0 runtime. Please satisfy at least one of following requirements.
Swift 5 Runtime Support for Command Line Toolsfrom More Downloads for Apple DevelopersConfiguration
You can configure IBGenerate by adding a
.ibgenerate.ymlfile from project root directory.excludedincludedcolorimportsxcodeTargetAcknowledgement
This projects is heavily inspired by natalie @Marcin Krzyżanowski
I ,phimage, do some work on it,
macOScompatibility, and decode storyboard into objects, etc…The main difference is that this project only generate the dynamic part of the code, the code generated from your storyboards.
The common code is in IBStoryboard package and could be imported using SwiftPM.
Then
ibgenerateis more configurable to add new features.