Category "swift"

Why is Xcode crashing when I try to preview?

Every time I am trying to resume my preview canvas in Xcode I get this annoying error. I tried restarting, moving the project to another location, and changing

iOS Deep link callbacks not working when the app is closed

I'm using a deep linking in my application and using this code in my SceneDelegate to segue to a view controller. func scene(_ scene: UIScene, openURLContexts U

Get the devices list from iPhone Bluetooth , including connected and unconnected devices

The Bluetooth search page of iPhone shows these offline Bluetooth headsets. I hope to get this list and show it in my app. Can I realize this function? How? th

Programmatic Control of Edit Widget Font Size?

SwiftUI offers .dynamicTypeSize(...) to control/limit the impact of user Text size preferences. An app developer, for example, can limit dynamic type to Dynamic

Change volume of audio track within AVMutableComposition

I'm trying to merge a pre-existing video with a newly recorded audio voiceover track. User can set the relative sound volume for the two audio tracks (audio bel

UILabels and UISlider for song time not updating in Mac Catalyst music player

I recently built a simple music app that does fine on my deactivated iPhone. I have since bought a Mac mini so I could run it natively on that platform with Mac

How do I center an Image view in pdf format with SwiftUI?

I have a vector (converted to Pdf) that I want to use as my background for my app. However, the Image is aligned all the way to the left as you'd expect when us

How to cancel the delayed thread?

I am executing set of tasks, and in order to span them over time I've used Thread.sleep(forTimeInterval: ... ) It adds pauses between executions. Then, on the m

How can I access the subviews in SwiftUI?

I am trying our SwiftUI and want to create a component on the lines of SwiftUI's components. So, here is what I am trying to do: Create a new view extending Vie

Swift // MLDataTable error: Couldn't lookup symbols:

import Cocoa import CreateML let data = try MLDataTable(contentsOf: URL(fileURLWithPath: "/Users/allan/Downloads/twitter-sanders-apple3.csv")) I got this erro

How to increase quality of rendered image for UIImageView?

I have an UIImageView with contentMode = .aspectFit. I have an image in imageView, which dimension is bigger than size of imageView. User can draw some lines an

Why primitive View in SwiftUI has no body?

The View protocol requires a body property: public protocol View { associatedtype Body : View @ViewBuilder var body: Self.Body { get } } Why have some

How to make a button (or any other element) show SwiftUI's DatePicker popup on tap?

I'm trying to achieve the simplest possible use case, but I can't figure it out. I have a picture of calendar. All I want is to show DatePicker popup when tappi

swift Xcode Secure Text Entry Asterisk not show when Screen Mirroring / Recording

I have checked the Secure Text Entry and entered "pwdTextfield.isSecureTextEntry = true" as the code. Therefore, I can see the asterisk well inside password tex

Link to fat Static Library inside Swift Package

I’m trying to build a Swift Package that wraps a fat static library written in C: libndi_advanced_ios.a from NewTek's Apple Advanced NDI SDK. I am having

iOS Deep Link from Widget when App closed?

My widget has several links that the user can click, the link are set up as follows: Link(destination: URL(string: "widget://start")!) Now I am able to detect

RealityKit – Why AnchorEntity position is always (x: 0, y: 0, z: 0)

I am using the following to to place an object on a plane. It works but the position of the anchor is always coming out to be 0,0,0 even though it is based on t

window.webkit.messageHandlers is null on ios 15

window.webkit.messageHandlers gives null on ios 15, but when I set config.limitsNavigationsToAppBoundDomains = true; it works properly. But I don't want to res

Why does this swift async-await code fails with leaked continuation?

I am experimenting with Swift async-await and AsyncSequence protocol, Here is the code: struct AsyncNumbers<Element: Numeric>: AsyncSequence { private

SwiftUI - MapAnnotation is showing up in wrong position

I am trying to display multiple map annotations to Apple Maps In SwiftUI, but the annotations are showing in some wrong perspective. All positions are displayed