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

Posts under Swift tag

200 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

FileProvider Extension not working when code signed
My project has a base app which is manually signed, inside I have a FileProvider parent app and extension. When things works elegantly in Xcode debug build when I run FP App. But, when I package it, the FileProvider can't mount, fails with a generic error on parent app (Error Domain=NSFileProviderErrorDomain Code=-2001 "The application cannot be used right now." UserInfo={NSLocalizedDescription=The application cannot be used right now.} Another generic error in FileProvider demon fileproviderd(488) deny(1) file-read-data /Applications/XYZ.app/Contents/Resources/FileFP.app How to solve this?
2
0
1.4k
Nov ’23
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
Sep ’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
485
Aug ’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
Oct ’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
794
Jan ’24
CloudKit Stopped Syncing after adding new Entities
Can someone please shed some light? I have an app that uses Core Data and CloudKit, up until the last version, I was able to sync data between devices but now after I added two new Entities for some reason it stopped syncing between devices. Here is how I did the change: Created a new Core Data container. Added the new Entities and their Attributes Tested the new Entities locally to be able to send the new schema to CloudKit. Went to CloudKit and made sure that the new Entities and Attributes were reflected on the Developent database. Deploy Schema Cahnges. Went to the Production database to make sure the new schema was deployed; and it was, both databases look the same. Testing: Tested in the simulator and with a real device and everything syncs, even the new Entities. If I download the app from the App Store on two different devices they do NOT sync. Based on the procedure I'm describing above, is there any important step I may have missed when doing the migration? I'm not sure if this is related to the syncing issue but after testing a few times, I no longer can turn the iCloud on, I get the following message when I try to turn iCloud Sync On. CoreData: error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate resetAfterError:andKeepContainer:]: <NSCloudKitMirroringDelegate: 0x282c488c0> - resetting internal state after error: Error Domain=NSCocoaErrorDomain Code=134410 "CloudKit setup failed because there is another instance of this persistent store actively syncing with CloudKit in this process." UserInfo={NSURL=file:///var/mobile/Containers/Data/Application/73F19BC7-4538-4098-85C7-484B36192CF3/Library/Application%20Support/CoreDataContainer.sqlite, NSLocalizedFailureReason=CloudKit setup failed because there is another instance of this persistent store actively syncing with CloudKit in this process., NSUnderlyingException=Illegal attempt to register a second handler for activity identifier com.apple.coredata.cloudkit.activity.setup.8D4C04F6-8040-445A-9447-E5646484521} Any idea of what could be wrong and preventing the devices from syncing? Any idea or suggestion is welcome. Thanks
3
0
1.8k
2w
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
745
Sep ’23
SwiftUI animation glitch with search bar and Scroll view (iOS 16.4 / SwiftUI 4)
Animation is glitching when I tap on search bar Below is the code struct CustomTabBar: View { @State var searchText = "" var data = [1,2,3,4,5,6,7,8,9,10] var body: some View { NavigationStack { ScrollView(.vertical) { ForEach(data, id: \.self) { d in box } } .navigationTitle("Search") .searchable(text: $searchText) } } var box: some View { Rectangle() .frame(width: 75, height: 50) .cornerRadius(10) } }
6
0
992
Dec ’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
427
Aug ’23
WeatherKit error on iOS 17 - macOS 14
Hi I upgraded my Mac to test the new os and iOS 17. But I have problems with the weather kit on the app. WeatherKit enabled as app service and capability there was no issue with the iOS 16. What could be the problem? import Foundation import WeatherKit class WeatherKitManager: ObservableObject { @Published var weather: Weather? @Published var isFetchingWeather = false func getWeather(latitude: Double, longitude: Double) async { do { let receivedWeather = try await WeatherService.shared.weather(for: .init(latitude: latitude, longitude: longitude)) DispatchQueue.main.async { self.weather = receivedWeather } } catch { fatalError("\(error)") } } var symbol: String { weather?.currentWeather.symbolName ?? "xmark.app" } var temp: String { if let temp = weather?.currentWeather.temperature.converted(to: .celsius) { let formattedTemp = String(format: "%.1f", temp.value) return "\(formattedTemp)°C" } else { return "Yükleniyor..." } } } Errors here Ceyehat/WeatherKitManager.swift:22: Fatal error: Error Domain=WeatherDaemon.WDSJWTAuthenticatorServiceListener.Errors Code=2 "(null)" Failed to generate jwt token for: com.apple.weatherkit.authservice with error: Error Domain=WeatherDaemon.WDSJWTAuthenticatorServiceListener.Errors Code=2 "(null)" Encountered an error when fetching weather data subset; location=<+37.78583400,-122.40641700> +/- 0.00m (speed -1.00 mps / course -1.00) @ 06/06/2023, 5:32:55 PM GMT+03:00, error=WeatherDaemon.WDSJWTAuthenticatorServiceListener.Errors 2 Error Domain=WeatherDaemon.WDSJWTAuthenticatorServiceListener.Errors Code=2 "(null)"
23
7
4.5k
Oct ’23
Range string return incorrect with regularExpression option when we run in iOS 17 developer beta.
Hi, I'm an iOS developer who found an issue with the regularExpression option in the range method of the string. The return value differs between iOS 17 beta 1 and iOS 16, even when using the same regex pattern and input. Build with XCode14.2 // Regex pattern to check thousand amount pattern but comma is optional. // 10000 => Correct // 1000,0 => Incorrect let regex = "^[+-]?[0-9]{1,3}(?:,?[0-9]{3})*$" let rangeOf10000 = "10000".range(of: regex, options: .regularExpression) let rangeOf100000 = "100000".range(of: regex, options: .regularExpression) // in iOS 17.0 developer beta // rangeOf10000 = nil // rangeOf100000 = got an object normally. // in iOS 16.2 // rangeOf10000 = got an object normally. // rangeOf100000 = got an object normally. I don't know if the defect in the range method or my missing something in the regex pattern such a long time, but I wonder why rangeOf10000 is nil in iOS 17 beta 1.
3
0
811
Sep ’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
Oct ’23
Cursor Disappearing with Multiple NSTextViews
I have a Mac app, Notenik, written with AppKit, that dynamically generates an Edit view that is used to edit multiple fields for a Note. Sometimes, depending on a user's request, multiple NSTextViews end up appearing within the same parent view (a tab, if that matters). Lately I and some of my users have noticed that, when moving from one NSTextView to another (either by tabbing or by clicking), the cursor initially fails to appear. Once the user starts editing within the NSTextView, the cursor appears and acts normally. And this doesn't occur when moving from an ordinary text field to an NSTextView -- only when moving from one NSTextView to another. But it is troubling and confusing to users that the cursor initially disappears. I'm not sure exactly when this started happening, but it has not been happening for very long. Although I make frequent updates to the app, this section of code has had no recent changes, so I am at a loss to explain this behavior, or to correct it. Any help would be appreciated.
1
0
843
Aug ’23
Using SettingsLink from MenuBarExtra does not activate the app
I have a Utility app that does not have a Dock icon and runs in the menu bar. On macOS Sonoma (14 DB 1) you cannot use anymore the workaround that we used on previous versions of the macOS, as you get a warning that you should use SettingsLink. NSApp.sendAction(Selector(("showSettingsWindow:")), to: nil, from: nil) But the issue is, that before I usually were calling as well NSApp.activate(ignoringOtherApps: true) to activate the app. As clicking on the MenuBar app icon does not do that. The SettingsLink only opens the Settings Scene, but does not actually activates the app. I could not find a workaround how to do so. As I cannot inject my code in SettingsLink call. Any ideas how I can activate my app when SettingsLink is called?
1
2
1.2k
Jul ’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
Sep ’23
Apple demo code lacking view models
All demo code from Apple that I know lacks view models. Every time model data is directly injected into the view and even modified from the view via the new @Bindable macro. Is Apple not using ViewModels and therefore MVVM at all? I understand it might not really be required for the small demos, but it would still be helpful to understand, e. g. how the new @Model, @Observable, @Binding fit into the MVVM model.
4
0
1.6k
Oct ’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
Oct ’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
Oct ’23