Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _add(project, args):
options = FileOptions(create_build_files=not args[u'--no-create-build-files'],
weak=args[u'--weak'],
ignore_unknown_type=args[u'--ignore-unknown-types'],
embed_framework=not args[u'--no-embed'],
code_sign_on_copy=args[u'--sign-on-copy'])
build_files = project.add_folder(args[u'
logger.info("The project need to have:")
logger.info("iOS Frameworks: {}".format(pbx_frameworks))
logger.info("iOS Libraries: {}".format(pbx_libraries))
logger.info("iOS local Frameworks: {}".format(frameworks))
logger.info("Libraries: {}".format(libraries))
logger.info("Sources to link: {}".format(sources))
logger.info("-" * 70)
logger.info("Analysis of {}".format(filename))
project = XcodeProject.load(filename)
sysroot = sh.xcrun("--sdk", "iphonesimulator", "--show-sdk-path").strip()
group = project.get_or_create_group("Frameworks")
g_classes = project.get_or_create_group("Classes")
file_options = FileOptions(embed_framework=False, code_sign_on_copy=True)
for framework in pbx_frameworks:
framework_name = "{}.framework".format(framework)
if framework_name in frameworks:
logger.info("Ensure {} is in the project (pbx_frameworks, local)".format(framework))
f_path = join(ctx.dist_dir, "frameworks", framework_name)
else:
logger.info("Ensure {} is in the project (pbx_frameworks, system)".format(framework))
f_path = join(sysroot, "System", "Library", "Frameworks",
"{}.framework".format(framework))
project.add_file(f_path, parent=group, tree="DEVELOPER_DIR",
force=False, file_options=file_options)
for library in pbx_libraries:
logger.info("Ensure {} is in the project (pbx_libraries, dylib+tbd)".format(library))
f_path = join(sysroot, "usr", "lib",
"{}.dylib".format(library))
project.add_file(f_path, parent=group, tree="DEVELOPER_DIR", force=False)
def add_folder(self, path, parent=None, excludes=None, recursive=True, create_groups=True, target_name=None,
file_options=FileOptions()):
"""
Given a directory, it will create the equivalent group structure and add all files in the process.
If groups matching the logical path already exist, it will use them instead of creating a new one. Same
apply for file within a group, if the file name already exists it will be ignored.
:param path: OS path to the directory to be added.
:param parent: Parent group to be added under
:param excludes: list of regexs to ignore
:param recursive: add folders recursively or stop in the first level
:param create_groups: add folders recursively as groups or references
:param target_name: Target name or list of target names where the file should be added (none for every target)
:param file_options: FileOptions object to be used during the addition of the file to the project.
:return: a list of elements that were added to the project successfully as PBXBuildFile objects
"""
if not os.path.isdir(path):
return None
def add_file_if_doesnt_exist(self, f_path, parent=None, tree='SOURCE_ROOT', create_build_files=True, weak=False,
ignore_unknown_type=False, target=None):
file_options = ProjectFiles.FileOptions(create_build_files=create_build_files, weak=weak,
ignore_unknown_type=ignore_unknown_type)
return self.add_file(f_path, parent=parent, tree=tree, force=False, target_name=target,
file_options=file_options)
def add_file(self, path, parent=None, tree=TreeType.SOURCE_ROOT, target_name=None, force=True, file_options=FileOptions()):
"""
Adds a file to the project, taking care of the type of the file and creating additional structures depending on
the file type. For instance, frameworks will be linked, embedded and search paths will be adjusted automatically.
Header file will be added to the headers sections, but not compiled, whereas the source files will be added to
the compilation phase.
:param path: Path to the file to be added
: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: a list of elements that were added to the project successfully as PBXBuildFile objects
"""
results = []
# if it's not forced to add the file stop if the file already exists.
if not force:
def _add(project, args):
if u'--header-scope' not in args or args[u'--header-scope'] not in ['public', 'private', 'project']:
header_scope = u'project'
else:
header_scope = args[u'--header-scope']
options = FileOptions(create_build_files=not args[u'--no-create-build-files'],
weak=args[u'--weak'],
ignore_unknown_type=args[u'--ignore-unknown-types'],
embed_framework=not args[u'--no-embed'],
code_sign_on_copy=args[u'--sign-on-copy'],
header_scope=header_scope.title())
build_files = project.add_file(args[u'
def _add(cls, project, args):
options = FileOptions(create_build_files=args.create_build_files,
weak=args.weak,
ignore_unknown_type=args.ignore_unknown_types,
embed_framework=args.embed,
code_sign_on_copy=args.code_sign_on_copy)
build_files = project.add_file_if_doesnt_exist(args.path, tree=args.tree, target_name=args.target,
file_options=options)
# print some information about the build files created.
if build_files is None:
return u'No files were added to the project'
if build_files is []:
return u'File added to the project, no build file sections created.'
info = {}
for build_file in build_files:
if build_file.isa not in info: