Stack Overflow » Swift
25 FOLLOWERS
Stack Overflow is a public platform building the definitive collection of coding questions & answers. This community is a place to get all your queries solved regarding Swift, a general-purpose, multi-paradigm, compiled programming language developed by Apple Inc.
Stack Overflow » Swift
24m ago
I have setup XCode Cloud to build app whenever code pushed to master branch. How to trigger Xcode cloud to build app from Github Action workflow ..read more
Stack Overflow » Swift
24m ago
For the question I will use the objects Deck and Card. In Realm, imagine to have a Deck of cards, which has a list of Cards:
// object: Deck
@Persisted var cards: List<Card>
this list is written into the realm DB.
During the usage of the app, the user can decide to hide from the deck certain cards. To do this, I have to eliminate from the cards's list some of the cards, but realm wants me to do it in a written transaction.
However, the problem is that in this way I can't restore the original cards list.
Here obviously there are many approaches we can use, but you have to imagine havin ..read more
Stack Overflow » Swift
3h ago
I have a scroll view in swift ui that can house different content such as text or videos. I want the videos to play when they appear but only unmute when they are in the middle of the scroll view, and only 1 video player can be unmuted at a time. I currently achieve this affect but the scroll view becomes very laggy and buggy. Honestly the scroll view gets slightly laggy as I scroll past videos even without this functionality. How can I make the scroll view very smooth while being able to present multiple video players and the unmute feature?
My current approach is housing the currently unmute ..read more
Stack Overflow » Swift
3h ago
I want the background image and the green UI element to be at the top of the screen, but with the code below the green UI elements in the middle.
code:
struct AppointmentStep1: View {
@Environment(\.dismiss) var dismiss
var body: some View {
ZStack {
// Background image
Image("home_bg")
.resizable()
.scaledToFill()
.edgesIgnoringSafeArea(.all)
VStack {
HStack {
Button {
dismiss()
} label ..read more
Stack Overflow » Swift
4h ago
I like to create a height notification trigger for my Swiftui app by subclassing UNNotificationTrigger. When I climb a mountain and reach the height of 2000 meters, I will get à notification on my apple device. Please advise me how.
i read the apple document and find no clue ..read more
Stack Overflow » Swift
4h ago
I want screen background image and the green should be at the top of the screen but with below code why green area with text and button in the middle i want it to be at the top of the screen
code:
struct AppointmentStep1: View {
@Environment(\.dismiss) var dismiss
var body: some View {
ZStack {
// Background image
Image("home_bg")
.resizable()
.scaledToFill()
.edgesIgnoringSafeArea(.all)
VStack {
HStack {
Button {
dismiss()
} label: {
Image(syst ..read more
Stack Overflow » Swift
4h ago
I need to install the eSim from the app automatically. I added this code:
let ctpr = CTCellularPlanProvisioningRequest()
let ctcp = CTCellularPlanProvisioning()
But when I call this next code:
ctcp.addPlan(with: ctpr)
I get this case. unknown the result is: .unknown case It's always returns 'unknown'.
I also sent a request on Apple eSim entitlements a long time ago. But they didn't respond ..read more
Stack Overflow » Swift
10h ago
I have two apps that use sound. I am using the same code in both apps but the sound only works in one of the apps. In the app where it is not working I get the error message. I have checked the url and the file is present in both apps. Any help would be appreciated.
if soundOn {
let pathToSound = Bundle.main.path(forResource: "keyboardtick", ofType: "wav")
let url = URL(fileURLWithPath: pathToSound!)
do {
audioPlayer = try AVAudioPlayer(contentsOf: url)
audioPlayer?.play()
} catch {
print("Error in playing keyboard sound ..read more
Stack Overflow » Swift
12h ago
I try to crop video with AVAssetWriter and modify CMSampleBuffer
func modifySampleBuffer(_ sampleBuffer: CMSampleBuffer, cropRect: CGRect) -> CMSampleBuffer? {
guard let pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) else { return nil }
let ciImage = CIImage(cvImageBuffer: pixelBuffer)
let croppedCIImage = ciImage.cropped(to: cropRect).transformed(by: CGAffineTransform(translationX: -cropRect.origin.x, y: -cropRect.origin.y))
var newPixelBuffer: CVPixelBuffer?
CVPixelBufferCreate(kCFAllocatorDefault, Int(cropRect.width), Int(cropRect.height), kCVP ..read more
Stack Overflow » Swift
14h ago
I am looking for a way to draw a route on a map with your finger. The drawn route then needs to be converted into an actual route for car. In Swift or SwiftUI.
I have an example from another app that does exactly what I want to accomplish. Click here to see an example video. (All credits to the creators of this app: FootPath)
I have searched a lot online and found a lot about drawing routes, but nothing that matches what I want or can use for that. I am still in the brainstorming stage of how to get this done.
I am familiar with using mapKit and how to display routes and such, but this is lik ..read more