Skip to content
This repository has been archived by the owner on Sep 6, 2019. It is now read-only.

Regenerate Storyboards.swift only if needed #60

Closed
Frizlab opened this issue Jul 19, 2015 · 2 comments
Closed

Regenerate Storyboards.swift only if needed #60

Frizlab opened this issue Jul 19, 2015 · 2 comments

Comments

@Frizlab
Copy link
Contributor

Frizlab commented Jul 19, 2015

The proposed run script build phase in the Readme will re-generate Storyboards.swift at each build.
The generation in itself is long. Add to this that Xcode have to re-compile the generated file each time, it took me three builds to get annoyed…

Here’s a proposed script that detects whether re-generating the file is actually needed before re-generating it.

echo "Natalie Generator: Determining if generated Swift file is up-to-date."

NATALIE_PATH="$PROJECT_DIR/Dependencies/natalie/natalie.swift"

GO=0
BASE_PATH="$PROJECT_DIR/$PROJECT_NAME"
OUTPUT_PATH="$BASE_PATH/Storyboards.swift"
if [ ! -e "$OUTPUT_PATH" ]; then
    GO=1
elif [ -n "$(find "$BASE_PATH" -type f -name "*.storyboard" -newer "$OUTPUT_PATH" -print -quit)" ]; then
    GO=1
fi

if [ $GO -eq 1 ]; then
    echo "Natalie Generator: Generated Swift is out-of-date; re-generating..."
    "$NATALIE_PATH" "$PROJECT_DIR/$PROJECT_NAME" >"$OUTPUT_PATH"
    echo "Natalie Generator: Done."
else
    echo "Natalie Generator: Generated Swift is up-to-date; skipping re-generation."
fi
@krzyzanowskim
Copy link
Owner

👏

@krzyzanowskim
Copy link
Owner

echo "Natalie Generator: Determining if generated Swift file is up-to-date."

NATALIE_PATH="../natalie.swift"

if [ -f $NATALIE_PATH ]
then
    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 "Natalie Generator: Generated Swift is out-of-date; re-generating..."
        "$NATALIE_PATH" "$PROJECT_DIR/$PROJECT_NAME" > "$PROJECT_DIR/$PROJECT_NAME/Storyboards.swift"
        echo "Natalie Generator: Done."
    else
        echo "Natalie Generator: Generated Swift is up-to-date; skipping re-generation."
    fi
fi

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants