Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
forked fromswiftlang/swift

The Swift Programming Language

License

NotificationsYou must be signed in to change notification settings

CodaFi/swift

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Swift logo

Swift Programming Language

ArchitectureMasterPackage
macOSx86_64Build StatusBuild Status
Ubuntu 16.04x86_64Build StatusBuild Status
Ubuntu 18.04x86_64Build StatusBuild Status
Ubuntu 20.04x86_64Build StatusBuild Status
CentOS 8x86_64Build StatusBuild Status
Amazon Linux 2x86_64Build StatusBuild Status

Swift Community-Hosted CI Platforms

OSArchitectureBuild
Ubuntu 16.04PPC64LEBuild Status
Ubuntu 18.04AArch64Build Status
Ubuntu 20.04AArch64Build Status
CentOS 8AArch64Build Status
Amazon Linux 2AArch64Build Status
AndroidARMv7Build Status
AndroidAArch64Build Status
Windows 2019 (VS 2017)x86_64Build Status
Windows 2019 (VS 2019)x86_64Build Status

Swift TensorFlow Community-Hosted CI Platforms

OSArchitectureBuild
Ubuntu 16.04x86_64Build Status
macOS 10.13x86_64Build Status
Ubuntu 16.04 (GPU)x86_64Build Status

Welcome to Swift

Swift is a high-performance system programming language. It has a cleanand modern syntax, offers seamless access to existing C and Objective-C codeand frameworks, and is memory safe by default.

Although inspired by Objective-C and many other languages, Swift is not itself aC-derived language. As a complete and independent language, Swift packages corefeatures like flow control, data structures, and functions, with high-levelconstructs like objects, protocols, closures, and generics. Swift embracesmodules, eliminating the need for headers and the code duplication they entail.

To learn more about the programming language, visitswift.org.

Contributing to Swift

Contributions to Swift are welcomed and encouraged! Please see theContributing to Swift guide.

To be a truly great community,Swift.org needs to welcomedevelopers from all walks of life, with different backgrounds, and with a widerange of experience. A diverse and friendly community will have more greatideas, more unique perspectives, and produce more great code. We will workdiligently to make the Swift community welcoming to everyone.

To give clarity of what is expected of our members, Swift has adopted thecode of conduct defined by the Contributor Covenant. This document is usedacross many open source communities, and we think it articulates our valueswell. For more, see theCode of Conduct.

Getting Started

These instructions give the most direct path to a working Swift developmentenvironment. To build from source you will need about 2 GB of disk space for thesource code and up to 70 GB of disk space for the build artifacts with fulldebugging. Depending on your machine, a clean build can take a few minutes toseveral hours. Naturally, incremental builds are much faster.

Once you are able to build things successfully and have a compile-test-debugloop going, check out thedevelopment tips forbetter productivity while working on the compiler.

You can also skimdocs/README.md to understand whathigh-level documentation is available.

System Requirements

macOS, Ubuntu Linux LTS, and the latest Ubuntu Linux release are currentlysupported as host development operating systems.

Please make sure you use Python 2.x. Python 3.x is not supported currently.

macOS

To build for macOS, you needXcode 12 beta 3.The required version of Xcode changes frequently, and is often a beta release.Check this document or the host information onhttps://ci.swift.org for thecurrent required version.

Swift's build tooling is meant to support spaces in the paths passed to them,but using spaces sometimes tickles bugs in Swift's build scripts or the toolsthey rely on. For example,SR-13441is caused by a space in the Xcode path used on macOS. If you see Swift's buildtooling misbehave due to a space in a path, pleasereport the bug on the Swift bug trackerand then change the path to work around it.

You will also needCMake andNinja,which can be installed via a package manager:

Homebrew

brew install cmake ninja

You can also usehomebrew-bundlefrom the root of this repository's working directory to install all of thesedependencies:

brew bundle

MacPorts

sudo port install cmake ninja

Instructions for installing CMake and Ninja directly can be foundbelow.

Linux

