← Back to Swift Course | Chapter 1: Setup & Basics | Lesson 2 of 7

Swift इंस्टॉल करना

Swift install करने का मतलब है toolchain को अपने computer पर download करना ताकि यह Swift code समझ सके और चला सके।

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

bash
# 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

bash
# 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

bash
swift --version

⚠️ Run this in your own terminal or Node.js environment.

Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. swift --version से installation verify करने से पहले Swift code लिखने की कोशिश करना, फिर एक missing toolchain से होने वाली phantom errors debug करना।
  2. यह मान लेना कि Swift macOS पर सिर्फ Xcode से installable है और यह न समझना कि official Linux toolchains और Docker images मौजूद हैं।
  3. एक manual Linux install के बाद Swift toolchain को system PATH में जोड़ना भूल जाना, इसलिए swift command नहीं मिलता।
चैप्टर सारांश
  • 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 होने पर, swift command terminal से सीधे .swift files compile और चला सकता है।
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.