Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return []
file_ref, abs_path, path, tree, expected_build_phase = self._add_file_reference(path, parent, tree, force,
file_options)
if path is None or tree is None:
return None
# no need to create the build_files, done
if not file_options.create_build_files:
return results
# create build_files for the targets
results.extend(self._create_build_files(file_ref, target_name, expected_build_phase, file_options))
# special case for the frameworks and libraries to update the search paths
if tree != TreeType.SOURCE_ROOT or abs_path is None:
return results
# the path is absolute and it's outside the scope of the project for linking purposes
library_path = os.path.join(u'$(SRCROOT)', os.path.split(file_ref.path)[0])
if os.path.isfile(abs_path):
self.add_library_search_paths([library_path], recursive=False)
else:
self.add_framework_search_paths([library_path, u'$(inherited)'], recursive=False)
return results
def options(cls):
return [TreeType.SOURCE_ROOT, TreeType.SDKROOT, TreeType.GROUP, TreeType.ABSOLUTE,
TreeType.DEVELOPER_DIR, TreeType.BUILT_PRODUCTS_DIR]
def options(cls):
return [TreeType.SOURCE_ROOT, TreeType.SDKROOT, TreeType.GROUP, TreeType.ABSOLUTE,
TreeType.DEVELOPER_DIR, TreeType.BUILT_PRODUCTS_DIR]
def __init__(self, parser):
file_parser = parser.add_parser(u'file', help=u'Manipulate files in the project')
# common parameters
standard_parameters(file_parser)
file_parser.add_argument(u'path', help=u'file path to be added to the project')
file_parser.add_argument(u'--tree', choices=TreeType.options(), default=TreeType.SOURCE_ROOT,
help=u'tree relative to the origin of the file to be added.')
# remove parameters
remove_parser = file_parser.add_argument_group(u'Remove file options')
remove_parser.add_argument(u'--delete', u'-D', action=u'store_true', help=u'')
# add parameters
add_parser = file_parser.add_argument_group(u'Add file options')
add_parser.add_argument(u'--weak', u'-w', action=u'store_true', help=u'link framework weakly.')
add_parser.add_argument(u'--no-embed', u'-E', action=u'store_false', dest=u'embed',
help=u'do not embed framework on the application')
add_parser.add_argument(u'--sign-on-copy', u'-csoc', action=u'store_true', dest=u'code_sign_on_copy',
help=u'code sign frameworks when copied to the application.')
add_parser.add_argument(u'--ignore-unknown-types', u'-i', action=u'store_true', dest=u'ignore_unknown_types',
help=u'ignore unknown types and add the file regardless.')
add_parser.add_argument(u'--no-create-build-files', u'-C', action=u'store_false', dest=u'create_build_files',
def add_project(self, path, parent=None, tree=TreeType.GROUP, target_name=None, force=True, file_options=FileOptions()):
"""
Adds another Xcode project into this project. Allows to use the products generated from the given project into
this project during compilation time. Optional: it can add the products into the different sections: frameworks
and bundles.
:param path: Path to the .xcodeproj file
:param parent: Parent group to be added under
:param tree: Tree where the path is relative to
:param target_name: Target name or list of target names where the file should be added (none for every target)
:param force: Add the file without checking if the file already exists
:param file_options: FileOptions object to be used during the addition of the file to the project.
:return: list of PBXReferenceProxy objects that can be used to create the PBXBuildFile phases.
"""
results = []
# if it's not forced to add the file stop if the file already exists.
if not force:
def get_attributes(self, file_ref, build_phase):
if file_ref.get_file_type() != u'wrapper.framework' and file_ref.get_file_type() != u'sourcecode.c.h':
return None
attributes = None
if build_phase.isa == u'PBXFrameworksBuildPhase':
attributes = [u'Weak'] if self.weak else None
if build_phase.isa == u'PBXCopyFilesBuildPhase' and \
file_ref.sourceTree != TreeType.SDKROOT and \
self.code_sign_on_copy:
if attributes is None:
attributes = []
attributes += [u'CodeSignOnCopy', u'RemoveHeadersOnCopy']
if build_phase.isa == u'PBXHeadersBuildPhase':
attributes = [self.header_scope] if self.header_scope != HeaderScope.PROJECT else None
return attributes