I had an iOS project where a gyb file was generating 10,000s lines of code, which made it a pain to debug because XCode would freak out. So I modified Apple's GYB script to support breaking the output into multiple files.
example.swift.gyb
// main example.swift file 🎉
let someSwiftCodeInBaseExport: String = "Hello world from the main file!"
% # create 9 files in the directory "example"
% for i in range (1, 10):
// new gyb file file${i}.swift
// Welcome to file ${i}! 🎊
let someSwiftCodeInFile${i}: String = "Hello world from file ${i}!"
% end
example.swift
// main example.swift file 🎉
let someSwiftCodeInBaseExport: String = "Hello world from the main file!"
example/file1.swift
// Welcome to file 1! 🎊
let someSwiftCodeInFile1: String = "Hello world from file 1!"
example/file2.swift ... example/file8.swift
example/file9.swift
// Welcome to file 9! 🎊
let someSwiftCodeInFile9: String = "Hello world from file 9!"
# transpile .gyb files. gyb2 is an adaption I made to create multiple swift files from one gyb
find . -name '*.gyb' | \
while read file; do \
tools/gyb2 --line-directive '' -o "${file%.gyb}" "$file"; \
done