swift README

The project's README from github.com/swiftlang/swift. As one markdown file: README.md.

Swift logo

Swift Programming Language

Welcome to Swift

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.

Contributing to Swift

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.

Getting Started

If you are interested in:

We also have an FAQ that answers common questions.

Swift Toolchains

Building

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:

More options may be added over time. Please pass --help to build-toolchain to see the full set of options.

Installing into Xcode

On macOS if one wants to install such a toolchain into Xcode:

  1. Untar and copy the toolchain to one of /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 ~/
  1. Specify the local toolchain for Xcode's use via Xcode->Toolchains.

Build Failures

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.

swift (swiftlang/swift)

Searching Database…

70.5K ·GitHub
Что это такое?Исходный репозиторий Swift — высокопроизводительного системного языка программирования с чистым современным синтаксисом, прозрачным доступом к существующему коду на C и Objective-C и безопасной работой с памятью по умолчанию.
Здесь разрабатывается компилятор Swift, или отсюда скачивают сам язык?Здесь лежит исходный код компилятора, а не установщик. Чтобы писать на Swift, используйте готовый toolchain с swift.org или Xcode; этот репозиторий — для работы над самим компилятором.
Хочу доработать компилятор — с чего начать?Чтобы вносить исправления, следуйте руководству How to Submit Your First Pull Request; чтобы просто один раз собрать компилятор, используйте руководство Getting Started.
Для сборки нужна какая-то конкретная версия Xcode?Задокументированное требование для сборки на macOS — Xcode, причём его версия должна соответствовать вашей ревизии кода. Именно с этого начинается руководство по сбоям сборки.
Сборка сломалась после обновления Xcode — есть быстрое решение?Да: если после смены версии Xcode ошибки остаются, передайте флаг --clean скрипту build-script; а при выходе нового Xcode флаг --reconfigure обновляет сборку без перекомпиляции всего проекта.
Собрать компилятор можно только на macOS?Практические инструкции в этом README относятся именно к macOS: собранный локально toolchain распаковывается в /Library/Developer/Toolchains или ~/Library/Developer/Toolchains и выбирается в Xcode->Toolchains.
Swift — это язык, произошедший от C?Нет — хотя Swift вдохновлён Objective-C и многими другими языками, он не является наследником C. Это полноценный самостоятельный язык с объектами, протоколами, замыканиями и обобщениями (generics), и вместо заголовочных файлов он использует модули.
Могу ли я собрать свой собственный toolchain Swift локально?Да — скрипт build-toolchain собирает toolchain так же, как CI swift.org делает снапшоты; на выходе получается архив вида swift-LOCAL-YYYY-MM-DD-a-osx.tar.gz.
Есть ли флаги, чтобы протестировать сборку или ускорить её?Да: --test запускает тесты после компиляции, --distcc распределяет C++-часть сборки между машинами, --sccache кэширует C++-артефакты, а --dry-run выполняет пробную сборку.
Creator
swiftlang
Size
1.3 GB
Stars
70.5K
Age
10y
Commits · 90 Days