Can a custom build phase modify a file before compilation?

365 views Asked by At

I have an iOS app that uses both Objective C and Swift. Before including Swift code, the app used a logger which uses c macros. For security reasons, the c macros then implement a mechanism that strips down the logs when building a release version, and that works perfectly fine.

When the Swift code kicked in, a Swift wrapper was made on top of the c macros. So now a log from the Swift code actually calls the swift wrapper which then calls the c macros. And that is not secure, the arguments sent to the swift wrapper should also be hidden otherwise an attacker may still extract some data.

I was thinking about running a custom build phase (shell script) that would delete all the function calls before creating a release build, but am doubtful this is possible.

So my question is: Can adding a custom build phase (run script phase) or maybe even a build rule modify a file before compiling it? Or will I have to write a script that I will need to run manually each time before releasing?

Thanks.

1

There are 1 answers

2
NRitH On

Yes, it's perfectly acceptable to add a pre-compilation build step to run a script.