def build_swift_package()

in project_future.py [0:0]


def build_swift_package(path, swiftc, swift_version, configuration,
                        sandbox_profile, stdout=sys.stdout, stderr=sys.stderr,
                        added_swift_flags=None,
                        incremental=False,
                        override_swift_exec=None):
    """Build a Swift package manager project."""
    swift = os.path.join(os.path.dirname(swiftc), 'swift')
    if not incremental:
        clean_swift_package(path, swiftc, sandbox_profile,
                            stdout=stdout, stderr=stderr)
    env = os.environ
    env['DYLD_LIBRARY_PATH'] = get_stdlib_platform_path(swiftc, 'macOS')
    env['SWIFT_EXEC'] = override_swift_exec or swiftc
    command = [swift, 'build', '-C', path, '--verbose',
               '--configuration', configuration]
    if (swift_branch not in ['swift-3.0-branch',
                             'swift-3.1-branch']):
        command.insert(2, '--disable-sandbox')

    if swift_version:
        if '.' not in swift_version:
            swift_version += '.0'

        major, minor = swift_version.split('.', 1)
        # Need to use float for minor version parsing
        # because it's possible that it would be specified
        # as e.g. `4.0.3`
        if int(major) == 4 and float(minor) == 2.0:
            command += ['-Xswiftc', '-swift-version', '-Xswiftc', swift_version]
        else:
            command += ['-Xswiftc', '-swift-version', '-Xswiftc', major]

    if added_swift_flags is not None:
        for flag in added_swift_flags.split():
            command += ["-Xswiftc", flag]
    return common.check_execute(command, timeout=3600,
                                sandbox_profile=sandbox_profile,
                                stdout=stdout, stderr=stderr,
                                env=env)