Updated the build script

I have made some update and improvements on the build script to work with the latest Apple developer tools. Take a look at the commits for details.