Swift Package Manager का परिचय
swift package init --type executable
swift build
swift run
swift test
Initializing a New Package
swift package init एक नया package skeleton बनाता है, जिसमें एक Package.swift manifest और एक starter source file शामिल है।
उदाहरण: Initializing a New Package
swift package init --type executable
⚠️ Run this in your own terminal or Node.js environment.
Building and Running a Package
swift build किसी package के सभी targets compile करता है, और swift run build करता है (अगर ज़रूरत हो) और फिर इसका main executable target execute करता है।
उदाहरण: Building and Running a Package
swift build
swift run
⚠️ Run this in your own terminal or Node.js environment.
Running Tests
swift test package के manifest में declared सभी test targets compile और चलाता है, pass/fail results report करते हुए।
उदाहरण: Running Tests
swift test
⚠️ Run this in your own terminal or Node.js environment.
- बिना एक
Package.swiftmanifest file वाले folder मेंswift buildयाswift runचलाने की कोशिश करना; SPM को यह जानने के लिए यह file चाहिए कि project कैसे build करना है। - किसी package के products (जो दूसरे packages import कर सकते हैं) को इसके targets (असल में compile हो रहे source modules) के साथ confuse करना।
- यह भूल जाना कि
swift testconvention से specificallyTestsपर खत्म होने वाला एक target ढूंढता है, package के testing setup से मेल खाते हुए।
swift package initएक नया package scaffold करता है, एकPackage.swiftmanifest generate करते हुए।Package.swiftpackage का नाम, dependencies, targets, और products declare करता है।swift buildpackage compile करता है, औरswift runएक executable target build और execute करता है।swift testpackage के test targets चलाता है।
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: