Discuss Swift.

Swift Documentation

Post

Replies

Boosts

Views

Activity

Could not find bundle inside /Library/Developer/CommandLineTools under scntool.
I am using Xcode 14.3 and when Issue that says "Could not find bundle inside /Library/Developer/CommandLineTools under scntool". I searched this up and tried reinstalling CommandLineTools, reinstalling xcode, and reseting xcode. Here are screenshots of the issue: https://docs.google.com/document/d/1H6HsoZoJhISMo-5cXG-kN0hat6jftcujL1iYK2TRkeA/edit And here is the code: https://github.com/EnderRobber101/Xcode Is there a solution? Please inform me of the solution. Thank you for reading.
3
2
1.6k
Apr ’23
SecCopyErrorMessageString leaks memory
SecCopyErrorMessageString suggests that the return value should be called with CFRelease to release/free the object. Though upon attempting to do so, XCode says "CFRelease is unavailable: Core Foundation objects are automatically memory managed". I have verified with Instruments in XCode that the follow code increases in memory usage without bound, from ~3MB to 20MB+ over 100000 iterations. public func simpleLeak(){ var secReq: SecRequirement? let err = SecRequirementCreateWithString("blah" as CFString, SecCSFlags(rawValue: 0), &secReq) guard err == errSecSuccess else { var errorString = SecCopyErrorMessageString(err, nil) print(errorString) return } } What's the proper usage of SecCopyErrorMessageString that doesn't leak memory in Swift?
2
0
482
Apr ’23
Undefined Symbols in Linking iOS App
Hi! Xcode 14.3 on MacOS 13.3.1 I'm developing in iOS app targeting iOS 14.0 and higher. I've included 4 cocoa pods in my project and my code has compiled and run just fine. When I started to try to build an archive to submit to the app store, things started falling apart. Now nothing compiles for simulators and test devices and I end up with linking errors with undefined symbols. I've tried clean builds, pod updating, pod installing, explicitly importing the modules in my swift code. I'm ready to pull my hair out. Undefined symbols for architecture arm64: "OBJC_CLASS$_SFGeometryUtils", referenced from: objc-class-ref in MGRS.o ld: symbol(s) not found for architecture arm64 Any suggestions? Randomly I can get past this road block and then I run into: cannot find type 'TIFFImage' in scope var tiffImage: TIFFImage! Then randomly back to unresolved symbols by linker. Thanks, Bobby
6
0
12k
May ’23
GoogleSignIn swift package breaks my watchOS app preview
I need to install the GoogleSignIn for my iOS application, and I did so. The issue is that the watchOS app inside the project stops working because of build failures that are caused by the GoogleSignIn package. I cannot figure how to fix it, because inside the project settings, that package appears in the list of Frameworks for the iOS target, and is not present into the list of Frameworks for the watchOS target, as you can see in the first image below.
2
1
791
May ’23
How to compress an AVAudioPCMBuffer to m4a file format without writing to disk?
Hi, I'd like to upload audio samples to the OpenAI Whisper API or others that take m4a, mp3, and wav data. I capture from the microphone and perform some basic signal processing to try to filter out non-voice samples and am left with AVAudioPCMBuffer. It seems there are two approaches: Use AVAudioConverter to create AVAudioCompressedBuffer in MPEG-4 audio format. I've gotten this working (although I can't verify that the compressed data is valid because I'm unable to export a file with proper MPEG-4 headers). Use AVAssetWriter, but this writes to disk, which strikes me as inefficient. Neither of these readily produces a memory buffer with a .m4a file inside. Am I missing some obvious way to do this? How do people upload compressed audio data to remote endpoints? I've also explored just trying to create my own MPEG-4 compliant header but I was unable to produce a valid file. Thanks, -- B.
3
0
744
May ’23
Convert AWS amplify List to Array
I am using aws amplify and it returns all of its results into models and their type is something like List. But I would like them in standard swift arrays so I can use all the functionality like .first and such. How can this be done easily? My error: Cannot convert value of type 'List?' to expected argument type '[ResourceSubCategory]' Thank you!
2
0
426
May ’23
Cycle inside my app on XCode 15 beta
I cannot run my app, I get this error. I installed xcode 15 beta on my mac m2 pro, also I have macOS Sonoma (v14.0) installed. In previous code versions the code was able to run. Cycle inside Appname; building could produce unreliable results. Cycle details: → Target 'Appname': ExtractAppIntentsMetadata ○ Target 'Appname': CodeSign /Users/fon/Library/Developer/Xcode/DerivedData/Appname-aepljzymlxbnxmekkzdewisujhhh/Build/Products/Debug-iphoneos/Appname.app/Frameworks/APGconnect.framework ○ Target 'Appname' has copy command from '/Users/fon/Library/Developer/Xcode/DerivedData/Appname-aepljzymlxbnxmekkzdewisujhhh/SourcePackages/artifacts/apgconnect-swiftpackagemanager/APGconnect/APGconnect.xcframework/ios-arm64/APGconnect.framework' to '/Users/fon/Library/Developer/Xcode/DerivedData/Appname-aepljzymlxbnxmekkzdewisujhhh/Build/Products/Debug-iphoneos/Appname.app/Frameworks/APGconnect.framework' ○ That command depends on command in Target 'Appname': script phase “Firebase Crashlytics” ○ Target 'Appname' has a command with output '/Users/fon/Library/Developer/Xcode/DerivedData/Appname-aepljzymlxbnxmekkzdewisujhhh/Build/Products/Debug-iphoneos/Appname.app.dSYM' ○ Target 'Appname' has process command with output '/Users/fon/Library/Developer/Xcode/DerivedData/Appname-aepljzymlxbnxmekkzdewisujhhh/Build/Products/Debug-iphoneos/Appname.app/Info.plist' ○ Target 'Appname' has copy command from '/Users/fon/Library/Developer/Xcode/DerivedData/Appname-aepljzymlxbnxmekkzdewisujhhh/SourcePackages/artifacts/apgconnect-swiftpackagemanager/APGconnect/APGconnect.xcframework/ios-arm64/APGconnect.framework' to '/Users/fon/Library/Developer/Xcode/DerivedData/Appname-aepljzymlxbnxmekkzdewisujhhh/Build/Products/Debug-iphoneos/Appname.app/Frameworks/APGconnect.framework' Raw dependency cycle trace: target: -> node: -> command: -> node: /Users/fon/Library/Developer/Xcode/DerivedData/Appname-aepljzymlxbnxmekkzdewisujhhh/Build/Intermediates.noindex/Appname.build/Debug-iphoneos/Appname.build/Objects-normal-ubsan/arm64/ExtractedAppShortcutsMetadata.stringsdata -> command: P0:target-Appname-e523191a5dddb74851b7e061f613cdd207daf3e2cc00aeba593ba12e8843cae3-:Debug:ExtractAppIntentsMetadata -> node: -> command: P0:::Gate target-Appname-e523191a5dddb74851b7e061f613cdd207daf3e2cc00aeba593ba12e8843cae3--package-copy-files-phase -> node: <CodeSign /Users/fon/Library/Developer/Xcode/DerivedData/Appname-aepljzymlxbnxmekkzdewisujhhh/Build/Products/Debug-iphoneos/Appname.app/Frameworks/APGconnect.framework> -> command: P0:target-Appname-e523191a5dddb74851b7e061f613cdd207daf3e2cc00aeba593ba12e8843cae3-:Debug:CodeSign /Users/fon/Library/Developer/Xcode/DerivedData/Appname-aepljzymlxbnxmekkzdewisujhhh/Build/Products/Debug-iphoneos/Appname.app/Frameworks/APGconnect.framework -> node: <Copy /Users/fon/Library/Developer/Xcode/DerivedData/Appname-aepljzymlxbnxmekkzdewisujhhh/Build/Products/Debug-iphoneos/Appname.app/Frameworks/APGconnect.framework> -> CYCLE POINT -> command: P0:target-Appname-e523191a5dddb74851b7e061f613cdd207daf3e2cc00aeba593ba12e8843cae3-:Debug:Copy /Users/fon/Library/Developer/Xcode/DerivedData/Appname-aepljzymlxbnxmekkzdewisujhhh/Build/Products/Debug-iphoneos/Appname.app/Frameworks/APGconnect.framework /Users/fon/Library/Developer/Xcode/DerivedData/Appname-aepljzymlxbnxmekkzdewisujhhh/SourcePackages/artifacts/apgconnect-swiftpackagemanager/APGconnect/APGconnect.xcframework/ios-arm64/APGconnect.framework -> node: -> command: P0:::Gate target-Appname-e523191a5dddb74851b7e061f613cdd207daf3e2cc00aeba593ba12e8843cae3--fused-phase8--cp--copy-pods-resources -> node: /Users/fon/Library/Developer/Xcode/DerivedData/Appname-aepljzymlxbnxmekkzdewisujhhh/Build/Intermediates.noindex/Appname.build/Debug-iphoneos/Appname.build/InputFileList-8F69F04ECE39CEA4D548803F-Pods-App-Appname-resources-Debug-input-files-6b988fea851b169d138afd42359e554e-resolved.xcfilelist -> command: P2:target-Appname-e523191a5dddb74851b7e061f613cdd207daf3e2cc00aeba593ba12e8843cae3-:Debug:WriteAuxiliaryFile /Users/fon/Library/Developer/Xcode/DerivedData/Appname-aepljzymlxbnxmekkzdewisujhhh/Build/Intermediates.noindex/Appname.build/Debug-iphoneos/Appname.build/InputFileList-8F69F04ECE39CEA4D548803F-Pods-App-Appname-resources-Debug-input-files-6b988fea851b169d138afd42359e554e-resolved.xcfilelist -> node: -> command: P0:::Gate target-Appname-e523191a5dddb74851b7e061f613cdd207daf3e2cc00aeba593ba12e8843cae3--fused-phase7--cp--embed-pods-frameworks -> node: /Users/fon/Library/Developer/Xcode/DerivedData/Appname-aepljzymlxbnxmekkzdewisujhhh/Build/Intermediates.noindex/Appname.build/Debug-iphoneos/Appname.build/InputFileList-9C4DC43DDD1B70E883929F7A-Pods-App-Appname-frameworks-Debug-input-files-67ca94915dc637813d7d2b89d288f680-resolved.xcfilelist -> command: P2:target-Appname-e523191a5dddb74851b7e061f613cdd207daf3e2cc00aeba593ba12e8843cae3-:Debug:WriteAuxiliaryFile /Users/fon/Library/Developer/Xcode/DerivedData/Appname-aepljzymlxbnxmekkzdewisujhhh/Build/Intermediates.noindex/Appname.build/Debug-iphoneos/Appname.build/InputFileList-9C4DC43DDD1B70E883929F7A-Pods-App-Appname-frameworks-Debug-input-files-67ca94915dc637813d7d2b89d288f680-resolved.xcfilelist -> node: -> command: P0:::Gate target-Appname-e523191a5dddb74851b7e061f613cdd207daf3e2cc00aeba593ba12e8843cae3--fused-phase6-firebase-crashlytics -> node: -> command: P2:target-Appname-e523191a5dddb74851b7e061f613cdd207daf3e2cc00aeba593ba12e8843cae3-:Debug:PhaseScriptExecution Firebase Crashlytics /Users/fon/Library/Developer/Xcode/DerivedData/Appname-aepljzymlxbnxmekkzdewisujhhh/Build/Intermediates.noindex/Appname.build/Debug-iphoneos/Appname.build/Script-B66C911C2756492F00413DA0.sh -> node: /Users/fon/Library/Developer/Xcode/DerivedData/Appname-aepljzymlxbnxmekkzdewisujhhh/Build/Products/Debug-iphoneos/Appname.app.dSYM/Contents/Resources/DWARF/Appname/ -> directoryTreeSignature: � -> directoryContents: /Users/fon/Library/Developer/Xcode/DerivedData/Appname-aepljzymlxbnxmekkzdewisujhhh/Build/Products/Debug-iphoneos/Appname.app.dSYM/Contents/Resources/DWARF/Appname -> node: /Users/fon/Library/Developer/Xcode/DerivedData/Appname-aepljzymlxbnxmekkzdewisujhhh/Build/Products/Debug-iphoneos/Appname.app.dSYM/Contents/Resources/DWARF/Appname ->
7
8
10k
Jun ’23
Xcode 15 Local Package Crash
Hey all! Updating older code & libraries to some of the new Swift 5.9 / iOS 17 changes. Running into a weird issue with Xcode 15. Whenever I try to add a local Swift package, Xcode immediately crashes with the following trace. Anyone else seeing something similar or have a workaround? ------------------------------------- Translated Report (Full Report Below) ------------------------------------- Process: Xcode [24187] Path: /Applications/Xcode-beta.app/Contents/MacOS/Xcode Identifier: com.apple.dt.Xcode Version: 15.0 (22181.17) Build Info: IDEFrameworks-22181017000000000~2 (15A5160n) Code Type: ARM-64 (Native) Parent Process: launchd [1] User ID: 501 Date/Time: 2023-06-12 12:45:18.5995 -0700 OS Version: macOS 13.4 (22F66) Report Version: 12 Anonymous UUID: 69A2C560-2753-9460-D969-DC28F9918E8D Sleep/Wake UUID: ADBB3D7D-6D24-4E07-BAA2-F7C0952990C0 Time Awake Since Boot: 130000 seconds Time Since Wake: 4284 seconds System Integrity Protection: enabled Crashed Thread: 0 Dispatch queue: com.apple.main-thread Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Application Specific Information: abort() called Application Specific Signatures: IDESwiftPackageDataSource.PreflightablePackage.swift:127@@asSourcePackageReference(with:) Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 libsystem_kernel.dylib 0x19b194724 __pthread_kill + 8 1 libsystem_pthread.dylib 0x19b1cbc28 pthread_kill + 288 2 libsystem_c.dylib 0x19b0d9ae8 abort + 180 3 IDEKit 0x1079f9bcc +[IDEAssertionHandler _handleAssertionWithLogString:assertionSignature:assertionReason:extraBacktrace:] + 972 4 IDEKit 0x1079fa4ac -[IDEAssertionHandler handleFailureInFunction:fileName:lineNumber:assertionSignature:messageFormat:arguments:] + 772 5 DVTFoundation 0x103fbf878 _DVTAssertionHandler + 472 6 DVTFoundation 0x103fbfce4 _DVTAssertFromSwift + 260 7 DVTFoundation 0x10408a678 _DVTAssert(_:file:line:function:varargs:) + 276 8 DVTFoundation 0x104089748 DVTAssert(_:_:file:line:function:_:) + 444 9 IDESwiftPackageUI 0x134d41af4 AvailablePackageOrigins.Origin.asSourcePackageReference(with:) + 568 10 IDESwiftPackageUI 0x134c44894 IDESwiftPackageChooseOptionsViewController.addPackage(_:) + 1020 11 IDESwiftPackageUI 0x134c44f48 @objc IDESwiftPackageChooseOptionsViewController.cancel(_:) + 80 12 AppKit 0x19e6718a8 -[NSApplication(NSResponder) sendAction:to:from:] + 440 13 DVTKit 0x102eaa234 __37-[DVTApplication sendAction:to:from:]_block_invoke + 300 14 DVTFoundation 0x103fc1594 DVTInvokeWithFailureHint + 76 15 DVTKit 0x102eaa00c -[DVTApplication sendAction:to:from:] + 404 16 AppKit 0x19e6716c0 -[NSControl sendAction:to:] + 72 17 AppKit 0x19e671604 __26-[NSCell _sendActionFrom:]_block_invoke + 100 18 AppKit 0x19e67152c -[NSCell _sendActionFrom:] + 204 19 AppKit 0x19e671450 -[NSButtonCell _sendActionFrom:] + 88 20 AppKit 0x19e66ea54 NSControlTrackMouse + 1480 21 AppKit 0x19e66e460 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 144 22 AppKit 0x19e66e318 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 488 23 AppKit 0x19e66d7e4 -[NSControl mouseDown:] + 448 24 AppKit 0x19e66c2cc -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 3476 25 AppKit 0x19e5f6f08 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 364 26 AppKit 0x19e5f6bc8 -[NSWindow(NSEventRouting) sendEvent:] + 284 27 AppKit 0x19e5f5f0c -[NSApplication(NSEvent) sendEvent:] + 1556 28 IDEKit 0x107a62bd0 -[IDEApplication sendEvent:] + 596 29 AppKit 0x19e845fc4 -[NSApplication _handleEvent:] + 60 30 AppKit 0x19e4bd368 -[NSApplication run] + 500 31 DVTKit 0x102ea8fb4 -[DVTApplication run] + 60 32 AppKit 0x19e494794 NSApplicationMain + 880 33 dyld 0x19ae73f28 start + 2236
3
2
1.7k
Jun ’23
Xcode 15 beta 1 failed to preview SwiftUI view in watchOS target
Hello! I can't preview the SwiftUI views of watchOS target in Xcode 15 beta 1, when the containing iOS app has a SPM dependency. Reproducing steps: Create a new watchOS app project (with a companion iOS app) in Xcode 15. Both iOS and watchOS ContentView can be previewed at this step. Add a Swift package to the iOS target (the package should be an iOS-specific package, not a watchOS one, for example, https://github.com/siteline/SwiftUI-Introspect) After you add the static library to iOS target, the watchOS preview no longer work anymore. If you check the error message, you can find the Xcode preview attempt to build the iOS package against watchOS SDK.
8
6
3.1k
Jun ’23
App hangs while opening from background
Hi, My app hangs for about a second when I open the app when it's been in background phase. It doesn't hang every time, but it hangs randomly (like once in 10 times) when I open the app again. I am not able to reproduce what causes this hang. Hang Detection provides hang logs (spindump) when hang occurs. It has something to do with MusicKit as logs mention it but I cannot understand what it is. Please help me understand these logs. I am running iOS 17 beta 1 with MusicKit and ApplicationMusicPlayer. Heaviest stack for the main thread of the target process: 69 start + 2104 (dyld + 87288) [0x1b719b4f8] 69 ??? (Timed + 32864) [0x104ae8060] 69 ??? (SwiftUI + 980040) [0x19840a448] 69 ??? (SwiftUI + 1071088) [0x1984207f0] 69 ??? (SwiftUI + 1667804) [0x1984b22dc] 69 UIApplicationMain + 340 (UIKitCore + 3740336) [0x196c602b0] 69 -[UIApplication _run] + 888 (UIKitCore + 3741260) [0x196c6064c] 69 GSEventRunModal + 164 (GraphicsServices + 4644) [0x1d6199224] 69 CFRunLoopRunSpecific + 600 (CoreFoundation + 527792) [0x1947fedb0] 68 __CFRunLoopRun + 1996 (CoreFoundation + 509348) [0x1947fa5a4] 68 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16 (CoreFoundation + 626340) [0x194816ea4] 68 _dispatch_main_queue_callback_4CF + 44 (libdispatch.dylib + 75296) [0x19c404620] 67 _dispatch_main_queue_drain + 744 (libdispatch.dylib + 76056) [0x19c404918] 67 swift_job_runImpl(swift::Job*, swift::ExecutorRef) + 72 (libswift_Concurrency.dylib + 274348) [0x19f58cfac] 67 swift::runJobInEstablishedExecutorContext(swift::Job*) + 416 (libswift_Concurrency.dylib + 269688) [0x19f58bd78] 66 ??? (MusicKit + 4857464) [0x208aabe78] 66 ??? (MusicKit + 4856108) [0x208aab92c] 66 -[MusicKit_SoftLinking_MPMusicPlayerController nowPlayingItem] + 24 (MusicKit + 157364) [0x2086306b4] 66 -[MPMusicPlayerController nowPlayingItem] + 24 (MediaPlayer + 1358540) [0x1a681bacc] 66 -[MPMusicPlayerController _nowPlaying] + 372 (MediaPlayer + 1329552) [0x1a6814990] 66 -[MPMusicPlayerController onServer:] + 52 (MediaPlayer + 1333428) [0x1a68158b4] 63 -[MPMusicPlayerApplicationController _establishConnectionIfNeeded] + 1768 (MediaPlayer + 1553848) [0x1a684b5b8] 63 _NSXPCDistantObjectSimpleMessageSend1 + 60 (Foundation + 208348) [0x1937daddc] 63 -[NSXPCConnection _sendSelector:withProxy:arg1:] + 116 (Foundation + 208548) [0x1937daea4] 62 -[NSXPCConnection _sendInvocation:orArguments:count:methodSignature:selector:withProxy:] + 2160 (Foundation + 214664) [0x1937dc688] 62 __NSXPCCONNECTION_IS_WAITING_FOR_A_SYNCHRONOUS_REPLY__ + 16 (Foundation + 652944) [0x193847690] 62 xpc_connection_send_message_with_reply_sync + 264 (libxpc.dylib + 67488) [0x1fc00d7a0] 62 dispatch_mach_send_with_result_and_wait_for_reply + 60 (libdispatch.dylib + 127760) [0x19c411310] 62 _dispatch_mach_send_and_wait_for_reply + 540 (libdispatch.dylib + 126832) [0x19c410f70] 62 mach_msg + 24 (libsystem_kernel.dylib + 4692) [0x1da082254] 62 mach_msg_overwrite + 436 (libsystem_kernel.dylib + 83544) [0x1da095658] 62 mach_msg2_trap + 8 (libsystem_kernel.dylib + 3332) [0x1da081d04] *62 ??? (<31E57057-A9A0-3BE5-90CB-5C08E9683B34> + 217132) [0xfffffff007e0102c] Thank you. CC @JoeKun
2
0
1k
Jun ’23
XCode 14.3.x and XCode 15 Beta Hangs On Compiling
We have a 7-year old codebase that uses a mix of frameworks including Rx and Firebase through Cocoapods. The compilation works fine up to XCode 14.2 but for some unknown reason the compilation just stuck / hang on XCode 14.3.x and XCode 15. There are several warnings in the codebase but the compiler does not output any error. Which is why we don't know what the exact issue(s) is/are. What's the change in XCode 14.3.x that could be causing this issue? If anyone has an idea on possible fix, willing to try it out.
2
0
1.3k
Jun ’23
Conversion from Base64 Public Key Data to SecKey and convert back from SecKey to Public Key Data are not the same. How can i resolve this?
I am trying to convert publicKeyFromDongleData to SecKey, then perform some tasks. After that, I want to convert SecKey to b64 String. I am assuming that publicKeyFromDongleData and b64 string will be the same. But, surprisingly, they are not the same. How can i resolve the issue? Is there any way around? My goal is to retain the public key before and after converting the same. let publicKeyFromDongleData = Data.init(base64Encoded: publicKeyFromDongle) guard let publicKeySecKey = SecKeyCreateWithData(publicKeyFromDongleData! as CFData, keyDict as CFDictionary, &amp;error) else { print("Failed to create public key:", error!.takeRetainedValue()) return nil } //var error:Unmanaged&lt;CFError&gt;? if let cfdata = SecKeyCopyExternalRepresentation(publicKeySecKey, &amp;error) { let data:Data = cfdata as Data let b64Key = data.base64EncodedString() print("after : \n") print(b64Key) }
3
0
922
Jun ’23
EXC_BAD_ACCESS when initializing a Model class with a custom class property
I have multiple classes that are contained within one another. Initializing class A(no other classes as properties) has no issues, but the moment that it tries to initialize class B, which takes class A as a property, an EXC_BAD_ACCESS error is thrown while attempting to set the first property value. Class A: import Foundation import SwiftData @Model public class Service: Identifiable, Equatable, Codable { @Attribute(.unique) public var id: UUID public var title: String public var price: Int public var stripePriceId: String public var servicePhoto: String public var serviceLength: Int public var category: [String] init(id: UUID, title: String, price: Int, stripePriceId: String, servicePhoto: String, serviceLength: Int, category: Array<String>) { self.id = id self.title = title self.price = price self.stripePriceId = stripePriceId self.servicePhoto = servicePhoto self.serviceLength = serviceLength self.category = category } } Class B: import Foundation import SwiftData import SwiftUI @Model public class ServiceOrder: Identifiable, Codable, Equatable { public var id: UUID @Relationship(.noAction) public var service: Service public var quantity: Int = 1 public var subtotal: Int { return service.price * quantity } public init(id: UUID = UUID(), service: Service, quantity: Int) { self.id = id self.service = service self.quantity = quantity } public func getValue<T>(for key: KeyPath<ServiceOrder, T>) -> T { return self[keyPath: key] } // This is where the error is being thrown. The custom setValue and getValue methods were added to every class to mitigate an 'Ambiguous use of __Value()' error, but that's for another thread public func setValue<T>(for key: ReferenceWritableKeyPath<ServiceOrder, T>, to newValue: T) { self[keyPath: key] = newValue } // This was added to see if following the Builder pattern might mitigate the issue by ensuring that all properties were initialized before being passed in, it did not change anything class ServiceOrderBuilder { private var id: UUID? private var service: Service? private var quantity: Int? init() { } init(id: UUID = UUID(), service: Service, quantity: Int = 1) { self.id = id self.service = service self.quantity = quantity } func setId(id: UUID = UUID()) -> ServiceOrderBuilder { self.id = id return self } func setService(service: Service) -> ServiceOrderBuilder { self.service = service return self } func setQuantity(quantity: Int = 1) -> ServiceOrderBuilder { self.quantity = quantity return self } func build() -> ServiceOrder? { guard let id = id, let service = service, let quantity = quantity else { return nil } return ServiceOrder(id: id, service: service, quantity: quantity) } } Here's where I'm doing the initialization of everything. I'm trying to just create sample data. import SwiftData import Foundation @MainActor public let previewContainer: ModelContainer = { do { var container = try ModelContainer( for: [Event.self, Braider.self, Queue.self, QueueSlot.self, Cart.self, ServiceOrder.self], ModelConfiguration(inMemory: true) ) var context = container.mainContext var serviceSampleData: [Service] = [ Service( id: UUID(), title: "Event Braid", price: 20, stripePriceId: "", servicePhoto: "", serviceLength: 15, category: []), ..., ] serviceSampleData.forEach { service in context.insert(service) } // This is where the error is thrown, no issue initializing the above Services var serviceOrder1: ServiceOrder = ServiceOrder( service: serviceSampleData[0], quantity: 1) context.insert(serviceOrder1) // ...continue building higher classes/Models that utilize the lower ones return container } catch { print("Failed to create container") do { return try ModelContainer( for: [Event.self], ModelConfiguration(inMemory: true) ) } catch { fatalError() }} }() I assumed that this was a SwiftData issue, as I mentioned in response to this post but looking back this issue has been happening for 7+ years, so now I'm assuming I'm doing something incorrect.
1
0
965
Jun ’23
macOS get SSID changes?
I've had a little personal utility running for several versions of macOS that uses let client = CWWiFiClient.shared() if let ssid_name = client.interface()?.ssid() to get the current SSID name and prints it (along with a bunch of other active network details. With the most recent Sonoma Beta 2 and Xcode beta 2, this always returns nil. Doing the same thing in a playground works as expected. Is this a purposeful change or a bug I should file?
29
2
5.2k
Jun ’23
Unable to Verify App: An internet connection is required to verify the trust of the developer' ... This app will not be available until verified.
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?
37
11
30k
Jun ’23
iPadOS: [API] Failed to create 0x88 image slot (alpha=1 wide=0) (client=0xfbe80e61) [0x5 (os/kern) failure]
I got the error "[API] Failed to create 0x88 image slot (alpha=1 wide=0) (client=0xfbe80e61) [0x5 (os/kern) failure]" when using NavigationStack of SwiftUI for navigation. It only happen in iPadOS (16.4) but not iOS in iPhone. Below is the view I am using. struct NewView: View { var body: some View { NavigationStack { VStack { NavigationLink("Show Detail View") { DetailView() } } .navigationTitle("Navigation") } } } struct DetailView: View { var body: some View { Text("This is the detail view") } } Anyone know the reason?
3
1
2.2k
Jun ’23