The Swift Programming Language
Swift is a high-performance system programming language. It has a clean and modern syntax, offers seamless access to existing C and Objective-C code and frameworks, and is memory-safe by default.
Although inspired by Objective-C and many other languages, Swift is not itself a C-derived language. As a complete and independent language, Swift packages core features like flow control, data structures, and functions, with high-level constructs like objects, protocols, closures, and generics. Swift embraces modules, eliminating the need for headers and the code duplication they entail.
To learn more about using the language, visit swift.org. To learn more about the compiler's internal design, see the documentation index.
Contributions to Swift are welcomed and encouraged! Please see the Contributing to Swift guide.
Before submitting the pull request, please make sure you have tested your changes and that they follow the Swift project guidelines for contributing code.
To be a truly great community, Swift.org needs to welcome developers from all walks of life, with different backgrounds, and with a wide range of experience. A diverse and friendly community will have more great ideas, more unique perspectives, and produce more great code. We will work diligently to make the Swift community welcoming to everyone.
To give clarity of what is expected of our members, Swift has adopted the code of conduct defined by the Contributor Covenant. This document is used across many open source communities, and we think it articulates our values well. For more, see the Code of Conduct.
If you are interested in:
We also have an FAQ that answers common questions.
Swift toolchains are created using the script build-toolchain. This script is used by swift.org's CI to produce snapshots and can allow for one to locally reproduce such builds for development or distribution purposes. A typical invocation looks like the following:
$ ./swift/utils/build-toolchain $BUNDLE_PREFIX
where $BUNDLE_PREFIX is a string that will be prepended to the build
date to give the bundle identifier of the toolchain's Info.plist. For
instance, if $BUNDLE_PREFIX was com.example, the toolchain
produced will have the bundle identifier com.example.YYYYMMDD. It
will be created in the directory you run the script with a filename
of the form: swift-LOCAL-YYYY-MM-DD-a-osx.tar.gz.
Beyond building the toolchain, build-toolchain also supports the
following (non-exhaustive) set of useful options:
--dry-run: Perform a dry run build. This is off by default.--test: Test the toolchain after it has been compiled. This is off by default.--distcc: Use distcc to speed up the build by distributing the C++ part of
the swift build. This is off by default.--sccache: Use sccache to speed up subsequent builds of the compiler by
caching more C++ build artifacts. This is off by default.More options may be added over time. Please pass --help to
build-toolchain to see the full set of options.
On macOS if one wants to install such a toolchain into Xcode:
/Library/Developer/Toolchains/ or
~/Library/Developer/Toolchains/. E.g.: $ sudo tar -xzf swift-LOCAL-YYYY-MM-DD-a-osx.tar.gz -C /
$ tar -xzf swift-LOCAL-YYYY-MM-DD-a-osx.tar.gz -C ~/
The script also generates an archive containing debug symbols which can be installed over the main archive allowing symbolication of any compiler crashes.
$ sudo tar -xzf swift-LOCAL-YYYY-MM-DD-a-osx-symbols.tar.gz -C /
$ tar -xzf swift-LOCAL-YYYY-MM-DD-a-osx-symbols.tar.gz -C ~/
Xcode->Toolchains.Try the suggestions in Troubleshooting build issues.
Make sure you are using the correct release of Xcode.
If you have changed Xcode versions but still encounter errors that appear to
be related to the Xcode version, try passing --clean to build-script.
When a new version of Xcode is released, you can update your build without
recompiling the entire project by passing --reconfigure to build-script.
Failed to produce diagnostic for return type mismatch with try expression
https://github.com/swiftlang/swift/issues/95102
Labels: triage needed
Windows: a Clang module that includes <windows.h> can't see HWND since Swift 6.4 (WinSDK declares <sdkddkver.h> but not <windef.h>)
https://github.com/swiftlang/swift/issues/95098
Labels: 없음
Contributions to Swift are welcomed and encouraged! For contributions to the broader Swift project, please see the Contributing to Swift guide.
To give clarity of what is expected of our members, Swift has adopted the code of conduct defined by the Contributor Covenant. This document is used across many open source communities, and it articulates our values. For more detail, read the project's Code of Conduct.
It is highly recommended that you become familiar with using Swift in your own projects before contributing directly to the language itself. We put together handy Getting Started guide and tutorials with step-by-step instructions to get you up and running.
Reporting bugs is a great way for anyone to help improve Swift. The open source Swift project uses GitHub Issues for tracking bugs.
[!NOTE] If a bug can be reproduced only within an Xcode project or a playground, or if the bug is associated with an Apple NDA, please file a report to Apple’s bug reporter instead.
Because Swift is under very active development, we receive a lot of bug reports. Before opening a new issue, take a moment to browse our existing issues to reduce the chance of reporting a duplicate.
Good first issues are bugs, ideas, and tasks that are intended to be accessible for contributors that are new to working on the Swift project, and even new to the patterns and concepts behind subprojects such as the Swift compiler. Good first issues are decorated with a corresponding label and are most easily found by visiting https://github.com/swiftlang/swift/contribute. They are expected to be low-priority and of modest scope, and not require excessive refactoring, research, or debugging — rather, they should encourage newcomers to dip their toes in some part of Swift, learn more about it, and make a real contribution.
Anyone with commit access and insight into a particular area is welcome and encouraged to pin down or think up good first issues.
If you are interested in:
We also host answers to Frequently Asked Questions that may be of interest.
Shaping the future of Swift is a community effort that anyone can participate in via the Evolution sections on the Swift forums. The Swift evolution process covers all changes to the Swift language and the public interface of the Swift standard library, including new language features and APIs, changes to existing language features or APIs, removal of existing features, and so on.
See the Swift evolution review schedule for current and upcoming proposal reviews.
The Swift project uses small, incremental changes as its preferred development model. Sometimes these changes are small bug fixes. Other times, these changes are small steps along the path to reaching larger stated goals. In contrast, long-term development branches can leave the community without a voice during development. Some additional problems with long-term branches include:
To address these problems, Swift uses an incremental development style. Small changes are preferred whenever possible. We require contributors to follow this practice when making large or otherwise invasive changes. Some tips follow:
Large or invasive changes usually have secondary changes that must be made before the large change (for example, API cleanup or addition). Commit these changes before the major change, independently of that work.
If possible, decompose the remaining interrelated work into unrelated sets of changes. Next, define the first increment and get consensus on the development goal of the change.
Make each change in the set either stand alone (for example, to fix a bug) or part of a planned series of changes that work toward the development goal. Explaining these relationships to the community can be helpful.
If you are interested in making a large change and feel unsure about its overall effect, please make sure to first discuss the change and reach a consensus through the Swift Forums. Then ask about the best way to go about making the change.
Although we don’t enforce a strict format for commit messages, we prefer that you follow the guidelines below, which are common among open source projects. Following these guidelines helps with the review process, searching commit logs, and email formatting. At a high level, the contents of the commit message should be to convey the rationale of the change, without delving into much detail. For example, “bits were not set right” leaves the reviewer wondering about which bits and why they weren’t “right”. In contrast, “Correctly compute ‘is dependent type’ bits in ‘Type’” conveys almost all there is to the change.
Below are some guidelines about the format of the commit message itself: