「Swift」の版間の差分

提供: ArchWiki
ナビゲーションに移動 検索に移動
(言語間リンクを追加)
(記事を差し替え)
1行目: 1行目:
 
[[Category:プログラミング言語]]
 
[[Category:プログラミング言語]]
 
[[en:Swift]]
 
[[en:Swift]]
  +
According to [[Wikipedia:Swift (programming language)|Wikipedia]]:
Running swift-language builds and doing swift development is possible on linux. To install swift use {{AUR|swift-bin}} for the released version, repackaged Fedora binary, or {{AUR|swift-language}} for a native build from source. {{AUR|swift-language-git}} will give the latest from git. For code completion the sourcekit language server protocol, [https://github.com/apple/sourcekit-lsp sourcekit-lsp] is available, e.g. as plugin to visual studio code, {{Pkg|code}}.
 
  +
: Swift is a general-purpose, multi-paradigm, compiled programming language developed by Apple Inc. and the open-source community. First released in 2014, Swift was developed as a replacement for Apple's earlier programming language Objective-C, as Objective-C had been largely unchanged since the early 1980s and lacked modern language features.
   
  +
Running Swift-language builds and doing Swift development is possible on Linux.
== Edit and code completion ==
 
  +
  +
== Installation ==
  +
  +
[[Install]] {{AUR|swift-bin}} for the released version, which is a repackaged Fedora binary, or {{AUR|swift-language}} for a native build from source.
  +
  +
Use {{AUR|swift-language-git}} for the development version.
  +
  +
For code completion the sourcekit language server protocol, [https://github.com/apple/sourcekit-lsp sourcekit-lsp] is available, e.g. as plugin to visual studio code, {{Pkg|code}}. See below.
  +
  +
=== Editing and code completion ===
   
 
[[Install]] {{Pkg|code}}, then install sourcekit-lsp from source, {{Pkg|nodejs}} is needed.
 
[[Install]] {{Pkg|code}}, then install sourcekit-lsp from source, {{Pkg|nodejs}} is needed.
{{hc| install vscode sourcekit-lsp from source|
 
git clone git@github.com:apple/sourcekit-lsp.git
 
cd Editors/vscode
 
npm run createDevPackage
 
code --install-extension out/sourcekit-lsp-vscode-dev.vsix
 
}}
 
   
  +
$ git clone git@github.com:apple/sourcekit-lsp.git
== hello world ==
 
  +
$ cd Editors/vscode
  +
$ npm run createDevPackage
  +
$ code --install-extension out/sourcekit-lsp-vscode-dev.vsix
   
  +
== Hello world ==
swift package manager allows to create example programs.
 
   
  +
The Swift package manager allows to create example programs.
{{hc|hello-world executable|
 
swift package init --type executable
 
swift run
 
}}
 
   
  +
$ swift package init --type executable
{{hc|hello-world library|
 
  +
$ swift run
swift package init
 
swift build
 
}}
 
   
  +
For a library:
== read eval print loop, REPL ==
 
  +
  +
$ swift package init
  +
$ swift build
  +
  +
== Read eval print loop, REPL ==
   
 
For details on the swift REPL, see [https://swift.org/getting-started/#using-the-repl here].
 
For details on the swift REPL, see [https://swift.org/getting-started/#using-the-repl here].
{{hc|read eval print loop|2=
+
{{hc|$ swift|2=
> swift
 
 
Welcome to Swift version 5.3 (swift-5.3-RELEASE).
 
Welcome to Swift version 5.3 (swift-5.3-RELEASE).
 
Type :help for assistance.
 
Type :help for assistance.
38行目: 45行目:
 
2>
 
2>
 
}}
 
}}
 
{{TranslationStatus|Swift|2022-06-28|738421}}
 

2023年4月11日 (火) 18:16時点における版

According to Wikipedia:

Swift is a general-purpose, multi-paradigm, compiled programming language developed by Apple Inc. and the open-source community. First released in 2014, Swift was developed as a replacement for Apple's earlier programming language Objective-C, as Objective-C had been largely unchanged since the early 1980s and lacked modern language features.

Running Swift-language builds and doing Swift development is possible on Linux.

Installation

Install swift-binAUR for the released version, which is a repackaged Fedora binary, or swift-languageAUR for a native build from source.

Use swift-language-gitAUR for the development version.

For code completion the sourcekit language server protocol, sourcekit-lsp is available, e.g. as plugin to visual studio code, code. See below.

Editing and code completion

Install code, then install sourcekit-lsp from source, nodejs is needed.

$ git clone git@github.com:apple/sourcekit-lsp.git
$ cd Editors/vscode
$ npm run createDevPackage
$ code --install-extension out/sourcekit-lsp-vscode-dev.vsix

Hello world

The Swift package manager allows to create example programs.

$ swift package init --type executable
$ swift run

For a library:

$ swift package init
$ swift build

Read eval print loop, REPL

For details on the swift REPL, see here.

$ swift
Welcome to Swift version 5.3 (swift-5.3-RELEASE).
Type :help for assistance.
  1> 1+1
$R0: Int = 2
  2>