Skip to content

Commit 321b37c

Browse files
committed
docs: fix and improve Swift URLSession and Alamofire instructions
1 parent 612bfa3 commit 321b37c

1 file changed

Lines changed: 61 additions & 91 deletions

File tree

doc/user_guide/instructions_to_run_generated_code.md

Lines changed: 61 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1770,132 +1770,102 @@ cargo run
17701770
- For more information, refer to the [Actix Web Client documentation](https://docs.rs/awc/).
17711771
17721772
## Swift (URLSession)
1773+
Here are the detailed instructions for running the generated API Dash code in **Swift (using `URLSession`)** for macOS and Linux:
1774+
### 1. Set Up the Environment
17731775
1774-
### Set Up the Environment
1775-
#### MacBook (macOS)
1776+
#### macOS
17761777
1777-
Verify Swift :
1778-
```
1778+
Verify Swift is installed:
1779+
```bash
17791780
swift --version
17801781
```
17811782
1782-
1783-
#### Linux(Multipartformdata is not supported)
1784-
1785-
Download Swift for Linux (e.g., Ubuntu) from Swift.org.
1786-
1787-
```
1788-
tar xzf filename
1789-
export PATH=$PWD/filename/usr/bin:$PATH
1790-
1791-
```
1792-
Verify:
1793-
```
1794-
swift --version
1783+
If Swift is not installed, download and install Xcode from the [Mac App Store](https://apps.apple.com/us/app/xcode/id497799835) or install the Command Line Tools:
1784+
```bash
1785+
xcode-select --install
17951786
```
17961787
1788+
#### Linux
17971789
1798-
1799-
1800-
1801-
Install Dependencies:
1790+
1. Download the Swift toolchain for your Linux distribution from [Swift.org](https://swift.org/download/).
1791+
2. Extract the archive (replace `swift-x.x.x-RELEASE-ubuntu22.04` with your downloaded filename):
1792+
```bash
1793+
tar xzf swift-x.x.x-RELEASE-ubuntu22.04.tar.gz
1794+
export PATH=$PWD/swift-x.x.x-RELEASE-ubuntu22.04/usr/bin:$PATH
18021795
```
1803-
sudo apt-get update
1804-
sudo apt-get install clang libicu-dev libcurl4-openssl-dev
1796+
3. Install required dependencies:
1797+
```bash
1798+
sudo apt-get update
1799+
sudo apt-get install clang libicu-dev libcurl4-openssl-dev
1800+
```
1801+
4. Verify installation:
1802+
```bash
1803+
swift --version
18051804
```
18061805
1806+
**Note:** Multipart form data is not supported on Linux.
18071807
1808-
### Create a Project:
1809-
```
1808+
### 2. Create a Project
1809+
```bash
18101810
mkdir URLSessionDemo
18111811
cd URLSessionDemo
18121812
swift package init --type executable
18131813
```
18141814
1815+
### 3. Run the Generated Code
18151816
1816-
1817-
1818-
### Run the Code
1819-
Ensure main.swift is in Sources/URLSessionDemo.
1820-
1821-
1822-
Run:
1823-
```
1824-
swift run
1817+
1. Copy the generated code from API Dash.
1818+
2. Paste it into `Sources/URLSessionDemo/main.swift`.
1819+
3. Run the project:
1820+
```bash
1821+
swift run
18251822
```
18261823
18271824
## Swift (Alamofire)
1825+
Here are the detailed instructions for running the generated API Dash code in **Swift (using `Alamofire`)** for macOS and Linux:
18281826
1829-
### Set Up the Environment
1830-
#### MacBook (macOS)
1827+
### 1. Set Up the Environment
18311828
1832-
Verify Swift :
1833-
```
1834-
swift --version
1835-
```
1829+
Follow the instructions from the [Swift (URLSession)](#swift-urlsession) section above to install Swift for your operating system.
18361830
1837-
1838-
#### Linux (Multipartformdata is not supported)
1839-
1840-
Download Swift for Linux (e.g., Ubuntu) from Swift.org.
1841-
1842-
```
1843-
tar xzf filename
1844-
export PATH=$PWD/filename/usr/bin:$PATH
1845-
1846-
```
1847-
Verify:
1848-
```
1831+
Verify installation:
1832+
```bash
18491833
swift --version
18501834
```
18511835
1836+
**Note:** Multipart form data is not supported on Linux.
18521837
1853-
1854-
1855-
1856-
Install Dependencies for swift:
1857-
```
1858-
sudo apt-get update
1859-
sudo apt-get install clang libicu-dev libcurl4-openssl-dev
1860-
```
1861-
1862-
1863-
### Create a Project:
1864-
```
1865-
mkdir URLSessionDemo
1866-
cd URLSessionDemo
1838+
### 2. Create a Project
1839+
```bash
1840+
mkdir AlamofireDemo
1841+
cd AlamofireDemo
18671842
swift package init --type executable
18681843
```
18691844
1845+
### 3. Add Alamofire Dependency
18701846
1871-
### Adding alamofire
1872-
open `package.swift` and add following dependencies and target(replace `project-name` with your project name)
1847+
Open `Package.swift` and update it to include Alamofire (replace `project-name` with your project name):
1848+
```swift
1849+
dependencies: [
1850+
.package(url: "https://github.com/Alamofire/Alamofire", from: "5.6.4")
1851+
],
1852+
targets: [
1853+
.executableTarget(
1854+
name: "project-name",
1855+
dependencies: [
1856+
"Alamofire"
1857+
]
1858+
)
1859+
]
18731860
```
1874-
dependencies: [
1875-
.package(url: "https://github.com/Alamofire/Alamofire", from: "5.6.4")
1876-
],
1877-
targets: [
1878-
.executableTarget(
1879-
name: "project-name",
1880-
dependencies: [
1881-
"Alamofire"
1882-
]
1883-
)
1884-
]
1885-
1886-
1887-
```
1888-
1889-
1890-
1891-
### Run the Code
1892-
Ensure main.swift is in Sources/URLSessionDemo.
18931861
1862+
### 4. Run the Generated Code
18941863
1895-
Run:
1896-
```
1897-
swift run
1864+
1. Copy the generated code from API Dash.
1865+
2. Paste it into `Sources/AlamofireDemo/main.swift`.
1866+
3. Run the project:
1867+
```bash
1868+
swift run
18981869
```
18991870
19001871
1901-

0 commit comments

Comments
 (0)