Fix Mac version bugs and restructure the Xcode project.

Fix Mac version bugs and restructure the Xcode project.