Use Swift Package on Playground

This article was forcibly made into the article on the 10th day of Swift Kotlin Lovers Association Advent Calendar 2020 w

background

I wanted to run the Swift Package of Swift Algorithms on Playground when writing "I touched Swift Algorithms lightly".

It seems that you can use Swift Package on Playground from Xcode 12, but it was awkward, so make a note of how to do it

Create an iOS Project

Create a project with New-> Project ... This time I made it with iOS-> App. Screen Shot 2020-12-31 at 23.51.19.png

Add Playground to Project

New-> Playground ...-> Create a Playground with iOS Blank.

When saving, add it to the Project created earlier.

Screen_Shot_2020-12-31_at_23_59_22.png

Add Swift Package

Add https://github.com/apple/swift-algorithms with File-> Swift Packages-> Add Package Dependency ...

Screen Shot 2021-01-01 at 0.07.39.png

Used in Playground

Implemented the following in Playground

import Algorithms

let numbers = [10, 20, 30, 40]
for combo in numbers.combinations(ofCount: 2) {
    print(combo)
}

that's all!

Of which

  1. Create a workplace (not a project)
  2. Add Playground
  3. Add Swift Package I feel happy when I get cool

Refs

Recommended Posts

Use Swift Package on Playground
Let's use Swift Package Manager (SwiftPM) ~ Creation ~
Let's use Swift Package Manager (SwiftPM) ~ Introduction ~
Use perltidy on CentOS 8
Use Flutter on Ubuntu
Use mod_auth_cas on CentOS 8
Research on Swift Optional
Use bat on Centos.
Use mkdir on ubuntu
Use Corretto 11 on Heroku
Use cpplapack on ubuntu
[Swift] Let's use extension
Use serial communication on Android
[Swift] Let's use Segmented Control
[Swift] How to use UserDefaults
How to use Swift UIScrollView
Use swift Filter and Map
Let's use Swift Firebase Firebase Auth
Use devise on multiple models
Use native code on Android
[Swift UI] Use Map view
Use PG Backups on Heroku
[Swift] Another way to use Result?
Use Docker Compose on Windows 10 Home
How to use Ruby on Rails
[Swift] Acquisition of IDFA on iOS14
How to use Bio-Formats on Ubuntu 20.04
[Swift] How to use SwiftLint (cocoapods)
[Swift] How to use Unwind segue
Use Docker on your M1 Mac
Install Xcode and use Hello Swift!
Preparing to use electron-react-boilerplate on Ubuntu 20.4
Use the iostat command on CentOS 8
Use completion in Eclipse on mac
Notes on Java path and Package
Use Docker CE (official) on CentOS 8