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

Spotlight-like (or Alfred-like) 'popup menu' in SwiftUI?

It should be possible to do this since Alfred, a third-party app, clearly does it successfully.

Attaching position, rotation, extrinsic, gravity, intrinsics to an images metadata

Hi I’m looking to see if anyone has figured out how to: Attach position, rotation, extrinsic, gravity, intrinsics to an images metadata. Recently I have been using ARKit, RealityKit and SceneKit to capture my arframes data including cvpixelbuffers. I noticed that apples new object capture api for iOS natively saves all this data but their process is quite restrictive for actually capturing the images. Instead I’d rather use my method and then manually attach the metadata. I’ve been successful with the depth map and gps and exif dictionaries but the Apple documentation doesn’t exist for the remaining parameters. As of ios16 Apple introduced new fields like kIIOCameraModel_Intrinsics etc but it’s not clear that dictionary that is in so i don’t know how to add it to metadata l. Any one have any clue? I think with this information if you can attach it all in the image and then create a photogrammetrysession, object capture api will run faster and create 3d models to the scale and as close as position to the position of your world position origin transform…. Currently I get good 3d models with just the depth maps attached inside the images I make but their orientation is wrong due to lack of gravity meta data etc….....

Running Shell on iOS simulator w/ Swift

A Swift function that can run Shell ONLY on iOS simulator devices, it's similar to Objective-C's spawn() function but is compatible to iOS, unfortunately, the app breaks or freezes after you execute the function via manual like pressing a button. I'm still figuring out how to run sudo and making it automatically type in the root's password, and for people who thinks this is an exploit, the function contains posix_spawn, waitpid, and Pipe() which is added by default.

Uknown class view Controller

I have a code here, import UIKit class ViewController: UIViewController { ...

com.accounts.iTunes error

I am trying to implement some MediaPlayer and MusicKit features. Anyone know how I fix this bug on com.accounts.iTunes authentication error?

NSAttributedString from html is not loading resources

I'm trying to move from NSAttributedString.init(data:options:) to NSAttributedString.fromHTML(_:options), which is asynchronous. It's working fine, except that the CSS inside the html doesn't load my custom fonts. The previous version loaded then without any problem. I can share the code, but it's very app specific. ...

Picker not changing

hey y'all, how come this super simple code is not working for me? If I select a different unit in the Picker, it doesn't change its label ```swift import SwiftUI ...
Solution:
changed it to ```swift Picker("Original Unit", selection: $unitOriginal) { ForEach(unitList, id: .self) { unit in Text(unit)...

ISO Custom isn't working

Why wouldn't a custom ISO be supported? I am using an iPhone 13 Pro Max
No description

MagnificationGesture or MagnifyGesture

Which ru supposed to use? Magnification Gesture is deprecated and MagnifyGesture is IOs17 only

Single Line text detection with DataScannerViewController

Anybody know how to use the DataScannerViewController for detecting text line by line? Right now it just detects large blobs of text (each RecognizedItem) but I want to be able to split these detection blobs into multiple lines of detected text. I dont want to use VNTextRequest because detection is more spotty

OnChange() doesn't trigger inside picker navigation view

For some reason the on change that I put on textfield only triggered after I close the selection view. ```swift Picker("Game", selection: $selectedGame) { Text("No Game Selected").tag(0 as Int?)...

Error on one struct but not on the other

Why the difference between Person1 and Person2?
No description

Viewing A 360 Degree Images and videos

I am making a app for viewing 360 images and videos using gesture I am unable to find out it how it will be done

Offset very strange

I have a CameraPreview which is displaying very strange on the bottom of the screen i have following code ```swift...
No description

Assigning propertyWrapper

Hi, I am learning propertyWrappers in Swift last days and I found something strange on the internet. In this article https://nshipster.com/propertywrapper/ import Foundation @propertyWrapper...

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