What’s New In Swift (2022)

Here’s a video I’ve just seen from WWDC, here are the highlights and in the conclusion what I think of it. So you don’t have to watch it (if you don’t want). If you do, please watch the video in the Apple developer portal rather than reading this article as this is really just my notes from that video.

Trust on first use for Swift package manager.

A security protocol where after first download subsequent downloads are verified against the initial download.

Swift packages

Command plugins

Replacing shell scripts, use Swift! These can be run whenever you want to as custom actions.

Generate source code from within a build (if the plugin has write permission), or automate release tasks.

Essentially these are Swift packages, and avoid bringing in runtime content into your App.

Build tool plugins

These extend the build system’s dependency graph. They are able to generate source code or resources as part of a build, and can be applied to each target that needs them (in contrast to command plugins).

Swift performance

Builds can be performed in parallel now (which is great!). Things like protocols with generic requirements could be slow to type check, but this is now significantly faster as is computing protocols on App startup is now cached.

Concurrency updates

Data races? A thing of the past with the new concurrency model.

Data race safety should prevent the following, because is `removeLast` run before or after append is run?

This behaviour is caught with an error, because this should be synchronised with an actor.

The distributed keyword added to actor should prevent mistakes where an actor is used across servers etc.

Swift concurrency view in instruments

This sounds rather good!

Swift Language Usability

Optional unwrapping

The if let pattern is great! But could it be improved rather than having the same variable name on both sides of an =? There’s a new shorthand pattern for this

With the same for guard and while

Optional

Complicated closures can now infer the result type. Yes, this is great.

Pointer conversions

Enables easier use of C functions in Swift. Which is nice.

Regex and RegexComponent

Searching and slicing is a pain, so it seems Apple would like you to use regex and their new regex builder.

RegexComponent is a reusable regex component. Because of course it is.

Generics and protocols

A protocol typically means “is an instance that conforms to this protocol”. However, at the same time (in different contexts) it can mean a potential instance that conforms to the protocol (which itself does not conform to the protcol).

To differentiate the latter from the former, the `any` keyword is used:

var map: any Mailmap

we can see the difference in the code below

If a generic type is only used in one place, you can use the `some` keyword. This makes them as easy to use as protocols above.

https://www.bramptonconsultancy.com/profile/ver-top-gun-maverick-repelis-espanol-y-latino/profile

https://www.bramptonconsultancy.com/profile/ver-bullet-train-repelis-espanol-y-latino63749/profile

https://www.bramptonconsultancy.com/profile/Spiderhead-espanol-y-latino-0nl1n3/profile

https://www.bramptonconsultancy.com/profile/Minions-El-origen-de-Gru-espanol-y-latino-0nl1n3/profile

https://www.bramptonconsultancy.com/profile/Garra-espanol-y-latino-0nl1n3/profile

https://www.bramptonconsultancy.com/profile/Interceptor-espanol-y-latino-0nl1n3/profile

https://www.bramptonconsultancy.com/profile/Fire-Island-espanol-y-latino-0nl1n3/profile

https://www.bramptonconsultancy.com/profile/Vikram-espanol-y-latino-0nl1n3/profile

https://www.bramptonconsultancy.com/profile/white-elephant-espanol-y-latino-0nl1n3/profile

https://www.bramptonconsultancy.com/profile/What-Is-a-Woman-espanol-y-latino-0nl1n3/profile

https://www.bramptonconsultancy.com/profile/bobs-burgers-la-peli-cula-espanol-y-latino-0nl1n3/profile

https://www.bramptonconsultancy.com/profile/Last-Seen-Alive-espanol-y-latino-0nl1n3/profile

https://www.bramptonconsultancy.com/profile/animales-fantastico-espanol-y-latino-0nl1n3/profile

https://www.bramptonconsultancy.com/profile/doctor-strange-2-espanol-l4t1n0/profile

https://www.bramptonconsultancy.com/profile/jurassic-world-dominion-full-sub-eng/profile

https://geany.org/p/IwIs7/

https://ideone.com/akVM6M

https://yamcode.com/kivb9vfmau

https://pasteio.com/xFG72LEWfAaw

https://p.teknik.io/GLy0N

https://bitbin.it/DZpjv02u/

https://notes.io/qrWsA

https://txt.fyi/-/22167/1f2763c6/

https://controlc.com/da269211

http://cpp.sh/7fmtm

https://paste2.org/c4KpyZIC

https://ide.geeksforgeeks.org/74a111de-91a6-45b0-a9cb-814260e575bd

https://paiza.io/projects/EYyA4in-0E9ikNd7RZtZrg

https://paste.tbee-clan.de/jTK2q

https://pastebin.com/BmPpNS71

https://jsfiddle.net/ufjqgdoz/

https://rextester.com/EOBHH28183

https://www.wowace.com/paste/0aa2e971

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章