Swift

steveriggins,
@steveriggins@mastodon.social avatar

So yeah you can pin a package manager package to a reference, but that doesn’t pin any dependencies it has.

How are people locking down the entire SPM tree for security purposes?

finestructure,
@finestructure@mastodon.social avatar

@steveriggins Commit your Package.resolved and compile with --disable-automatic-resolution. This will make the build break if there's drift between what the manifest specifies and what resolved has locked in.

kaiengelhardt,
@kaiengelhardt@mastodon.social avatar

I have just open sourced a small package with convenience APIs for Auto Layout.

It‘s called Consti and you can find it on Github: https://github.com/kaiengelhardt/Consti.

I‘ve been using these convenience APIs in all my projects for years. Never had any need for a more complex Auto Layout replacement like SnapKit for example.

Jeehut,
@Jeehut@iosdev.space avatar

First time I'm using ’s async-let in my apps, can you help me understand what's going on? 👨‍💻

I expect that (1) and (2) run in parallel. But (3+) probably is sequential, cause I'm calling "try await" inside the loop, right? 🤔

How to fix that? Is there a simple way? 💪

Jeehut,
@Jeehut@iosdev.space avatar

@cocoaphony So there is no syntactic sugar for running an array of tasks? I wanted to avoid TaskGroup because it’s so much boilerplate.

I think I will keep it sequential then. Most people only have one Subscription Group anyway. 🤷‍♂️

finestructure,
@finestructure@mastodon.social avatar

@Jeehut @cocoaphony TaskGroup is for an indeterminate number of tasks, async let for when you have a fixed number. Give TaskGroup a try, it looks more boilerplate-ty than it actually is!

davidbures,
@davidbures@mstdn.social avatar

I'm working on my first CLI app built with Swift in ages (the only other CLI app I made was my very first Swift app in 2020).

What do you think of the way the output looks? 😊

ctietze,
@ctietze@mastodon.social avatar

@davidbures Consistent indentation, nice 👍

shnhrrsn,

Javascript would be proud… Unexpected from though.

1> 5 / 0
error: repl.swift:1:3: error: division by zero
5 / 0
^

1> 5.0 / 0.0
$R0: Double = +Inf
2>

@swift

thias,
@thias@mastodon.social avatar

@shnhrrsn @swift isn’t that normal IEEE floating point behaviour?

pixel, (edited )
@pixel@social.pixels.pizza avatar

“This has come up several times on the forums, but I've never written it up in a standard place, so here it is: There are only three ways to get run-time polymorphism in Swift. Well, three and a half.”


https://belkadan.com/blog/2024/04/Run-time-Polymorphism-in-Swift/

Doozmen,

@pixel thanks for writing this up. Do you know how applies to Kotlin? Probably the Java part in your table?

pixel,
@pixel@social.pixels.pizza avatar

@Doozmen I didn't write it :)

sean,
@sean@scoat.es avatar

Sitting in on the Server Side Meetup stream right now.

https://www.youtube.com/watch?v=FULMRV3wIKg

sean,
@sean@scoat.es avatar

"this will blow some people's minds but you can have the compiler tell you about errors before you ship code to production” 🤣
~– @0xTim

davidbures,
@davidbures@mstdn.social avatar

An interesting Swift question:

Is there a way to pick a random English word from the system dictionary without having to include that entire dictionary in the app bundle?

I’m writing a CLI for some work-related stuff and need a way to generate a random English word. I don’t want to include entire dictionaries within the tool itself, so I thought there might be a way to get a random word from the system dictionary.

dimitribouniol,
@dimitribouniol@mastodon.social avatar

@davidbures Hopefully its not sandbox restricted or something silly like that!

davidbures,
@davidbures@mstdn.social avatar

@dimitribouniol Luckily I never use the sandbox 😂

swiftly,

Can anyone point me to any resources they recommend on building Widgets for macOS which pay particular attention to dynamic configuration (selecting user created values from the main app) and interactivity?

JTostitos,
@JTostitos@techhub.social avatar

@swiftly some of these examples may be of use to you: https://github.com/pawello2222/WidgetExamples#deeplink-widget

fancypat,

Hi pals, ever wish there was an app just for reading Swift Evolution proposals? Me neither. Anyways, I built one: https://testflight.apple.com/join/qmH8gk0n

It's called Evolreader (because it's for reading Swift Evol-ution... you get it). It downloads the swift-evolution repo to your device so you can read stuff offline. It also saves your progress along the way.

I had fun making it, it's free, and maybe some of you might enjoy it. Here, have some hashtags and screenshots.

image/png
image/png

patrickmcconnell,

I was unable to push an archive build in until I removed some preview content? The build otherwise works fine until I try an archive. Something feels wrong there but I don’t have time to do more than comment out the “offending” code

luckkerr,
@luckkerr@mastodon.world avatar

@patrickmcconnell somewhere in that preview you use code that is marked as debug only? Try also surrounding preview with DEBUG

ctietze,
@ctietze@mastodon.social avatar

In a lot of things are zero-overhead abstractions.

There being no overhead, there's no excuse not to wrap things in your own structs except that it's effort.

That's the point of this. To spend effort writing the right thing to avoid thinking the wrong thing in the future.

kaybutter,
@kaybutter@mastodon.social avatar

@ctietze This! I do this all the time, even for things like ID types. It’s so much clearer to the pass a UserID type than a string. Especially if you have a lot of other things with ids.
Then the compiler won’t even let you pass the wrong thing in the future.