For Ubuntu, you'll need the following development dependencies:

sudo apt-get install    \  clang                 \  cmake                 \  git                   \  icu-devtools          \  libcurl4-openssl-dev  \  libedit-dev           \  libicu-dev            \  libncurses5-dev       \  libpython-dev         \  libsqlite3-dev        \  libxml2-dev           \  ninja-build           \  pkg-config            \  python                \  python-six            \  rsync                 \  swig                  \  systemtap-sdt-dev     \  tzdata                \  uuid-dev

Note: LLDB currently requires at leastswig-1.3.40 but will successfully buildwith version 2 shipped with Ubuntu.

Note: For Ubuntu 20.04, uselibpython2-dev in place of the libpython-dev package above.

Getting Sources for Swift and Related Projects

First create a directory for all of the Swift sources:

mkdir swift-sourcecd swift-source

Note: This is important since update-checkout (see below) checks outrepositories next to the Swift source directory. This means that if one clonesSwift and has other unrelated repositories, update-checkout may not clone thoserepositories and will update them instead. Be aware thatupdate-checkoutcurrently does not support paths with non-ASCII characters. If such charactersare present in the path toswift-source,update-checkout will fail.

Via HTTPS For those checking out sources as read-only, HTTPS works best:

git clone https://github.com/apple/swift.git./swift/utils/update-checkout --clone

Via SSH For those who plan on regularly making direct commits,cloning over SSH may provide a better experience (which requiresuploading SSH keys to GitHub):

git clone git@github.com:apple/swift.git./swift/utils/update-checkout --clone-with-ssh

Building Swift

Thebuild-script is a high-level build automation script that supports basicoptions such as building a Swift-compatible LLDB, building the Swift PackageManager, building for various platforms, running tests after builds, and more.

There are two primary build systems to use: Xcode and Ninja. The Xcode buildsystem allows you to work in Xcode, but Ninja is a bit faster and supportsmore environments.

First, make sure that you're in the swift directory:

cd swift

To build using Ninja, run:

utils/build-script --release-debuginfo

When developing Swift, it helps to build what you're working on in a debugconfiguration while building the rest of the project with optimizations. Beloware some examples of using debug variants:

utils/build-script --release-debuginfo --debug-swift # Swift frontend built in debugutils/build-script --release-debuginfo --debug-swift-stdlib # Standard library built in debugutils/build-script --release-debuginfo --debug-swift --force-optimized-typechecker # Swift frontend sans type checker built in debug

Limiting the amount of debug code in the compiler has a very large impact onSwift compile times, and in turn the test execution time. If you want to buildthe entire project in debug, you can run:

utils/build-script --debug

For documentation of all available arguments, as well as additional usageinformation, see the inline help:

utils/build-script -h

Xcode

To build using Xcode, specify the--xcode argument on any of the above commands.Xcode can be used to edit the Swift source code, but it is not currentlyfully supported as a build environment for SDKs other than macOS. The generatedXcode project does not integrate with the test runner, but the tests can be runwith the 'check-swift' target.

Build Products

All of the build products are placed inswift-source/build/${TOOL}-${MODE}/${PRODUCT}-${PLATFORM}/.If macOS Swift with Ninja in DebugAssert mode was built, all of the productswould be inswift-source/build/Ninja-DebugAssert/swift-macosx-x86_64/. Ithelps to save this directory as an environment variable for future use.

export SWIFT_BUILD_DIR="~/swift-source/build/Ninja-DebugAssert/swift-macosx-x86_64"

Ninja

Once the first build has completed, Ninja can perform fast incremental builds ofvarious products. These incremental builds are a big timesaver when developingand debugging.

cd ${SWIFT_BUILD_DIR}ninja swift-frontend

This will build the Swift compiler, but will not rebuild the standard library orany other target. Building theswift-stdlib target as an additional layer oftesting from time to time is also a good idea. To build just the standardlibrary, run:

ninja swift-stdlib

It is always a good idea to do a full build after usingupdate-checkout.

Using Xcode

