code: def remove_file_by_id(self, file_id, target_name=None):
          
  
          file_ref = self.get_file_by_id(file_id)
          if file_ref is None:
              return False
  
          for target in self.objects.get_targets(target_name):
              for build_phase_id in target.buildPhases:
                  build_phase = self.objects[build_phase_id]
  
                  for build_file_id in build_phase.files:
                      build_file = self.objects[build_file_id]
  
                      if build_file.fileRef == file_ref.get_id():
                          # remove the build file from the phase
                          build_phase.remove_build_file(build_file)
  
                  # if the build_phase is empty remove it too, unless it's a shell script.
                  if build_phase.files.__len__() == 0 and build_phase.isa != u'PBXShellScriptBuildPhase':
                      # remove the build phase from the target
                      target.remove_build_phase(build_phase)
  
          # remove it iff it's removed from all targets or no build file reference it
          for build_file in self.objects.get_objects_in_section(u'PBXBuildFile'):
              if build_file.fileRef == file_ref.get_id():
                  return True
  
          # remove the file from any groups if there is no reference from any target
          for group in self.objects.get_objects_in_section(u'PBXGroup'):
              if file_ref.get_id() in group.children:
                  group.remove_child(file_ref)
  
          # the file is not referenced in any build file, remove it
          del self.objects[file_ref.get_id()]
          return True
docs: Removes the file id from given target name. If no target name is given, the file is removed
          from all targets
          :param file_id: identifier of the file to be removed
          :param target_name: Target name or list of target names where the file should be removed from (none for every
              target)
          :return: True if the file id was removed. False if the file was not removed.