parameters: (project_dir, configurations, root_dir)
docstring: Update inplace Xcode project to support multiple configurations.
  
    Args:
      project_dir: path to the input Xcode project
      configurations: list of string corresponding to the configurations that
        need to be supported by the tweaked Xcode projects, must contains at
        least one value.
      root_dir: path to the root directory used to find markdown files
docstring_summary: Update inplace Xcode project to support multiple configurations.
docstring_tokens: Update inplace Xcode project to support multiple configurations .
function: def UpdateXcodeProject(project_dir, configurations, root_dir):
    """Update inplace Xcode project to support multiple configurations.
  
    Args:
      project_dir: path to the input Xcode project
      configurations: list of string corresponding to the configurations that
        need to be supported by the tweaked Xcode projects, must contains at
        least one value.
      root_dir: path to the root directory used to find markdown files
    """
    json_data = json.loads(LoadXcodeProjectAsJSON(project_dir))
    project = XcodeProject(json_data['objects'])
  
    objects_to_remove = []
    for value in list(project.objects.values()):
      isa = value['isa']
  
      # Teach build shell script to look for the configuration and platform.
      if isa == 'PBXShellScriptBuildPhase':
        shell_path = value['shellPath']
        if shell_path.endswith('/sh'):
          value['shellScript'] = value['shellScript'].replace(
              'ninja -C .',
              'ninja -C "../${CONFIGURATION}${EFFECTIVE_PLATFORM_NAME}"')
        elif re.search('[ /]python[23]?$', shell_path):
          value['shellScript'] = value['shellScript'].replace(
              'ninja_params = [ \'-C\', \'.\' ]',
              'ninja_params = [ \'-C\', \'../\' + os.environ[\'CONFIGURATION\']'
              ' + os.environ[\'EFFECTIVE_PLATFORM_NAME\'] ]')
  
      # Add new configuration, using the first one as default.
      if isa == 'XCConfigurationList':
        value['defaultConfigurationName'] = configurations[0]
        objects_to_remove.extend(value['buildConfigurations'])
  
        build_config_template = project.objects[value['buildConfigurations'][0]]
        build_config_template['buildSettings']['CONFIGURATION_BUILD_DIR'] = \
            '$(PROJECT_DIR)/../$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)'
  
        value['buildConfigurations'] = []
        for configuration in configurations:
          new_build_config = copy.copy(build_config_template)
          new_build_config['name'] = configuration
          value['buildConfigurations'].append(
              project.AddObject('products', new_build_config))
  
    for object_id in objects_to_remove:
      del project.objects[object_id]
  
    source = GetOrCreateRootGroup(project, json_data['rootObject'], 'Source')
    AddMarkdownToProject(project, root_dir, source)
    SortFileReferencesByName(project, source)
  
    objects = collections.OrderedDict(sorted(project.objects.items()))
    WriteXcodeProject(project_dir, json.dumps(json_data))
function_tokens: def UpdateXcodeProject ( project_dir , configurations , root_dir ) : json_data = json . loads ( LoadXcodeProjectAsJSON ( project_dir ) ) project = XcodeProject ( json_data [ 'objects' ] ) objects_to_remove = [ ] for value in list ( project . objects . values ( ) ) : isa = value [ 'isa' ] # Teach build shell script to look for the configuration and platform. if isa == 'PBXShellScriptBuildPhase' : shell_path = value [ 'shellPath' ] if shell_path . endswith ( '/sh' ) : value [ 'shellScript' ] = value [ 'shellScript' ] . replace ( 'ninja -C .' , 'ninja -C "../${CONFIGURATION}${EFFECTIVE_PLATFORM_NAME}"' ) elif re . search ( '[ /]python[23]?$' , shell_path ) : value [ 'shellScript' ] = value [ 'shellScript' ] . replace ( 'ninja_params = [ \'-C\', \'.\' ]' , 'ninja_params = [ \'-C\', \'../\' + os.environ[\'CONFIGURATION\']' ' + os.environ[\'EFFECTIVE_PLATFORM_NAME\'] ]' ) # Add new configuration, using the first one as default. if isa == 'XCConfigurationList' : value [ 'defaultConfigurationName' ] = configurations [ 0 ] objects_to_remove . extend ( value [ 'buildConfigurations' ] ) build_config_template = project . objects [ value [ 'buildConfigurations' ] [ 0 ] ] build_config_template [ 'buildSettings' ] [ 'CONFIGURATION_BUILD_DIR' ] = '$(PROJECT_DIR)/../$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)' value [ 'buildConfigurations' ] = [ ] for configuration in configurations : new_build_config = copy . copy ( build_config_template ) new_build_config [ 'name' ] = configuration value [ 'buildConfigurations' ] . append ( project . AddObject ( 'products' , new_build_config ) ) for object_id in objects_to_remove : del project . objects [ object_id ] source = GetOrCreateRootGroup ( project , json_data [ 'rootObject' ] , 'Source' ) AddMarkdownToProject ( project , root_dir , source ) SortFileReferencesByName ( project , source ) objects = collections . OrderedDict ( sorted ( project . objects . items ( ) ) ) WriteXcodeProject ( project_dir , json . dumps ( json_data ) )