The Swift Den

TSD

The Swift Den

The Discord server for Swift developers. Get tips and snippets for your projects!

Join

swift-development

javascript

python

rust

c-sharp

For??

the for word is throwing me off here, he could've used any other word right? it's not anything syntaxt related? ( the for in func setAge(for person: String, to value: Int) { )...
No description

menubar extra swiftui open main window on tray click?

Like title menubar extra swiftui open main window on tray click? There seem To be no way to just implement this. ...

Can't run Xcode at all

Hi. I'm using a MacBook Air M1, running Xcode Version 15.0 beta 2, on macOS Sonoma 14.0. When running a simple playground code of swift, i get an error: failed to launch proccess. this operation couldn't be complete. StackOverflow claims the solution is to disable Rosetta for xcode by going to the xcode app file, selecting get info and unchecking the Rosetta checkbox. However, I don't have such a box. I tried to run some command someone said and it shows i'm using 2 different architectures as showin in picture. Is that okay? Anyways, I don't know what to do. Apprecieate any help, thanks....
No description

XCode concern please help

Hello, I am a user on Macbook, and I am looking to make a simple website on XCode, preferably with HTML/CSS/Java but it seems incredibly confusing to do so. I see that most people use swift on XCode but I was just wondering if there was a way to make a regular html site on Xcode...

AR Measurement app using RealityKit

#swift-development Value of type - 'ARViewContainer' has no member 'parentSession' can anyone please help me with the error in the image...
No description

How to Rename a Project/App in Xcode

I'm not sure what's the best way in doing this. πŸ‘€

opensource / full version paddle alternative opensource?

Hi everyone im building a swift ui app with a free version and an upgraded features for a small payment. Is there anywhere in the xcode swiftui world For licensing software with a femote api like paddle does? ...

Is it possible to replicate Mac's standard Help menu Search item?

Old programmer but Apple programming noob. I wanted to make a menubar-only app that had a text entry field in its submenu, just like Help/Search. It compiles with no errors and runs with no errors and no log output but the TextField between the "Buttons" dosn't appear. ```swift...
No description

How to position vertical Slider

I'm an old programmer but new to Mac and SwiftUI. I'm trying to get a vertical Slider positioned right up against the right edge of the window. Apparently this requires rotation:
Slider(value: $vx).rotationEffect(.degrees(v1))
Slider(value: $vx).rotationEffect(.degrees(v1))
But this rotation is just an effect. All measurements, bounding boxes, alignment, etc that effect its size and position behave as though it's still horizontal, which makes it incredibly unintuitive and frustrating to reason about, especially when new and unfamiliar with how positioning etc is done even for normal UI elements....

View Changing in Simulator not Preview

I've noticed that these lines of code, whenever I run them in the simulator, it would preview the changes in view. However, whenever I run them in the Xcode preview, it wouldn't change the view at all? I'm quite confused about this. ```swift import SwiftUI ...

NSScreen visibleFrame / safeAreaInsets not adding up right?

I'm trying to compare visibleFrame and frame to figure out whether the dock is currently showing on a given screen. Of course, I need to account for the menubar and any inset caused by a macbook notch as part of this. However, the number I'm getting don't quite add up right! For example, on my M2 Macbook Air: frame has a height of 956 (as expected) visibleFrame has a height of 919...

SideMenuView help please, I don't have long

I have a completely fine SideMenuView and no errors but nothing comes up on the app preview, I will probably send a the code and that tomorrow

Changing a Boolean when a key is pressed.

Does anyone know how I would be able to change a Boolean when a key is pressed on a keyboard?

AngularGradient issue

Hello! I'm trying to replicate a 4 point gradient you see on the left, but I'm getting this weird line that doesn't let black and red connect and it looks like that colors do not start from corners, but are a bit off. Any help is appreciated ```swift AngularGradient( gradient: Gradient(colors: [.black, .black, .white, .red]), ...
No description

MacOS user-level custom FAT16 USB volume

There's a slightly tweaked FAT16 implementation used on some Akai samplers. I've created an emulator of one of those samplers. It supports r/w USB volumes with a custom FAT16 implementation. All of this works, but currently goes via the deprecated AuthorizationExecuteWithPrivileges for achieving raw USB volume access. Yesterday I looked into migrating to SMJobBless, but it also turns out to be deprecated. It's an incredible amount of work, and this SMJobBless example gave the same error as the "Hello job bless" I tried adding directly to my project, which is "Error Domain=CFErrorDomainLaunchd Code=4". Then I looked into using FUSE, but from what I understand, opening a raw USB volume still requires the user-level process to be elevated. Is this correct?...

Can someone please send code for a side menu view?

I just saw it in a forum here and am curious and it sounds like a fun interesting challenge, please tell me how and I will experiment and adapt

Buttons not working on SideMenuView

Hello good morning. I am trying to make an application and in the homescreen I have a SideBar and inside several buttons. I can not get the buttons to work. Also I get this error in console when I run it "NavigationLink presenting a value must appear inside a NavigationStack or NavigationSplitView. Link will be disabled." but I can't solve the error. ...

Nondescript crash in my SwiftData app when trying to access a dictionary

I'm making an app for a school project in SwiftUI and SwiftData. It's a habit tracker and I have a SwiftData class for persisting basic habits. Where the problem started is that I'm trying to implement a way to track when a certain habit was completed. I deleted my existing instances of the class and added a dictionary under self.isCompleted as [Date:Bool] (so 3rd of August = true etc.)...