Swift इंस्टॉल करना
In this page:
Installing on macOS
macOS पर, App Store से Xcode install करना अपने आप Swift compiler और standard library install करता है।
वैकल्पिक रूप से, xcode-select --install चलाना सिर्फ Command Line Tools install करता है, जिसमें पूरे Xcode IDE के बिना swift और swiftc शामिल हैं।
उदाहरण: Installing on macOS
# Install Xcode from App Store, or install command-line tools only:
xcode-select --install
⚠️ Run this in your own terminal or Node.js environment.
Installing on Linux
Linux पर, Swift swift.org से एक toolchain tarball download करके या supported distributions के लिए एक package manager उपयोग करके install किया जाता है, फिर इसे extract करके इसकी bin directory को अपने PATH में जोड़ते हुए।
swift:5.9 जैसी Docker images बिना manual install के एक working environment पाने का एक तेज़ तरीका हैं।
उदाहरण: Installing on Linux
# Ubuntu — install via Swift.org toolchain
wget https://download.swift.org/swift-5.10-release/ubuntu2204/swift-5.10-RELEASE/swift-5.10-RELEASE-ubuntu22.04.tar.gz
tar xzf swift-5.10-RELEASE-ubuntu22.04.tar.gz
export PATH=$PWD/swift-5.10-RELEASE-ubuntu22.04/usr/bin:$PATH
⚠️ Run this in your own terminal or Node.js environment.
Verifying the Installation
Install करने के बाद, एक terminal में swift --version चलाना installed Swift compiler version print करता है। अगर command नहीं मिलता, toolchain का bin folder अब भी आपके shell के PATH में जोड़ा जाना है।
उदाहरण: Verifying the Installation
swift --version
⚠️ Run this in your own terminal or Node.js environment.
swift --versionसे installation verify करने से पहले Swift code लिखने की कोशिश करना, फिर एक missing toolchain से होने वाली phantom errors debug करना।- यह मान लेना कि Swift macOS पर सिर्फ Xcode से installable है और यह न समझना कि official Linux toolchains और Docker images मौजूद हैं।
- एक manual Linux install के बाद Swift toolchain को system PATH में जोड़ना भूल जाना, इसलिए
swiftcommand नहीं मिलता।
- macOS पर, Swift Xcode या standalone Command Line Tools के साथ bundled आता है।
- Linux पर, official Swift toolchains swift.org से distributed होते हैं, या
swift:5.9जैसी Docker images के ज़रिए। swift --versionचलाना installation confirm करता है और compiler version दिखाता है।- एक बार installed होने पर,
swiftcommand terminal से सीधे.swiftfiles compile और चला सकता है।
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: