โš ๏ธ Custom Warnings & Errors for Xcode

ยท

1 min read

How many times do we submit a build to production and forgot to change something?? For me is more than I want ๐Ÿคฏ

For this reason, I had to find a way to prevent this, and this is my solution, Iโ€™m sure there are lots of people like me (hope so ๐Ÿ˜Š)

Letโ€™s say that we have this swift file with some configurations for API calls.

i.png

What I need is this simple thing, every time I build the app Xcode should give me a warning if Iโ€™m not using the production environment, and when releasing for production should give me an error, thatโ€™s it ๐Ÿ’ช

The way I achieved this was by creating a New Run Script Phase in Build Phases with some shell script.

2.png

Thatโ€™s all we need ๐Ÿ’ฅ๐Ÿ’ฅ๐Ÿ’ฅ

So now every time you build your project you will see a warning if production itโ€™s not used.

3.png

And when you archive you will see this ๐Ÿ˜‡

4.png

ย