Refactor target (sanbox_reorganization_544 branch)

This is some work based on the sanbox_reorganization_544 branch aimed to clean up the exiting implementation of the targets logic.

The branch is still failing and there is some more work planned (like updating the xcconfigs).

/c @mtitolo