To open the Swift project in Xcode, open${SWIFT_BUILD_DIR}/Swift.xcodeproj.It will auto-create alot of schemes for all of the available targets. Acommon debug flow would involve:

  • Select the 'swift-frontend' scheme.
  • Pull up the scheme editor (⌘⇧<).
  • Select the 'Arguments' tab and click the '+'.
  • Add the command line options.
  • Close the scheme editor.
  • Build and run.

Another option is to change the scheme to "Wait for executable to be launched",then run the build product in Terminal.

Swift Toolchains

Building

Swift toolchains are created using the scriptbuild-toolchain. Thisscript is used by swift.org's CI to produce snapshots and can allow for one tolocally reproduce such builds for development or distribution purposes. A typicalinvocation looks like the following:

  $ ./swift/utils/build-toolchain $BUNDLE_PREFIX

where$BUNDLE_PREFIX is a string that will be prepended to the builddate to give the bundle identifier of the toolchain'sInfo.plist. Forinstance, if$BUNDLE_PREFIX wascom.example, the toolchainproduced will have the bundle identifiercom.example.YYYYMMDD. Itwill be created in the directory you run the script with a filenameof the form:swift-LOCAL-YYYY-MM-DD-a-osx.tar.gz.

Beyond building the toolchain,build-toolchain also supports thefollowing (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 ofthe swift build. This is off by default.

More options may be added over time. Please pass--help tobuild-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.x.:
  $ 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 whichcan be installed over the main archive allowing symbolication of anycompiler 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 viaXcode->Toolchains.

Build Failures

Make sure you are using thecorrect release of Xcode.

If you have changed Xcode versions but still encounter errors that appear tobe related to the Xcode version, try passing--clean tobuild-script.

When a new version of Xcode is released, you can update your build withoutrecompiling the entire project by passing the--reconfigure option.

Make sure all repositories are up to date with theupdate-checkout commanddescribed above.

Testing Swift

Seedocs/Testing.md, in particular the section onlit.py.

Learning More

Be sure to look through thedocsdirectory for more information about the compiler. In particular, the documentstitledDebugging the Swift Compiler andContinuous Integration for Swift are veryhelpful to understand before submitting your first PR.

Building Documentation

To read the compiler documentation, start by installing theSphinx documentation generator tool by running thecommand:

easy_install -U "Sphinx < 2.0"

Once complete, you can build the Swift documentation by changing directory intodocs and typingmake. Thiscompiles the.rst files in thedocsdirectory into HTML in thedocs/_build/html directory.

Many of the docs are out of date, but you can see some historical designdocuments in thedocs directory.

Another source of documentation is the standard library itself, located instdlib. Much of the language is actually implemented in the library(includingInt), and the standard library gives some examples of what can beexpressed today.

Build Dependencies

CMake

CMake is the core infrastructure used to configure builds ofSwift and its companion projects; at least version 3.16.5 is required.

On macOS, you can download theCMake Binary Distribution,bundled as an application, copy it to/Applications, and add the embeddedcommand line tools to yourPATH:

export PATH=/Applications/CMake.app/Contents/bin:$PATH

On Linux, if you have not already installed Swift'sdevelopmentdependencies, you can download and install the CMakepackage separately using the following command:

sudo apt-get install cmake

Ninja

Ninja is the current recommended build systemfor building Swift and is the default configuration generated by CMake.Pre-builtpackagesare available for macOS and Linux distributions. You can also clone Ninjanext to the other projects and it will be bootstrapped automatically:

Via HTTPS

git clone https://github.com/ninja-build/ninja.git && cd ninjagit checkout releasecat README

Via SSH

git clone git@github.com:ninja-build/ninja.git && cd ninjagit checkout releasecat README

About

The Swift Programming Language

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++51.1%
  • Swift44.2%
  • Python2.3%
  • CMake0.7%
  • Objective-C0.6%
  • C0.4%
  • Other0.7%

[8]ページ先頭

©2009-2025 Movatter.jp