Total Pageviews

Tuesday, 25 February 2025

苹果宣布开源Xcode开发工具构建引擎Swift Build

 

遵守Apache License 2.0开源协议。Swift Build负责将开发者创建的源代码和项目描述转换为应用程序、库和命令行工具等可交付的输出产品。作为基础设施组件,Swift Build不仅能够执行来自更高级客户端的构建请求(如Swift Package Manager和Xcode),还提供了针对Linux和Windows平台的支持。Swift Build与Swift编译器无缝集成,支持多种产品类型的构建,并且能够在构建Swift和C代码时,最大化并行性,提高工作流程效率。

源代码:https://github.com/swiftlang/swift-build

-------

A high-level build system based on llbuild, used by Xcode, Swift Playground, and the Swift Package Manager 

Swift Build

Swift Build is a high-level build system based on llbuild with great support for building Swift. It is used by Xcode to build Xcode projects and Swift packages, and by Swift Playground. It can also be used as the Swift Package Manager build system in preview form when passing --build-system swiftbuild.

Usage

With SwiftPM

When building SwiftPM from sources which include Swift Build integration, passing --build-system swiftbuild will enable the new build-system. This functionality is not currently available in nightly toolchains.

With Xcode

Changes to swift-build can also be tested in Xcode using the launch-xcode command plugin provided by the package. Run swift package --disable-sandbox launch-xcode from your checkout of swift-build to launch a copy of the currently xcode-selected Xcode.app configured to use your modified copy of the build system service. This workflow is generally only supported when using the latest available Xcode version.

With xcodebuild

Changes to swift-build can also be tested in xcodebuild using the run-xcodebuild command plugin provided by the package. Run swift package --disable-sandbox run-xcodebuild from your checkout of swift-build to run xcodebuild from the currently xcode-selected Xcode.app configured to use your modified copy of the build system service. Arguments followed by -- will be forwarded to xcodebuild unmodified. This workflow is generally only supported when using the latest available Xcode version.

Debugging

When using the Xcode or xcodebuild workflows above, you can easily set breakpoints and debug. First, open the swift-build package containing your changes in Xcode and choose the "Debug > Attach to Process by PID or Name…" menu item. In the panel that appears, type "SWBBuildServiceBundle" as the process name and click "Attach". The debugger will wait for the process to launch. Run the relevant command shown above to launch Xcode or xcodebuild, and once you open a workspace the swift-build process will launch and the debugger will attach to it automatically.

Documentation

SwiftBuild.docc contains additional technical documentation.

To view the documentation in browser, run the following command at the root of the project:

docc preview SwiftBuild.docc

On macOS, use:

xcrun docc preview SwiftBuild.docc


from https://github.com/swiftlang/swift-build

No comments:

Post a Comment