Hello!
We're working on a large app with over 400 modules in both Swift and Objective-C, totaling more than 3 million lines of code. Since the release of Xcode 15 and 16 this summer, we’ve been experiencing issues with LLDB that have made debugging practically impossible.
Here are some of the problems we’re facing:
The first breakpoint takes a very long time to hit.
When using 'po self', we encounter the following error:
error: type for self cannot be reconstructed: type for typename "$s5MyModule10PlayerViewCD" was not found (cached)
error: Couldn't realize Swift AST type of self. Hint: using `v` to directly inspect variables and fields may still work.
We get numerous log messages like this:
Debugging will be degraded due to missing types. Rebuilding the project will regenerate the needed module files.warning: (arm64) /Users/egormerkushev/Library/Developer/Xcode/DerivedData/App-enhtbwiyebmjsffoqkqhhpshsfia/Build/Products/Debug-iphoneos/MyModule.framework/MyModule(UploadConfiguration.o) 0x000000000000079d: unable to locate module needed for external types: /Users/builder/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/169D1N0MIKBUI/Security-3BRN4UPIIGHME.pcm
error: '/Users/builder/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/169D1N0MIKBUI/Security-3BRN4UPIIGHME.pcm' does not exist
In the Derived Data folder, we find files with hash-like names, such as:
Security-3JM2E93YFDLZNYHWPPIMWNENB.d
Security-3JM2E93YFDLZNYHWPPIMWNENB.dia
Security-3JM2E93YFDLZNYHWPPIMWNENB.pcm
Security-3JM2E93YFDLZNYHWPPIMWNENB.scan
Security-3NAAT3MGN7XY96KVJW529HR41.d
Security-3NAAT3MGN7XY96KVJW529HR41.dia
Security-3NAAT3MGN7XY96KVJW529HR41.pcm
Security-3NAAT3MGN7XY96KVJW529HR41.scan
Security-3RJH8STJC01N1KKN7JCY1WK7F.d
Security-3RJH8STJC01N1KKN7JCY1WK7F.dia
Security-3RJH8STJC01N1KKN7JCY1WK7F.pcm
Security-3RJH8STJC01N1KKN7JCY1WK7F.scan
Security-3TILE9XTY0B8UV9VYL7Y0MJN.d
Security-3TILE9XTY0B8UV9VYL7Y0MJN.dia
Security-3TILE9XTY0B8UV9VYL7Y0MJN.pcm
Security-3TILE9XTY0B8UV9VYL7Y0MJN.scan
Security-3ZE8O6ZPHE4L52UZGL0PCBA59.d
Security-3ZE8O6ZPHE4L52UZGL0PCBA59.dia
...
When enabling LLDB logs with:
log enable -f /tmp/lldb.log lldb all
we end up with a 1.5GB log file containing hundreds of thousands of error messages.
Finally, the LLDB console output in Xcode ends with errors like:
error: Assertion failed: (byte_size > 0 && byte_size <= 8 && "GetMaxU64 invalid byte_size!"), function GetMaxU64, file DataExtractor.cpp, line 527
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 LLDB 0x0000000116ccfe1c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1 LLDB 0x000000011682fdcc lldb_private::lldb_assert(bool, char const*, char const*, char const*, unsigned int) + 148
2 LLDB 0x000000011682944c lldb_private::DataExtractor::GetMaxU64(unsigned long long*, unsigned long) const + 72
3 LLDB 0x00000001167335a8 lldb_private::CompilerType::GetValueAsScalar(lldb_private::DataExtractor const&, unsigned long long, unsigned long, lldb_private::Scalar&, lldb_private::ExecutionContextScope*) const + 304
4 LLDB 0x000000011666f0f4 lldb_private::Value::ResolveValue(lldb_private::ExecutionContext*, lldb_private::Module*) + 388
5 LLDB 0x0000000116671e94 lldb_private::ValueObject::ResolveValue(lldb_private::Scalar&) + 104
6 LLDB 0x0000000116674d6c lldb_private::ValueObject::GetValueAsSigned(long long, bool*) + 140
7 LLDB 0x000000011650510c lldb::SBValue::GetValueAsSigned(long long) + 160
8 lldb-rpc-server 0x00000001025ebe70 rpc_server::_ZN4lldb7SBValue16GetValueAsSignedEx::HandleRPCCall(rpc_common::Connection&, rpc_common::RPCStream&, rpc_common::RPCStream&) + 92
...
13 libsystem_pthread.dylib 0x00000001917fb2e4 _pthread_start + 136
14 libsystem_pthread.dylib 0x00000001917f60fc thread_start + 8
Please file a bug report against lldb reporting this failure log, and as many details as possibleerror: Assertion failed: (byte_size > 0 && byte_size <= 8 && "GetMaxU64 invalid byte_size!"), function GetMaxU64, file DataExtractor.cpp, line 527
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 LLDB 0x0000000116ccfe1c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1 LLDB 0x000000011682fdcc lldb_private::lldb_assert(bool, char const*, char const*, char const*, unsigned int) + 148
2 LLDB 0x000000011682944c lldb_private::DataExtractor::GetMaxU64(unsigned long long*, unsigned long) const + 72
3 LLDB 0x00000001167335a8 lldb_private::CompilerType::GetValueAsScalar(lldb_private::DataExtractor const&, unsigned long long, unsigned long, lldb_private::Scalar&, lldb_private::ExecutionContextScope*) const + 304
4 LLDB 0x000000011666f0f4 lldb_private::Value::ResolveValue(lldb_private::ExecutionContext*, lldb_private::Module*) + 388
5 LLDB 0x0000000116671e94 lldb_private::ValueObject::ResolveValue(lldb_private::Scalar&) + 104
6 LLDB 0x0000000116674c44 lldb_private::ValueObject::GetValueAsUnsigned(unsigned long long, bool*) + 140
7 LLDB 0x0000000116505224 lldb::SBValue::GetValueAsUnsigned(unsigned long long) + 160
8 lldb-rpc-server 0x00000001025ebf18 rpc_server::_ZN4lldb7SBValue18GetValueAsUnsignedEy::HandleRPCCall(rpc_common::Connection&, rpc_common::RPCStream&, rpc_common::RPCStream&) + 92
9 lldb-rpc-server 0x00000001025f62b8 rpc_common::Connection::PrivateHandleRPCPacket(rpc_common::RPCPacket&, rpc_common::RPCPacket&, bool&) + 628
10 lldb-rpc-server 0x00000001025f9e8c Packets::ProcessPackets() + 564
11 lldb-rpc-server 0x00000001025f9bf4 Packets::ReadThread() + 276
12 lldb-rpc-server 0x00000001025f9ad4 Packets::RunReadThread(void*) + 12
13 libsystem_pthread.dylib 0x00000001917fb2e4 _pthread_start + 136
14 libsystem_pthread.dylib 0x00000001917f60fc thread_start + 8
Please file a bug report against lldb reporting this failure log, and as many details as possiblePrinting description of self:
error: type for self cannot be reconstructed: type for typename "$s5MyModule10PlayerViewCD" was not found (cached)
error: Couldn't realize Swift AST type of self. Hint: using `v` to directly inspect variables and fields may still work.
In short, our debugger is completely unusable at this point, which is severely impacting our team's ability to develop effectively.
Do you have any suggestions on how we can resolve these issues? We would really appreciate your help. Thank you!
Swift
RSS for tagSwift 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
I develop React Native app with dynamically linked pods, and app runs on simulator well, while running it on connected device returns this error:
dyld[53510]: Symbol not found: __ZN5swift39swift51override_conformsToSwiftProtocolEPKNS_14TargetMetadataINS_9InProcessEEEPKNS_24TargetProtocolDescriptorIS1_EEN7__swift9__runtime4llvm9StringRefEPFPKNS_35TargetProtocolConformanceDescriptorIS1_EES4_S8_SC_E
Referenced from: <4A3492BF-0479-3124-BE58-05BAED71BB20> /private/var/containers/Bundle/Application/0D9FDF5C-BBC9-4060-972B-B2D6FD91E321/BFF.app/Frameworks/Framework1 Expected in: <0549B906-CB15-3735-AA15-FAEB5F687C8B> /private/var/containers/Bundle/Application/0D9FDF5C-BBC9-4060-972B-B2D6FD91E321/BFF.app/Frameworks/Framework2
I already tried different things:
Different versions of IPHONEOS_DEPLOYMENT_TARGET
Ensured that all dependencies using same Swift version
Different linking
Tested on different devices and iOS versions
Standard cleaning of derived data and reinstalling podfiles also included
BUILD_LIBRARY_FOR_DISTRIBUTION="YES"
ENABLE_BITCODE="NO"
I was curious as to the procedure for having an encryption key leaked and was hoping to have your opinions on how these two questions will be answered [if you were in the position].
Q1: Let's say, for instance, that you're making a social media network that stores private messages in a database network (such as Firebase) and uses basic encryption to store that data into an encrypted format (e.g., text message: "Hello Mous772!"; Firebase data: "deaErG5gao7J5qw/QI3EOA==").
But oh no! Someone got access to the encryption key used to encrypt hundreds of thousands of messages. You cannot simply delete thousands of messages because of this hacker, so how should you deal with this? This is where my question comes in. Is it possible to change the encryption key for all of the data if I am using the code system at the bottom of this question and using that code system to store encrypted data in Firebase? If so, how would you go about doing that? (Please use simple language; I'm not good with this stuff).
Q2: What, in your opinion, is the best way to prevent this in the first place? I was told that a good solution was to store two sets of the same data; when one kegs it, we shut down the original and use the backup; however, this does not sound sustainable at all. I want to know what steps can be taken to ensure this never happens.
[Please don't give me "Well... you can never *really hide these keys!" I'm well aware it's not possible to never have them leaked ever; I'm just looking for best practices only.]
This is the encryption system we are using for this hypothetical app.
// MARK: Value
// MARK: Private
private let key: Data
private let iv: Data
// MARK: - Initialzier
init?(key: String, iv: String) {
guard key.count == kCCKeySizeAES128 || key.count == kCCKeySizeAES256, let keyData = key.data(using: .utf8) else {
debugPrint("Error: Failed to set a key.")
return nil
}
guard iv.count == kCCBlockSizeAES128, let ivData = iv.data(using: .utf8) else {
debugPrint("Error: Failed to set an initial vector.")
return nil
}
self.key = keyData
self.iv = ivData
}
// MARK: - Function
// MARK: Public
func encrypt(string: String) -> Data? {
return crypt(data: string.data(using: .utf8), option: CCOperation(kCCEncrypt))
}
func decrypt(data: Data?) -> String? {
guard let decryptedData = crypt(data: data, option: CCOperation(kCCDecrypt)) else { return nil }
return String(bytes: decryptedData, encoding: .utf8)
}
func crypt(data: Data?, option: CCOperation) -> Data? {
guard let data = data else { return nil }
let cryptLength = data.count + key.count
var cryptData = Data(count: cryptLength)
var bytesLength = Int(0)
let status = cryptData.withUnsafeMutableBytes { cryptBytes in
data.withUnsafeBytes { dataBytes in
iv.withUnsafeBytes { ivBytes in
key.withUnsafeBytes { keyBytes in
CCCrypt(option, CCAlgorithm(kCCAlgorithmAES), CCOptions(kCCOptionPKCS7Padding), keyBytes.baseAddress, key.count, ivBytes.baseAddress, dataBytes.baseAddress, data.count, cryptBytes.baseAddress, cryptLength, &bytesLength)
}
}
}
}
guard Int32(status) == Int32(kCCSuccess) else {
debugPrint("Error: Failed to crypt data. Status \(status)")
return nil
}
cryptData.removeSubrange(bytesLength..<cryptData.count)
return cryptData
}
}
//let password = "UserPassword1!"
//let key128 = "1234567890123456" // 16 bytes for AES128
//let key256 = "12345678901234561234567890123456" // 32 bytes for AES256
//let iv = "abcdefghijklmnop" // 16 bytes for AES128
//let aes128 = AES(key: key128, iv: iv)
//let aes256 = AES(key: key256, iv: iv)
//let encryptedPassword128 = aes128?.encrypt(string: password)
//aes128?.decrypt(data: encryptedPassword128)
//let encryptedPassword256 = aes256?.encrypt(string: password)
//aes256?.decrypt(data: encryptedPassword256)
Is there any particular reason why ASWebAuthenticationSession doesn't have support for async/await? (example below)
do {
let callbackURL = try await webAuthSession.start()
} catch {
// handle error
}
I'm curious if this style of integration doesn't exist for architectural reasons? Or is the legacy completion handler style preserved in order to prevent existing integrations from breaking?
As the title states, this severely limits the flexibility of multi-window applications in creating a good user experience.
Even effects like the ones shown below cannot be achieved.
I am using a Key to connect my notification server with APNS in order to send out notifications to users. I have recently added notifications to a second app of mine, using the same notification server to fire off notifications for both apps. However, any notifications going to the second app return the error InvalidProviderToken, where as I get no such issues when send notifications to the first app. Everything, including the payloads, are exactly the same between the two apps, the only difference is that the device IDs are attached to different apps.
Does anyone know why/how this would happen and how I can resolve it?
Hey there,
Create Live activity in my project, after executing the creation method, back to the background, real-time activity UI is not displayed, but click Smart Island is effective,
now do not know where the problem appears?
Has anyone experienced this problem?
Thanks
Hi, is there any way to interact with the eye tracking accessibility feature in iOS and iPadOS? I want to be able to trigger an eye tracker recalibration programmatically. Also if possible, I would like to be able to retrieve gaze location data.
These are not intended to be features on an app being published to the app store but rather a custom made accessibility app.
Hi there, I'm having an app developed in the last weeks, and recently I'm testing it on iOS 18. This following piece of UI code has diff between iOS 18 and iOS version lower than 18.
I have a NavigationStack in my homeView, and the display difference is for its toolbar in one destination. I've tried both approaches in code, with header variable or ToolbarItemGroup used directly in the toolbar modifier, both would result in there being a spacer between the body VStack and toolbar, which is unexpected. Here's the code and a demo screenshot.
var body: some View {
// header
VStack(alignment: .leading) {
notificationView(
iconKey: "ErrorCircle",
contentKey: "receivedFile.notification.noNetwork.content"
)
fileListView
}
.toolbar {
// header
ToolbarItemGroup(placement: .principal) {
Button {
dismiss()
} label: {
Image(systemName: "chevron.backward")
}
.background(Color.yellow)
Spacer()
Text(LocalizedStringKey("title"))
.font(
.system(size: 17)
.weight(.semibold)
)
.background(Color.yellow)
Spacer()
Button {
print("click")
} label: {
Text("Click")
}
.background(Color.yellow)
}
}
.navigationBarBackButtonHidden()
.onAppear {
refreshAllFiles()
}
}
@ToolbarContentBuilder private var header: some ToolbarContent {
ToolbarItem(placement: .topBarLeading) {
Button {
dismiss()
} label: {
Image(systemName: "chevron.backward")
}
.background(Color.yellow)
}
ToolbarItem(placement: .principal) {
Text(LocalizedStringKey("receivedFileList.title"))
.font(
.system(size: 17)
.weight(.semibold)
)
.background(Color.yellow)
}
ToolbarItem(placement: .topBarTrailing) {
Button {
print("click for jumping")
} label: {
Text("Click for jumping")
}
.background(Color.yellow)
}
}
Hope I can get some help from the forum on the usage. If not fixable, may I know if this is a known issue that would be fixed in the next upgrades.
Hi everyone,
I need to synchronize the playback of RealityKit Timelines via SharePlay.
To do this I am trying to get the references of the timelines using "AnimationPlaybackController" and "AnimationResource". In my realitykit scene I have configured both an animation (with blender), and a timeline, the animation starts correctly when the realitykit scene starts, the timeline not.
Below the code:
struct ContentView: View {
@State private var subscriptions = [EventSubscription]()
@Environment(AppModel.self)
private var appModel
let rootEntity = Entity()
@State var testEntity: Entity?
@State var testAnimation: AnimationResource?
@State var testController: AnimationPlaybackController?
init() {
CubeComponent.registerComponent()
}
var body: some View {
RealityView { content in
content.add(rootEntity)
if let scene = try? await Entity(named: "Room", in: realityKitContentBundle) {
rootEntity.addChild(scene)
playAnimations(from: content)
}
}
.gesture(SpatialTapGesture().targetedToAnyEntity()
.onEnded({ value in
_ = value.entity.applyTapForBehaviors()
if let testEntity, let testAnimation {
testController = testEntity.playAnimation(testAnimation.repeat())
}
})
)
}
func playAnimations(from content: RealityViewContent) {
subscriptions.append(content.subscribe(to: ComponentEvents.DidAdd.self, componentType: AnimationLibraryComponent.self, { event in
let entity = event.entity
entity.components[AnimationLibraryComponent.self]?.animations.forEach({ (key, value) in
if value.definition is AnimationGroup {
if key == "/Room/TestTimeline" {
let controller = entity.playAnimation(value.repeat())
testEntity = entity
testAnimation = value
appModel.syncronizedAnimations[key] = .init(name: key, animationController: controller, entityName: entity.name)
}
} else {
if entity.name == "SphereInteractable" {
let controller = entity.playAnimation(value.repeat())
appModel.syncronizedAnimations[key] = .init(name: key, animationController: controller, entityName: entity.name)
}
}
})
}))
}
}
the variables testEntity, testAnimation and testController are for testing purposes only. If I try to start the animations in the playAnimations function, only the animation created via blender starts (the one related to the object "SphereInteractable"), the Timeline starts only if I save a reference and I play it with a tap gesture or with a delay of ! seconds with DispatchQueue.asyncAfter called in the onAppear.
is there a better way to handle this? The goal is to have a reference of the AnimationPlaybackController of the timeline, in order to sync the animation via shareplay.
Thanks
I've been struggling to get a ValueTransformer to work while developing in Xcode 16 for iOS 18. Despite thinking I had everything set up correctly, I keep encountering the following error whenever I create a tag:
let tag = Tag(name: name, color: color.toPlatformColor()) // Converts it to NSColor or UIColor
modelContext.insert(tag)
SwiftData/DataUtilities.swift:184: Fatal error: Unable to determine the primitive for Attribute - name: color, options: [transformable with Optional("ColorTransformer")], valueType: UIColor, defaultValue: UIExtendedSRGBColorSpace 0 0 1 1, hashModifier: nil
Here’s what I’m dealing with:
Tag Model:
@Model
public final class Tag: Identifiable {
var name: String = ""
@Attribute(.transformable(by: ColorTransformer.self))
var color: PlatformColor = PlatformColor.blue
init(name: String, color: PlatformColor) {
self.name = name
self.color = color
}
}
ColorTransformer:
final class ColorTransformer: ValueTransformer {
override func transformedValue(_ value: Any?) -> Any? {
guard let color = value as? PlatformColor else { return nil }
do {
let data = try NSKeyedArchiver.archivedData(
withRootObject: color, requiringSecureCoding: true)
return data
} catch {
assertionFailure("Failed to transform `PlatformColor` to `Data`")
return nil
}
}
override func reverseTransformedValue(_ value: Any?) -> Any? {
guard let data = value as? NSData else { return PlatformColor.black }
do {
let color = try NSKeyedUnarchiver.unarchivedObject(
ofClass: PlatformColor.self, from: data as Data)
return color
} catch {
assertionFailure("Failed to transform `Data` to `PlatformColor`")
return nil
}
}
override class func transformedValueClass() -> AnyClass {
return PlatformColor.self
}
override class func allowsReverseTransformation() -> Bool {
return true
}
public static func register() {
ValueTransformer.setValueTransformer(ColorTransformer(), forName: .colorTransformer)
}
}
extension NSValueTransformerName {
static let colorTransformer = NSValueTransformerName(rawValue: "ColorTransformer")
}
Platform Alias:
#if os(macOS)
typealias PlatformColor = NSColor
#else
typealias PlatformColor = UIColor
#endif
The ValueTransformer is registered when the ModelContainer is created at app startup:
var sharedModelContainer: ModelContainer = {
ColorTransformer.register()
// Other configurations...
}()
I've also tried not aliasing the colors to see if that changes anything, but I still encounter the same issue. Any guidance or suggestions would be greatly appreciated!
Hello I'm a beginner to Swift Concurrency and have run into an issue with AsyncStream. I've run into a situation that causes an observing of a for loop to receiving a values from an AsyncStream.
At the bottom is the code that you can copy it into a Swift Playground and run.
The code is supposed to mock a system that has a service going through a filter to read and write to a connection.
Here is a log of the prints
🙈🫴 setupRTFAsyncWrites Start
⬅️ Pretend to write 0
➡️ Pretend to read 0
feed into filter 0
yield write data 1
🙈🫴 setupRTFAsyncWrites: write(1 bytes)
⬅️🙈🫴 Async Event: dataToDevice: 1 bytes
⬅️ Pretend to write 1
➡️ Pretend to read 1
feed into filter 1
yield write data 2
// here our for loop should have picked up the value sent down the continuation. But instead it just sits here.
Sample that can go into a playground
//: A UIKit based Playground for presenting user interface
import SwiftUI
import PlaygroundSupport
import Combine
import CommonCrypto
import Foundation
class TestConnection {
var didRead: ((Data) -> ()) = { _ in }
var count = 0
init() {
}
func write(data: Data) {
// pretend we sent this to the BT device
print("⬅️ Pretend to write \(count)")
Task {
try await Task.sleep(ms: 200)
print("➡️ Pretend to read \(self.count)")
self.count += 1
// pretend this is a response from the device
self.didRead(Data([0x00]))
}
}
}
enum TestEvent: Sendable {
/// ask some one to write this to the device
case write(Data)
/// the filter is done
case handshakeDone
}
class TestFilter {
var eventsStream: AsyncStream<TestEvent>
var continuation: AsyncStream<TestEvent>.Continuation
private var count = 0
init() {
(self.eventsStream, self.continuation) = AsyncStream<TestEvent>.makeStream(bufferingPolicy: .unbounded)
}
func feed(data: Data) {
print("\tfeed into filter \(count)")
count += 1
if count > 5 {
print("\t✅ handshake done")
self.continuation.yield(.handshakeDone)
return
}
Task {
// data delivered to us by a bluetooth device
// pretend it takes time to process this and then we return with a request to write back to the connection
try await Task.sleep(ms: 200)
print("\tyield write data \(self.count)")
// pretend this is a response from the device
let result = self.continuation.yield(.write(Data([0x11])))
}
}
/// gives the first request to fire to the device for the handshaking sequence
func start() -> Data {
return Data([0x00])
}
}
// Here we facilitate communication between the filter and the connection
class TestService {
private let filter: TestFilter
var task: Task<(), Never>?
let testConn: TestConnection
init(filter: TestFilter) {
self.filter = filter
self.testConn = TestConnection()
self.testConn.didRead = { [weak self] data in
self?.filter.feed(data: data)
}
self.task = Task { [weak self] () in
await self?.setupAsyncWrites()
}
}
func setupAsyncWrites() async {
print("🙈🫴 setupRTFAsyncWrites Start")
for await event in self.filter.eventsStream {
print("\t\t🙈🫴 setupRTFAsyncWrites: \(event)")
guard case .write(let data) = event else {
print("\t\t🙈🫴 NOT data to device: \(event)")
continue
}
print("\t\t⬅️🙈🫴 Async Event: dataToDevice: \(data)")
self.testConn.write(data: data)
} // for
// This shouldn't end
assertionFailure("This should not end")
}
public func handshake() async {
let data = self.filter.start()
self.testConn.write(data: data)
await self.waitForHandshakedone()
}
private func waitForHandshakedone() async {
for await event in self.filter.eventsStream {
if case .handshakeDone = event {
break
}
continue
}
}
}
Task {
let service = TestService(filter: TestFilter())
await service.handshake()
print("Done")
}
/*
This is what happens:
🙈🫴 setupRTFAsyncWrites Start
⬅️ Pretend to write 0
➡️ Pretend to read 0
feed into filter 0
yield write data 1
🙈🫴 setupRTFAsyncWrites: write(1 bytes)
⬅️🙈🫴 Async Event: dataToDevice: 1 bytes
⬅️ Pretend to write 1
➡️ Pretend to read 1
feed into filter 1
yield write data 2
// It just stops here, the `for` loop in setupAsyncWrites() should have picked up the event sent down the continuation after "yield write data 2"
// It should say
🙈🫴 setupRTFAsyncWrites: write(1 bytes)
⬅️🙈🫴 Async Event: dataToDevice: 1 bytes
*/
extension Task<Never, Never> {
public static func sleep(ms duration: UInt64) async throws {
try await Task.sleep(nanoseconds: 1_000_000 * duration)
}
}
I need to connect to a JMS that publishes data that I need to collect.
I am trying one solution: RabbitMQ with the JMS plugin. I succeeded to install RabbitMQ and send messages from one process to another. However, I need to consume a JMS that an external party publishes.
Can anybody tell me how I should configure the Host, Port, Username, Password and Queue name for RabbitMQ/JMS so that I can consume (or subscribe to) that JMS?
Or does anybody know another way to consume (or subscribe to) a JMS from Swift?
I have no idea which of the provided Tags I should select.
Thanks!
Wouter
iOS WKWebview - When we run the WKWebview with loading the HTML file. Including JS method call and video looping it here in js file. Getting this method call webViewWebContentProcessDidTerminate(_ webView: WKWebView). Can anyone provide the solution?
Thanks
Since iPadOS 18.x WKWebView seems to have a bug within its Fullscreen API (which can be enabled via WKPreferences.isElementFullscreenEnabled). This bug has the effect that websites trying to make an element (for example a video player) fullscreen fail to do so. This does not always happen, most of the time the fullscreen mode does work fine, but sometimes (far too often to be ignored) it does not. If an instance of WKWebView shows this issue, it can not be "fixed" by reloading the page or loading other pages, this issue exists in this instance forever.
My App is a web browser App so I can create and remove WKWebView instance easily (by opening or closing Tabs). And there are times where I never see this bug, and times where ever other tab shows this bug. It's totally unreliable.
The App does not show any issues at all when running under iPadOS 17 or older. The issue is only present under iPadOS 18.x.
After some testing I've found out that when the bug has affected an instance of WKWebView, the JavaScript call element.requestFullscreen() will work if the element is a video element, but does no longer work if it is another element (like a DIV). If an instance of WKWebView is not affected by this bug, element.requestFullscreen() will work for all HTML elements.
Does anyone has experienced this bug as well? And maybe found a workaround? Or maybe found a pattern which helps to find out what exactly is triggering this bug?
When first opening my app, the first view navigated to loads and then a second later reloads. When navigating away and back to the view, it only loads once as designed.
Has anyone ever experienced this before and knows of any obvious reasons?
I can upload code snippets later, the views are wrapped in navigation links.
Thanks for any help
I have noticed a strange bug with TabView in the settings window of an macOS app. When text is typed into a textbox, the icon jiggles a little bit, but ONLY on a non-retina monitor (1920x1200 in my test). Some icons jiggle, others don’t. Below is code for the gearshape which exhibits this behavior. “sparkle” doesn’t. Very odd. Tried on macOS 15.0.1, Xcode 16.
You can see it in action here
https://imgur.com/a/huCw7sN
// App file
@main
struct TabViewJiggleApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
Settings {
SettingsView()
}
}
}
// Settings view
struct SettingsView: View {
@State private var input: String = ""
var body: some View {
TabView {
TextField("Enter text", text: $input)
.tabItem {
Label("General", systemImage: "gearshape")
.font(.system(size: 20))
}
}
}
}
It appears that starting with macOS Sequoia, Quick Look Preview extension no longer loads MapKit maps correctly anymore. Map tiles do not appear, leaving users with a beige background.
Users report that polylines do render correctly, but annotations appears black.
This was previously working fine in prior macOS versions including Sonoma.
STEPS TO REPRODUCE
Create a macOS app project, with an associated document.
Ensure project has a Quick Look preview extension, with necessary basic setups.
Ensure that the extension mentioned in (2) must have a MKMapView. Any other cosmetic changes, etc, does not need to be implemented to observe the base issue. Do note that it has been reported that in addition to the map tiles not loading, annotations don't render correctly as well.
Hello everyone,
I’m currently working on a Swift project using the Network framework to create a multicast-based communication system. Specifically, I’m implementing both a multicast receiver and a sender that join the same multicast group for communication. However, I’ve run into some challenges with the connection management, replying to multicast messages, and handling state updates for both connections and connection groups.
Below is a breakdown of my setup and the specific issues I’ve encountered.
I have two main parts in the implementation: the multicast receiver and the multicast sender. The goal is for the receiver to join the multicast group, receive messages from the sender, and send a reply back to the sender using a direct connection.
Multicast Receiver Code:
import Network
import Foundation
func setupMulticastGroup() -> NWConnectionGroup? {
let multicastEndpoint1 = NWEndpoint.hostPort(host: NWEndpoint.Host("224.0.0.1"), port: NWEndpoint.Port(rawValue: 45000)!)
let multicastParameters = NWParameters.udp
multicastParameters.multipathServiceType = .aggregate
do {
let multicastGroup = try NWMulticastGroup(for: [multicastEndpoint1], from: nil, disableUnicast: false)
let multicastConnections = NWConnectionGroup(with: multicastGroup, using: multicastParameters)
multicastConnections.stateUpdateHandler = InternalConnectionStateUpdateHandler
multicastConnections.setReceiveHandler(maximumMessageSize: 16384, rejectOversizedMessages: false, handler: receiveHandler)
multicastConnections.newConnectionHandler = newConnectionHandler
multicastConnections.start(queue: .global())
return multicastConnections
} catch {
return nil
}
}
func receiveHandler(message: NWConnectionGroup.Message, content: Data?, isComplete: Bool) {
print("Received message from \(String(describing: message.remoteEndpoint))")
if let content = content, let messageString = String(data: content, encoding: .utf8) {
print("Received Message: \(messageString)")
}
let remoteEndpoint = message.remoteEndpoint
message.reply(content: "Multicast group on 144 machine ACK from recv handler".data(using: .utf8))
if let connection = multicastConnections?.extract(connectionTo: remoteEndpoint) {
connection.stateUpdateHandler = InternalConnectionRecvStateUpdateHandler
connection.start(queue: .global())
connection.send(content: "Multicast group on 144 machine ACK from recv handler".data(using: .utf8), completion: NWConnection.SendCompletion.contentProcessed({ error in
print("Error code: \(error?.errorCode ?? 0)")
print("Ack sent to \(connection.endpoint)")
}))
}
}
func newConnectionHandler(connection: NWConnection) {
connection.start(queue: .global())
connection.send(content: "Multicast group on 144 machine ACK".data(using: .utf8), completion: NWConnection.SendCompletion.contentProcessed({ error in
print("Error code: \(error?.errorCode ?? 0)")
print("Ack sent to \(connection.endpoint)")
}))
}
func InternalConnectionRecvStateUpdateHandler(_ pState: NWConnection.State) {
switch pState {
case .setup:
NSLog("The connection has been initialized but not started")
case .preparing:
NSLog("The connection is preparing")
case .waiting(let error):
NSLog("The connection is waiting for a network path change. Error: \(error)")
case .ready:
NSLog("The connection is established and ready to send and receive data.")
case .failed(let error):
NSLog("The connection has disconnected or encountered an error. Error: \(error)")
case .cancelled:
NSLog("The connection has been canceled.")
default:
NSLog("Unknown NWConnection.State.")
}
}
func InternalConnectionStateUpdateHandler(_ pState: NWConnectionGroup.State) {
switch pState {
case .setup:
NSLog("The connection has been initialized but not started")
case .waiting(let error):
NSLog("The connection is waiting for a network path change. Error: \(error)")
case .ready:
NSLog("The connection is established and ready to send and receive data.")
case .failed(let error):
NSLog("The connection has disconnected or encountered an error. Error: \(error)")
case .cancelled:
NSLog("The connection has been canceled.")
default:
NSLog("Unknown NWConnection.State.")
}
}
let multicastConnections = setupMulticastGroup()
RunLoop.main.run()
Multicast Sender Code:
import Foundation
import Network
func setupConnection() -> NWConnection {
let params = NWParameters.udp
params.allowLocalEndpointReuse = true
return NWConnection(to: NWEndpoint.hostPort(host: NWEndpoint.Host("224.0.0.1"), port: NWEndpoint.Port(rawValue: 45000)!), using: params)
}
func sendData(using connection: NWConnection, data: Data) {
connection.send(content: data, completion: .contentProcessed { nwError in
if let error = nwError {
print("Failed to send message with error: \(error)")
} else {
print("Message sent successfully")
}
})
}
func setupReceiveHandler(for connection: NWConnection) {
connection.receive(minimumIncompleteLength: 1, maximumLength: 65000) { content, contentContext, isComplete, error in
print("Received data:")
print(content as Any)
print(contentContext as Any)
print(error as Any)
setupReceiveHandler(for: connection)
}
}
let connectionSender = setupConnection()
connectionSender.stateUpdateHandler = internalConnectionStateUpdateHandler
connectionSender.start(queue: .global())
let sendingData = "Hello, this is a multicast message from the process on mac machine 144".data(using: .utf8)!
sendData(using: connectionSender, data: sendingData)
setupReceiveHandler(for: connectionSender)
RunLoop.main.run()
Issues Encountered:
Error Code 0 Even When Connection Refused:
On the receiver side, I encountered this log:
nw_socket_get_input_frames [C1.1.1:1] recvmsg(fd 8, 9216 bytes) [61: Connection refused]
Error code: 0
Ack sent to 10.20.16.144:62707
Questions:
how do I reply to the message if above usage pattern is wrong?
how do I get a NWConnection from the received message to create a separate connection for communication with the sender.
Any insights or suggestions on resolving these issues or improving my multicast communication setup would be greatly appreciated.
Thanks :)
I added a password to Keychain using Swift on macOS.
All works well, and I can see it
using Keychain Access, it is stored under iCloud -> Passwords.
How can I see this password on the Passwords App. Is there something I need to do, maybe in Swift, to have this password in the Passwords App, not just in Keychain Access
Note, I have turn on iCloud Keychain on my Mac: https://support.apple.com/en-us/109016