https://github.com/emanuelefavero/swift
A repository for Swift code snippets, features, and techniques
https://github.com/emanuelefavero/swift
ios macos mobile-development snippets swift
Last synced: 3 months ago
JSON representation
A repository for Swift code snippets, features, and techniques
- Host: GitHub
- URL: https://github.com/emanuelefavero/swift
- Owner: emanuelefavero
- License: mit
- Created: 2024-08-07T20:57:50.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-13T05:28:06.000Z (about 1 year ago)
- Last Synced: 2025-03-29T16:12:46.830Z (6 months ago)
- Topics: ios, macos, mobile-development, snippets, swift
- Language: Swift
- Homepage:
- Size: 59.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Swift
A repository for Swift code snippets, features, and techniques

## Installation
Follow the instructions [here](https://www.swift.org/install/macos/) to install Swift on your machine
## Usage
To run a Swift file, use the following command:
```bash
swift .swift
```### Automatically restart Swift files
I personally simply use the npm package `nodemon` to automatically restart the Swift file when it is saved. To do this, install `nodemon` globally:
```bash
npm install -g nodemon
```> Note: You need to have [Node.js](https://nodejs.org/en) installed on your machine to use `nodemon`
Then, run the following command:
```bash
nodemon --exec swift .swift
```> Note: You could assign an alias in your `.bashrc` or `.zshrc` file to make this easier to run:
> `alias swiftmon='nodemon --exec swift'`### Using Swift REPL
You can also use the Swift REPL to run Swift code. To do this, simply run the following command:
```bash
swift repl
```To exit the REPL, type `:exit` or `:q` and press `Enter`
## Table of Contents
- [Hello World](./examples/HelloWorld.swift)
- [Variables](./examples/Variables.swift)
- [Data Types](./examples/DataTypes.swift)
- [Comments](./examples/Comments.swift)
- [Operators](./examples/Operators.swift)
- [Optionals](./examples/Optionals.swift)
- [Conditional Statements](./examples/ConditionalStatements.swift)
- [While Loops](./examples/WhileLoops.swift)
- [For Loops](./examples/ForLoops.swift)
- [Strings](./examples/Strings.swift)
- [Convert Data Types](./examples/ConvertDataTypes.swift)
- [Control Transfer](./examples/ControlTransfer.swift)
- [Arrays](./examples/Arrays.swift)
- [Sets](./examples/Sets.swift)
- [Sets Operations](./examples/SetsOperations.swift)
- [Dictionaries](./examples/Dictionaries.swift)
- [Functions](./examples/Functions.swift)## Resources
- [Swift.org](https://www.swift.org/)
- [Getting Started with Swift](https://www.swift.org/getting-started/)
- [SwiftUI](https://www.swift.org/getting-started/swiftui/)
- [Swift Playgrounds](https://www.apple.com/swift/playgrounds/)## License
- [MIT](LICENSE.md)