Fixed crash on building in console

Build with xcodebuild will cause crash due to NSInvalidArgumentException.