ctietze,
@ctietze@mastodon.social avatar

@kaybutter This is such a big strength of Swift.

Being able to verify that you can reduce this to 0 overhead should be such a peace of mind, too

Lobrien,

@Migueldeicaza What did you use to write https://migueldeicaza.github.io/SwiftGodotDocs/tutorials/swiftgodot/your-first-extension ? I was thinking of doing Pong Wars to learn and writing up my experience.

Migueldeicaza,
@Migueldeicaza@mastodon.social avatar

@Lobrien that’s just Swift DocC, it generates these tutorials for you.

Source code is on the GitHub repository for SwiftGodot

tootsdk,
@tootsdk@iosdev.space avatar

A new release of TootSDK - 3.7.0 📣

https://github.com/TootSDK/TootSDK/releases/tag/3.7.0

What's changed:

  • Adds TootClient.deleteProfileAvatar() and TootClient.deleteProfileHeader() @technicat

Community contributions are greatly appreciated 🙌

ryanlintott,
@ryanlintott@mastodon.social avatar

Any ideas on how to make a UIAccessibility.Notification.announcement concurrency-safe?

PhilNeal,
@PhilNeal@mas.to avatar

Helped my good mate @respraycatherine dismantle her c.1911 Swift Bicycle today - the first stage in any and nearly everything was as it should be thank goodness but we had to have a little giggle at the !! of

davidbures,
@davidbures@mstdn.social avatar

What helped me the most to write good async functions in Swift is imagining @mattiem and @donnywals looking at me like this

mattiem,
@mattiem@mastodon.social avatar

@davidbures @donnywals I’m not sure who this 😅 don’t forget I’m old!

davidbures,
@davidbures@mstdn.social avatar
libei,

Is this a good way to do simple debounce? Will Task creations take too much resources? 🤔

tootsdk,
@tootsdk@iosdev.space avatar

A new release of TootSDK - 3.4.0 📣

https://github.com/TootSDK/TootSDK/releases/tag/3.4.0

What's changed:

  • Allow setting a list as "exclusive" @technicat

Community contributions are greatly appreciated 🙌

danwood,

This is pretty fun - in 5.9 and up, with the ability to use case and if statements to assign, you can very tersely express matching to more than one case of an enum. For example:

bealex,
@bealex@mastodon.social avatar

@danwood options are always welcome. This is a simple case, you can probably use even Sets and "contains" even. Switch might be useful if you have associated values.

nicklockwood,
@nicklockwood@mastodon.social avatar

@bealex @danwood another reason is that enum cases are only Equatable by default if they don't have payloads. If any of the cases you were testing for had an associated value then == wouldn't work, whereas this switch pattern still would

ole,
@ole@chaos.social avatar

Huge thanks to the Swift team for publishing (and maintaining!) documentation of underscored (and therefore unofficial/private) Swift language attributes. It’s been a big help. https://github.com/apple/swift/blob/main/docs/ReferenceGuides/UnderscoredAttributes.md

ole,
@ole@chaos.social avatar

@schwa Hah, I just came across this again today (in the context of CGFloat). I believe this would allow e.g. moving TopLevelEncoder/Decoder from Combine into the standard library, as was being discussed back in 2020? https://forums.swift.org/t/move-combines-toplevelencoder-and-topleveldecoder-protocols-into-the-standard-library/32494/5

SergKoren,
@SergKoren@writing.exchange avatar

Stupid question time. Is there an UIMenuController equivalent for a TextEditor in SwiftUI? How would I go about modifying the built-in popup menu?

andhash39,

Never change,

brandonhorst,
@brandonhorst@techhub.social avatar

@andhash39 I would use a switch here

mczachurski,
@mczachurski@mastodon.social avatar

I have devoted the last six months to this project. I am very pleased with the result. I know that there are still many things missing. This project also proves that it is possible to do a pretty complex API (server-side) in the Swift programming language. https://mastodon.social/@vernissage/112225820640477556

pylapp,
@pylapp@framapiaf.org avatar

@mczachurski Did you still plan to keep updated and enrich the “Vernissage for Pixelfed” iOS app? :blobcatcoffee:

mczachurski,
@mczachurski@mastodon.social avatar

@pylapp Yes, of course. My aim is to create a very simple platform (along with a new iOS client). A platform that is easy to install, focused on photos, thoroughly tested. And in the future Vernissage for Pixelfed will probably be renamed (to avoid confusion).

phranck, German
@phranck@chaos.social avatar

& developers: Presumed, you want to write a Swift Package for a SwiftUI app which contains specific code for both iOS and macOS.

What would your way to split the code platform wise.

jaanus,

@phranck @ctietze I think that is the way.

If it was the main app target, you could select in Xcode with checkboxes which app targets include the file, so you could have MyViewIOS included only in iOS target. As far as I know, you can’t do that with packages, so conditionals it is.

phranck,
@phranck@chaos.social avatar

@jaanus @ctietze Yap, unfortunately this isn't possible with packages.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • swift
  • DreamBathrooms
  • mdbf
  • ethstaker
  • magazineikmin
  • cubers
  • rosin
  • thenastyranch
  • Youngstown
  • osvaldo12
  • slotface
  • khanakhh
  • kavyap
  • InstantRegret
  • Durango
  • JUstTest
  • everett
  • tacticalgear
  • modclub
  • anitta
  • cisconetworking
  • tester
  • ngwrru68w68
  • GTA5RPClips
  • normalnudes
  • megavids
  • Leos
  • provamag3
  • lostlight
  • All magazines