You might get a much better deal than with building, without the potential pitfalls. Try to compare buying something else with building,if you haven’t. In this market it probably makes as much sense as ever to buy instead of build.
You could buy a bigger house and do a very inexpensive interior bootleg apartment with the option of removing modifications one day.
If you can find it, buying a place with a fully permitted second unit would be more cost effective and no building/contractor nightmares. They just don’t add much to resale prices. I designed and built my own “second dwelling unit”, even with only about 4k in labor, the house with its own garage doesn’t increase equity above cost.
I don’t see much economic value in adding second units in most cases. It won’t pencil out and you lose land. You will lose privacy forever if you ever become dependent on renting it. You likely won’t be able to rent both, as in UcGal’s case and my own.