Incorporate R.swift to Bazel.
Well, this is neither easy nor difficult. Just between the two. How to say it in English? Average?
Hello. I just have production experience with Bazel and I can’t wait to share it so everyone can benefit from it.
R.swift is a library to help us minimise stringy reference to resources. That’s my own word. Please check it out at https://github.com/mac-cain13/R.swift.
To incorporate the workflow of generate R.generated.swift, we should have an xcodeproj where R.swift will parse and put the script in Build Phase.
Until now, I can’t find a solution built right inside bazel to invoke the script in a correct way. Besides, the rswift is an unforgiving tool that demands us to give it a lot of environment variables derived from xcodebuild which in turns, it should be invoked from xcodeproj.
The solution is quite simple.
Meet our friendly XcodeGen. This tool will help us generate an xcodeproj from a spec which we will write as follows,
https://gist.github.com/muizidn/26699fb4e3a1651eebcabe032a57dac3
Then we can build using this code,
xcodegen
xcodebuild -t rswift
Thanks me later.
Conclusion
Easy. Peasy. Happy.
Thanks XcodeGen!!