Swift is a powerful and intuitive programming language for Apple platforms and beyond.

Swift Documentation

Posts under Swift tag

2,037 Posts
Sort by:
Post not yet marked as solved
25 Replies
19k Views
We are working on a new iOS application utilizing the new iOS 17 APIs, and I have updated Xcode to Xcode 15 Beta, and my iPhone 12 Pro to iOS 17 Beta 2, though this issue was also present on iOS 17 Beta 1. In Xcode, for "Signing and Capabilities" I have my Team set to my personal team, utilizing the "Automatically manage signing" tick. While the app will build and install on my phone, I immediately receive this error, with no popup to trust the developer. Going to Settings > General > VPN and Device Management, I can see my Development Team, and I am able to Trust my team. When trying to then Verify App(s), it tells me it will use my internet connection to verify the application. However, it will then do nothing, with no error, regardless of how many times I attempt to verify. Trying to open the app from my home screen will result in the repeated "Unable to Verify Error". Trying to reset network settings does not result in any change in this behavior, nor does a reset of the phone. I have tried 4 different high quality WiFi networks, as well as a fully connection AT&T cellular LTE connection, and still receive this error. I am running out of diagnostic scenarios, and I'm curious if anyone has found a resolution to this?
Posted
by covt.
Last updated
.
Post not yet marked as solved
2 Replies
34 Views
I'm developing an application using SwiftUI and SwiftData. The app includes a pricing section, and I'd like it to have an initial default value for pricing. Additionally, when updating the app on the App Store, I also want to update the prices. However, I'd like users to have the option to create their own prices if they don't want to use the ones I suggest. I want to save these prices obtained from the user because I'll be using these values for some operations later on. I'm wondering how to achieve this. Should I use SwiftData or UserDefaults for managing the data, or should I save the prices to a JSON file? If I opt for saving to a JSON file, would it be possible to update the JSON file when updating the app? Please feel free to ask any questions. Thank you in advance for your responses.
Posted Last updated
.
Post not yet marked as solved
0 Replies
29 Views
Hey, im training an MLImageClassifier via the train()-method: guard let job = try? MLImageClassifier.train(trainingData: trainingData, parameters: modelParameter, sessionParameters: sessionParameters) else{ debugPrint("Training failed") return } Unfortunately the metrics of my MLProgress, which is created from the returning MLJob while training are empty. Code for listening on Progress: job.progress.publisher(for: \.fractionCompleted) .sink{[weak job] fractionCompleted in guard let job = job else { debugPrint("failure in creating job") return } guard let progress = MLProgress(progress: job.progress) else { debugPrint("failure in creating progress") return } print("ProgressPROGRESS: \(progress)") print("Progress: \(fractionCompleted)") } .store(in: &subscriptions) Printing the Progress ends in: MLProgress(elapsedTime: 2.2328420877456665, phase: CreateML.MLPhase.extractingFeatures, itemCount: 32, totalItemCount: Optional(39), metrics: [:]) Got the Same result when listening to MLCheckpoints, Metrics are empty aswell: MLCheckpoint(url: URLPATH.checkpoint, phase: CreateML.MLPhase.extractingFeatures, iteration: 32, date: 2024-04-18 11:21:18 +0000, metrics: [:]) Can some1 tell me how I can access the metrics while training? Thanks!
Posted Last updated
.
Post not yet marked as solved
1 Replies
75 Views
Hello, I have RouteManage, which is a Class and has following Protokolls: NSObject, Codable ,ObservableObject and is an Singleton and I have a RouteTrackingAttributes which has ActivityAttributes I tried to set let attributes = RouteTrackingAttributes() let state = RouteTrackingAttributes.ContentState(routeManager: routeManger) activity = try? Activity.request() the update from singleton. But it dosen't work. It worked only once? thank you for help greeting Fabian
Posted Last updated
.
Post not yet marked as solved
0 Replies
49 Views
Hi, In Windows and Linux, it's possible to ask a printer to print content programmatically in Black & White. This may be referred to as "Monochrome", "Grayscale", "B&W", depending on the device driver. For feature parity with other operating systems, I'd like to do the same -- programmatically -- in macOS using Objective-C or Swift. Is this possible? If not, what's the best, formal way to request this useful OS feature to Apple so that it may be added in a future release? More context about this request: https://github.com/openjdk/jdk/pull/18195
Posted
by tresf.
Last updated
.
Post not yet marked as solved
0 Replies
56 Views
I asked this on StackOverflow too, but did not get a response. Copying verbatim (images might not work as expected). Short question: which instructions other than floating point arithmetic instructions like fmul, fadd, fdiv etc are counted under the hardware event INST_SIMD_ALU in XCode Instruments? Alternatively, how can I count the number of floating point operations in a program using CPU counters? I want to measure/estimate the FLOPs count of my program and thought that CPU counters might be a good tool for this. The closest hardware event mnemonic that I could find is INST_SIMD_ALU, whose description reads. Retired non-load/store Advanced SIMD and FP unit instructions So, as a sanity check I wrote a tiny Swift code with ostensibly predictable FLOPs count. let iterCount = 1_000_000_000 var x = 3.1415926 let a = 2.3e1 let ainv = 1 / a // avoid inf for _ in 1...iterCount { x *= a x += 1.0 x -= 6.1 x *= ainv } So, I expect there to be around 4 * iterCount = 4e9 FLOPs. But, on running this under CPU Counters with the event INST_SIMD_ALU I get a count of 5e9, 1 extra FLOP per loop iteration than expected. See screenshot below. dumbLoop is the name of the function that I wrapped the code in. Here is the assembly for the loop +0x3c fmul d0, d0, d1 <---------------------------------- +0x40 fadd d0, d0, d2 | +0x44 fmov d4, x10 | +0x48 fadd d0, d0, d4 | +0x4c fmul d0, d0, d3 | +0x50 subs x9, x9, #0x1 | +0x54 b.ne "specialized dumbLoop(_:initialValue:)+0x3c" --- Since it's non-load/store instructions, it shouldn't be counting fmov and b.ne. That leaves subs, which is an integer subtraction instruction used for decrementing the loop counter. So, I ran two more "tests" to see if the one extra count comes from subs. On running it again with CPU Counters with the hardware event INST_INT_ALU, I found a count of one billion, which adds up with the number of loop decrements. Just to be sure, I unrolled the loop by a factor of 4, so that the number of loop decrements becomes 250 million from one billion. let iterCount = 1_000_000_000 var x = 3.1415926 let a = 2.3e1 let ainv = 1 / a // avoid inf let n = Int(iter_count / 4) for _ in 1...n { x *= a x += 1.0 x -= 6.1 x *= ainv x *= a x += 1.0 x -= 6.1 x *= ainv x *= a x += 1.0 x -= 6.1 x *= ainv x *= a x += 1.0 x -= 6.1 x *= ainv } print(x) And it adds up, around 250 million integer ALU instructions, and the total ALU instructions is 4.23 billion, somewhat short of the expected 4.25 billion. So, at the moment if I want to count the FLOPs in my program, one estimate I can use is INST_SIMD_ALU - INST_INT_ALU. But, is this description complete, or are there an other instructions that I might spuriously count as floating point operations? Is there a better way to count the number of FLOPs?
Posted
by cku.
Last updated
.
Post not yet marked as solved
1 Replies
59 Views
Following the recent 17.4.1 update, while QR code scanning has been resolved, we're still experiencing problems with barcode scanning on iPad devices. Specifically, the AVCaptureMetadataOutput delegate is not functioning as expected. This issue is significantly impacting our application's functionality. We kindly request immediate attention to this matter to ensure seamless operation.
Posted
by devtatva.
Last updated
.
Post not yet marked as solved
0 Replies
68 Views
Within Xcode when initializing the client via code below, do I insert this code in my app declaration Swift file or can it be just another Swift file included in my app? Thanks! let client = Graph.Client( shopDomain: "your-shop-name.myshopify.com", apiKey: "your-storefront-access-token", locale: Locale(identifier: "en_US") )
Posted Last updated
.
Post not yet marked as solved
1 Replies
106 Views
Hi Folks, I would like it so that when I press the button on the HomeScreen, the TabView hides and the toolbar item appears in its place. Currently, the toolbar item stacks on top of the TabView. However, when I try to hide the TabView, with an if condition for example, the screens turn black. I think it's because of the screen calls in the TabView. Is there an option to achieve what I want? I'm new to SwiftUI, so I'm very glad for any Solutions or advices. struct NavBar: View { var body: some View { TabView { HomeScreen() .tabItem { Label( "Home", systemImage: "house" ) } ... } } } struct HomeScreen: View { @State private var showDeleteButton = false var body: some View { Button("Show/Dissmiss Delete Button", action: { showDeleteButton.toggle() }).toolbar { if showDeleteButton { ToolbarItem(placement: .bottomBar) { Button("Delete", action: {}) } } } } }
Posted Last updated
.
Post not yet marked as solved
1 Replies
92 Views
I want to have a list of tasks and each task have a list of navigationLinks each NavigationLink has subtaskName as a label and subtaskDetails as destination and every List (tasks list and subtasks list) has .onDelete and .onMove behaviors But when I implement the code below the navigationLink act weird. navigationLink inside List inside List is not navigating when clicked and it is only triggered and navigates to SubtaskDetailView when clicking the outer List row. How can I fix this problem? import SwiftUI struct ContentView: View { @State private var tasks: [Task] = [ Task(name: "Task 1", subtasks: [ Subtask(name: "Subtask 1", details: "Details for Subtask 1"), Subtask(name: "Subtask 2", details: "Details for Subtask 2") ]), Task(name: "Task 2", subtasks: [ Subtask(name: "Subtask 1", details: "Details for Subtask 1"), Subtask(name: "Subtask 2", details: "Details for Subtask 2") ]), Task(name: "Task 3", subtasks: [ Subtask(name: "Subtask 1", details: "Details for Subtask 1"), Subtask(name: "Subtask 2", details: "Details for Subtask 2") ]) ] var body: some View { NavigationView { List { ForEach(tasks.indices, id: \.self) { index in TaskView(task: $tasks[index]) } .onDelete(perform: deleteTask) .onMove(perform: moveTask) } .navigationTitle("Tasks") .toolbar { EditButton() } } } private func deleteTask(at offsets: IndexSet) { tasks.remove(atOffsets: offsets) } private func moveTask(from source: IndexSet, to destination: Int) { tasks.move(fromOffsets: source, toOffset: destination) } } struct TaskView: View { @Binding var task: Task var body: some View { List { Text(task.name) .font(.headline) .padding(.bottom, 4) ForEach(task.subtasks.indices, id: \.self) { index in NavigationLink(destination: SubtaskDetailView(details: task.subtasks[index].details)) { Text(task.subtasks[index].name) } } .onDelete(perform: { indexSet in task.subtasks.remove(atOffsets: indexSet) }) .onMove(perform: { indices, newOffset in task.subtasks.move(fromOffsets: indices, toOffset: newOffset) }) } .frame(minHeight: CGFloat(task.subtasks.count) * 80) } } struct SubtaskDetailView: View { let details: String var body: some View { Text(details) .navigationTitle("Subtask Details") } } struct Task: Identifiable { let id = UUID() var name: String var subtasks: [Subtask] } struct Subtask: Identifiable { let id = UUID() var name: String var details: String } Thanks!
Posted Last updated
.
Post not yet marked as solved
2 Replies
71 Views
Hello, It's been more than three weeks that i've been freaking out about this crash that occurs while establishing a BLE connection to a peripheral, scan wifi networks and connect to one of them via BLE. Here is the crash's stacktrace and I hope that I can get some help in order to resolve this ungoing crash : +0x284 mov x2, x22 +0x288 mov x3, x28 +0x28c bl "swift::ConcurrentReadableHashMap<MallocTypeCacheEntry, swift::LazyMutex>::resize(swift::ConcurrentReadableHashMap<MallocTypeCacheEntry, swift::LazyMutex>::IndexStorage, unsigned char, MallocTypeCacheEntry*)" +0x290 mov x23, x0 +0x294 add x0, sp, #0x2c +0x298 mov x1, x23 +0x29c mov x2, x24 +0x2a0 mov x3, x28 +0x2a4 bl "std::__1::pair<MallocTypeCacheEntry*, unsigned int> swift::ConcurrentReadableHashMap<MallocTypeCacheEntry, swift::LazyMutex>::find<unsigned int>(unsigned int const&, swift::ConcurrentReadableHashMap<MallocTypeCacheEntry, swift::LazyMutex>::IndexStorage, unsigned long, MallocTypeCacheEntry*)" +0x2a8 and x26, x1, #0xffffffff +0x2ac cbnz x27, "_swift_allocObject_+0x2bc" +0x2b0 b "_swift_allocObject_+0x2cc" +0x2b4 mov x26, x1 +0x2b8 cbz x27, "_swift_allocObject_+0x2cc" +0x2bc ldr w8, [x27] +0x2c0 mov x22, x27 +0x2c4 cmp w24, w8 +0x2c8 b.lo "_swift_allocObject_+0x358" +0x2cc add x8, x24, x24, lsr #2 +0x2d0 add x9, x24, #0x1 +0x2d4 cmp x8, x9 +0x2d8 csinc x8, x8, x24, hi +0x2dc lsl x8, x8, #3 +0x2e0 add x0, x8, #0x8 +0x2e4 bl "DYLD-STUB$$malloc_good_size" +0x2e8 mov x28, x0 +0x2ec mov w1, #0xb407 +0x2f0 movk w1, #0x5640, lsl #16 +0x2f4 bl "0x1a255c690" +0x2f8 cbz x0, "_swift_allocObject_+0x49c" +0x2fc mov x22, x0 +0x300 mov x8, #0x7fffffff8 +0x304 add x8, x28, x8 +0x308 lsr x8, x8, #3 +0x30c str w8, [x0] +0x310 cbz x27, "_swift_allocObject_+0x34c" +0x314 add x0, x22, #0x8 +0x318 lsl x2, x24, #3 +0x31c mov x1, x25 +0x320 bl "DYLD-STUB$$memcpy" +0x324 mov w0, #0x10 +0x328 mov x1, #0x3c70 +0x32c movk x1, #0xaff9, lsl #16 +0x330 movk x1, #0x80, lsl #32 +0x334 movk x1, #0xa, lsl #48 +0x338 bl "0x1a255c690" +0x33c adrp x8, 403725 ; 0x6290d000 +0x340 ldr x9, [x8, #0xdf8] +0x344 stp x9, x27, [x0] +0x348 str x0, [x8, #0xdf8] +0x34c adrp x8, 403725 ; 0x6290d000 +0x350 add x8, x8, #0xde0 +0x354 stlr x22, [x8] +0x358 add x8, x22, x24, lsl #3 +0x35c ldp x10, x22, [sp, #0x8] +0x360 mov x9, x22 +0x364 bfi x9, x21, #32, #32 +0x368 str x9, [x8, #0x8] +0x36c stlr w10, [x20] +0x370 and x8, x26, #0xffffffff +0x374 and w16, w23, #0x3 +0x378 ldp x26, x25, [sp, #0x18] +0x37c cmp x16, #0x3 +0x380 csel x16, x16, xzr, ls +0x384 adrp x17, 0 ; 0x0 +0x388 add x17, x17, #0x6cc +0x38c ldrsw x16, [x17, x16, lsl #2] +0x390 adr x17, #0x0 +0x394 add x16, x17, x16 +0x398 br x16 +0x39c lsl x8, x8, #2 +0x3a0 lsl x8, x10, x8 +0x3a4 orr x8, x8, x23 +0x3a8 adrp x9, 403725 ; 0x6290d000 +0x3ac add x9, x9, #0xde8 +0x3b0 stlr x8, [x9] +0x3b4 b "_swift_allocObject_+0x3fc" +0x3b8 and x9, x23, #0xfffffffffffffffc +0x3bc tst x23, #0x3 +0x3c0 csel x9, xzr, x9, eq +0x3c4 add x8, x9, x8 +0x3c8 stlrb w10, [x8] +0x3cc b "_swift_allocObject_+0x3fc" +0x3d0 and x9, x23, #0xfffffffffffffffc +0x3d4 tst x23, #0x3 +0x3d8 csel x9, xzr, x9, eq +0x3dc add x8, x9, x8, lsl #1 +0x3e0 stlrh w10, [x8] +0x3e4 b "_swift_allocObject_+0x3fc" +0x3e8 and x9, x23, #0xfffffffffffffffc +0x3ec tst x23, #0x3 +0x3f0 csel x9, xzr, x9, eq +0x3f4 add x8, x9, x8, lsl #2 +0x3f8 stlr w10, [x8] +0x3fc dmb ish +0x400 adrp x8, 403725 ; 0x6290d000 +0x404 ldr w8, [x8, #0xdd8] +0x408 cbnz w8, "_swift_allocObject_+0x438" +0x40c adrp x8, 403725 ; 0x6290d000 +0x410 ldr x23, [x8, #0xdf8] +0x414 cbz x23, "_swift_allocObject_+0x430" +0x418 ldp x20, x0, [x23] +0x41c bl "DYLD-STUB$$free" +0x420 mov x0, x23 +0x424 bl "DYLD-STUB$$free" +0x428 mov x23, x20 +0x42c cbnz x20, "_swift_allocObject_+0x418" +0x430 adrp x8, 403725 ; 0x6290d000 +0x434 str xzr, [x8, #0xdf8] +0x438 adrp x0, 403725 ; 0x6290d000 +0x43c add x0, x0, #0xdf0 +0x440 bl "0x1a255c9f0" +0x444 bfi x22, x21, #32, #32 +0x448 mov x0, x26 +0x44c mov x1, x25 +0x450 mov x2, x22 +0x454 bl "swift::swift_slowAllocTyped(unsigned long, unsigned long, unsigned long long)" +0x458 cbz x19, "_swift_allocObject_+0x470" +0x45c mov x16, x0 +0x460 movk x16, #0x6ae1, lsl #48 +0x464 mov x17, x19 +0x468 pacda x17, x16 +0x46c b "_swift_allocObject_+0x474" +0x470 mov x17, #0x0 +0x474 mov w8, #0x3 +0x478 stp x17, x8, [x0] +0x47c ldp x29, x30, [sp, #0x80] +0x480 ldp x20, x19, [sp, #0x70] +0x484 ldp x22, x21, [sp, #0x60] +0x488 ldp x24, x23, [sp, #0x50] +0x48c ldp x26, x25, [sp, #0x40] +0x490 ldp x28, x27, [sp, #0x30] +0x494 add sp, sp, #0x90 +0x498 retab +0x49c bl "_swift_allocObject_.cold.1"
Posted Last updated
.
Post not yet marked as solved
0 Replies
72 Views
This code works when I run it in the iOS Simulator with iOS 17.0.1: let passcodeInput = springboard.secureTextFields["Passcode field"] _ = passcodeInput.waitForExistence(timeout: 10) passcodeInput.tap() However if I run it on the iOS Simulator with iOS 17.4 I get this error: t = nans Checking existence of `"Passcode field" SecureTextField` t = nans Capturing debug information t = nans Requesting snapshot of accessibility hierarchy for app with pid 66943 t = nans Tap "Passcode field" SecureTextField t = nans Wait for com.apple.springboard to idle t = nans Find the "Passcode field" SecureTextField t = nans Find the "Passcode field" SecureTextField (retry 1) t = nans Find the "Passcode field" SecureTextField (retry 2) t = nans Requesting snapshot of accessibility hierarchy for app with pid 66943 <unknown>:0: error: PRCheckUITests : Failed to tap "Passcode field" SecureTextField: No matches found for Descendants matching type SecureTextField from input {( Application, pid: 66943, label: ' ' )} Did the hardcoded string "Passcode field" change for iOS 17.4? How can I access the passcode field through springboard in a test?
Posted
by SirEl12.
Last updated
.
Post not yet marked as solved
0 Replies
34 Views
I am following this code https://developer.apple.com/documentation/corenfc/building_an_nfc_tag-reader_app to implement a simple scanner for NFC. Now whenever I scan I am always getting <NSXPCConnection: 0x3036981e0> connection to service with pid 60 named com.apple.nfcd.service.corenfc: Exception caught during decoding of received selector didDetectExternalReaderWithNotification:, dropping incoming message. Exception: Exception while decoding argument 0 (#2 of invocation): Exception: decodeObjectForKey: class "NFFieldNotificationECP1_0" not loaded or does not exist>. this error. It always calls this function func readerSession(_ session: NFCNDEFReaderSession, didInvalidateWithError error: Error)
Posted Last updated
.
Post not yet marked as solved
0 Replies
76 Views
In my react native app deployed on appstore. I've added Privacy.Info file to declare privacy manifest as requested by Apple. But as soon as I added this file in my project using xcode, I am getting the Multiple commands produce Error when I make the build. Below is the code for my privacy.info file, which I've added in the root ios folder of my react native project. <dict> <key>NSPrivacyAccessedAPITypes</key> <array> <dict> <key>NSPrivacyAccessedAPIType</key> <string>NSPrivacyAccessedAPICategoryDiskSpace</string> <key>NSPrivacyAccessedAPITypeReasons</key> <array> <string>E174.1</string> </array> </dict> <dict> <key>NSPrivacyAccessedAPIType</key> <string>NSPrivacyAccessedAPICategoryUserDefaults</string> <key>NSPrivacyAccessedAPITypeReasons</key> <array> <string>CA92.1</string> </array> </dict> <dict> <key>NSPrivacyAccessedAPIType</key> <string>NSPrivacyAccessedAPICategoryFileTimestamp</string> <key>NSPrivacyAccessedAPITypeReasons</key> <array> <string>C617.1</string> </array> </dict> <dict> <key>NSPrivacyAccessedAPIType</key> <string>NSPrivacyAccessedAPICategorySystemBootTime</string> <key>NSPrivacyAccessedAPITypeReasons</key> <array> <string>35F9.1</string> </array> </dict> </array> </dict>
Posted Last updated
.
Post not yet marked as solved
2 Replies
105 Views
Hi, The goal is the move an element based on an input matrix using timer to trigger changes in the position. Say we have 2 positions, an input matrix and the element that is to be moved defined: import SwiftUI import Foundation // Positions struct PositionConstants { static let pos_1 = CGPoint(x: 155, y: 475) static let pos_2 = CGPoint(x: 135, y: 375) } // Input Matrix struct Input { static let input_1: [[Int]] = [ [ 1, 1, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 1, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ], ] } // Element Class class Element: ObservableObject { let imageName: String let name: String let size: CGSize @Published var position: CGPoint init(imageName: String, name: String, size: CGSize, position: CGPoint) { self.imageName = imageName self.name = name self.size = size self.position = position } } Moving the element without a function works perfectly fine: struct Pos_View: View { @ObservedObject var element_1 = Element(imageName: "pic_1", name: "", size: CGSize(width: 100, height: 100), position: PositionConstants.pos_1) let Input_Matrix = Input.input_1 // Index to track current row in matrix @State private var currentIndex = 0 // Timer to trigger updates private let timer = Timer.publish(every: 1.0, on: .main, in: .common).autoconnect() var body: some View { VStack { // Display element Image(element_1.imageName) .resizable() .frame(width: element_1.size.width, height: element_1.size.height) .position(element_1.position) .onReceive(timer) { _ in // Update element position based on matrix if currentIndex < Input_Matrix.count { let isFirstElementOne = Input_Matrix[currentIndex][0] == 1 let newPosition = isFirstElementOne ? PositionConstants.pos_2 : PositionConstants.pos_1 withAnimation { element_1.position = newPosition } currentIndex += 1 } else { // Stop the timer when we reach the end of the matrix timer.upstream.connect().cancel() } } } } } struct ContentView: PreviewProvider { static var previews: some View { Pos_View() } } But when using a function to trigger the animation, I get the error "Cannot use mutating member on immutable value: 'self' is immutable" when calling the function using a button: struct Pos_View: View { @ObservedObject var element_1 = Element(imageName: "pic_1", name: "", size: CGSize(width: 100, height: 100), position: PositionConstants.pos_1) let Input_Matrix = Input.input_1 // Index to track current row in matrix @State var currentIndex = 0 // Timer to trigger updates private var timer: Timer? var body: some View { VStack { // Display element Image(element_1.imageName) .resizable() .frame(width: element_1.size.width, height: element_1.size.height) .position(element_1.position) // Button to start animation Button("Start Animation") { startAnimation() } } } mutating func startAnimation() { currentIndex = 0 // Reset index before starting animation timer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) {timer in if self.currentIndex < self.Input_Matrix.count { let isFirstElementOne = self.Input_Matrix[self.currentIndex][0] == 1 let newPosition = isFirstElementOne ? PositionConstants.pos_2 : PositionConstants.pos_1 withAnimation { self.element_1.position = newPosition } self.currentIndex += 1 } else { // Stop the timer when we reach the end of matrix timer.invalidate() } } } } struct ContentView: PreviewProvider { static var previews: some View { Pos_View() } } The function is defined as mutating and the element as as @ObservedObject. Anyone has a clue?
Posted
by Heph.
Last updated
.
Post not yet marked as solved
0 Replies
56 Views
I have a basic Xcode project where I am adding a swift file with the below AppIntent. This causes the AppIntent action to be added in the Shortcuts app in MacOS. I wanted to know how is this AppIntent directly be able to add the Intent action in the shortcuts app. I have checked the build setting in the Xcode project but I did not find anything being generated that could have caused this. Can someone help me understand what internally happens that causes the action to be added to the shortcuts app? import AppIntents import SwiftUI @available(macOS 13, *) struct TWIntent: AppIntent { static let title: LocalizedStringResource = "TWMeditationIntent" static var description = IntentDescription("try adding this sample action as your TW shortcut") static var parameterSummary: some ParameterSummary { Summary("Get information on \(\.$TWType)") } // we can have multiple parameter of diff types @Parameter(title: "TWType", description: "The type to get information on.") var TWType: String func perform() async throws -> some IntentResult & ReturnsValue<String> & ProvidesDialog { NSLog(AppDelegate.TAG + "Inside perform() in MeditationIntent") return .result(value: TWType, dialog: "Logged a 15 minute break.\(TWType)") } }
Posted Last updated
.
Post not yet marked as solved
2 Replies
120 Views
After numerous trials and errors, we finally succeeded in implementing VR180. However, there is a problem. Videos played via a URL (Internet) connection experience significant lag. Initially, I thought it was a bitrate issue. But after various tests, I began to suspect that the problem might be with the internet connection processing..itself I tested the same video through both file opening (set up as a network drive) and URL (AWS) connections. Since AWS provides stable speeds, I concluded there is no issue there. The video files are 8K. The bitrate is between 80-90 Mbps. The conditions for decoding and implementing 8K are the same. Also, when I mirrored the video, there was significant lag. Both AFP and URL use the same wireless conditions. I assume the conditions for implementing 8K are the same. When mirroring, the AFP connection had no lag at all. Could it be that VisionOS's URL (Internet connection) is causing a high system load? I noticed that an app called AmazeVR allows videos to be downloaded before playing. Could this be because of the URL issue? If anyone knows, please respond.
Posted
by iron5bba.
Last updated
.
Post marked as solved
3 Replies
101 Views
Hello i have build my own dialogue a normal hstack vstack its working not in scrollview and I have two Problems and no idea: at fresh loading page or scroll at scroll view the dialogue is showing. by the second tap not :( the ingoresafeplaces doesn't work. do you have an solution? Greeting Fabian
Posted Last updated
.
Post not yet marked as solved
4 Replies
948 Views
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace. Stack dump: 0. Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -c /Users/lawrey/Documents/GitHub/IPPTPLUS-IOS/IPPT/Common/Toast/Toast.swift /Users/lawrey/Documents/GitHub/IPPTPLUS-IOS/IPPT/Shop/CheckOutViewController.swift /Users/lawrey/Documents/GitHub/IPPTPLUS-IOS/IPPT/Common/UITextField/NLPaddedTextFieldView.swift ... ... /IPPT.build/Release-iphoneos/IPPT.build/Objects-normal/arm64/SettingsVC.o -index-unit-output-path /IPPT.build/Release-iphoneos/IPPT.build/Objects-normal/arm64/DGElasticPullToRefreshConstants.o -index-unit-output-path /IPPT.build/Release-iphoneos/IPPT.build/Objects-normal/arm64/DGElasticPullToRefreshView.o -index-unit-output-path /IPPT.build/Release-iphoneos/IPPT.build/Objects-normal/arm64/CountDownRouterVC.o -index-unit-output-path /IPPT.build/Release-iphoneos/IPPT.build/Objects-normal/arm64/DatePickerTableViewCell.o -index-unit-output-path /IPPT.build/Release-iphoneos/IPPT.build/Objects-normal/arm64/CircularProgress.o 1. Apple Swift version 5.8 (swiftlang-5.8.0.124.2 clang-1403.0.22.11.100) 2. Compiling with the current language version 3. While evaluating request ExecuteSILPipelineRequest(Run pipelines { PrepareOptimizationPasses, EarlyModulePasses, HighLevel,Function+EarlyLoopOpt, HighLevel,Module+StackPromote, MidLevel,Function, ClosureSpecialize, LowLevel,Function, LateLoopOpt, SIL Debug Info Generator } on SIL for IPPT) 4. While running pass #670343 SILModuleTransform "DeadFunctionAndGlobalElimination". Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): 0 swift-frontend 0x0000000109b7f300 llvm::sys::PrintStackTrace(llvm::raw_ostream&amp;, int) + 56 1 swift-frontend 0x0000000109b7e2e4 llvm::sys::RunSignalHandlers() + 112 2 swift-frontend 0x0000000109b7f910 SignalHandler(int) + 344 3 libsystem_platform.dylib 0x000000019418aa24 _sigtramp + 56 4 swift-frontend 0x00000001052bb65c (anonymous namespace)::DeadFunctionAndGlobalEliminationPass::run() + 424 5 swift-frontend 0x00000001052bb65c (anonymous namespace)::DeadFunctionAndGlobalEliminationPass::run() + 424 6 swift-frontend 0x00000001054214a0 swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&amp;) + 15312 7 swift-frontend 0x0000000105442a04 swift::SimpleRequest&lt;swift::ExecuteSILPipelineRequest, std::__1::tuple&lt;&gt; (swift::SILPipelineExecutionDescriptor), (swift::RequestFlags)1&gt;::evaluateRequest(swift::ExecuteSILPipelineRequest const&amp;, swift::Evaluator&amp;) + 56 8 swift-frontend 0x0000000105428dd4 llvm::Expected&lt;swift::ExecuteSILPipelineRequest::OutputType&gt; swift::Evaluator::getResultUncached&lt;swift::ExecuteSILPipelineRequest&gt;(swift::ExecuteSILPipelineRequest const&amp;) + 484 9 swift-frontend 0x000000010542b714 swift::runSILOptimizationPasses(swift::SILModule&amp;) + 400 10 swift-frontend 0x0000000104c09c10 swift::CompilerInstance::performSILProcessing(swift::SILModule*) + 524 11 swift-frontend 0x0000000104a6d51c performCompileStepsPostSILGen(swift::CompilerInstance&amp;, std::__1::unique_ptr&lt;swift::SILModule, std::__1::default_delete&lt;swift::SILModule&gt; &gt;, llvm::PointerUnion&lt;swift::ModuleDecl*, swift::SourceFile*&gt;, swift::PrimarySpecificPaths const&amp;, int&amp;, swift::FrontendObserver*) + 1040 12 swift-frontend 0x0000000104a70ab8 performCompile(swift::CompilerInstance&amp;, int&amp;, swift::FrontendObserver*) + 3288 13 swift-frontend 0x0000000104a6e944 swift::performFrontend(llvm::ArrayRef&lt;char const*&gt;, char const*, void*, swift::FrontendObserver*) + 4308 14 swift-frontend 0x0000000104a3368c swift::mainEntry(int, char const**) + 4116 15 dyld 0x0000000193e03f28 start + 2236 Command SwiftCompile failed with a nonzero exit code I need help understanding the root cause to resolve. Overwhelmed by the log :(
Posted
by lawrey.
Last updated
.