Post

Replies

Boosts

Views

Activity

Distinguishing the MacOS and Mac Catalyst destinations
When using xcodebuild to build my project, I specify a destination of generic/platform=macOS Xcode informs me that my destination is ambiguous as there is a generic destination for Mac Catalyst. --- xcodebuild: WARNING: Using the first of multiple matching destinations: { platform:macOS, name:Any Mac } { platform:macOS, variant:Mac Catalyst, name:Any Mac } At the end of the day, that's OK. It's selected the proper destination by happenstance. But is there a way t change my destination specifier so that it can zero in on the MacOS destination that is not the MacCatalyst variant? I've tried using "generic/platform=macOS,variant=". But that does not work.
1
0
842
Sep ’23
Safari responds to a successful "fetch" of a file:// URL with a status of 0
I built a web application that is designed to be run from my application bundle by using webView.loadFileURL(htmlFile, allowingReadAccessTo: projectFolder) on a WKWebView. Inside of the site's folder is a directory of svg images (from the ionicons project). At runtime the code tries to load one of those images using: req = fetch(url).then((rsp) => { if (rsp.ok) { return rsp.text().then((svgContent) => { if (svgContent && sanitize !== false) { svgContent = validateContent(svgContent); } (code from the ionicons project). The rsp.ok check simply examines the response to the fetch request to see if the status code is in the range 200-299. For the "file://" URL, however Safari on both MacOS and iOS returns 0 in the status. In spite of that 0, however the request has succeeded and the browser has the content of the file. If I modify the code to ignore rsp.ok the following call accessing rsp.text() succeeds. I'm not sure what the expectations are for a file:// URL passed through fetch. Is the 0 status code a bug in Webkit or Safari, or is it an expected result for a file:// URL and the code making the fetch request needs work?
0
0
603
Nov ’23
NWConnection.receive doesn't return expected data
I'm using an NWConnection to talk to a TCP endpoint. The connection steps are working fine and I'm able to receive some data, but not all the data I expect. I am posting to see if I misunderstand how the NWConnection is supposed to behave. The messages I want to receive have a header and a payload. The header tells me how many bytes are in the payload. To do that I am trying to call receive twice on the connection. The first receive looks something like connection.receive(minimumIncompleteLength: MessageHeader.PackedDataCount, maximumLength: MessageHeader.PackedDataCount) { … } The second receive call is very similar and tries to grab the payload. It looks something like: let payloadLength = messageHeader.payloadLength connection.receive(minimumIncompleteLength: payloadLength, maximumLength: payloadLength) { … } The first message sent by the server has the bytes [0x0F, 0x00, 0x01, 0x02]. The first three bytes are the header and indicate that the message type is 0x0F, of length 1 byte (0x0001) and the payload is one byte, 0x02. When I run my code, the first call to receive works fine. I get three of the four bytes sent by the server. The second call to receive, however, never returns the one remaining byte (the callback is never invoked). If I change the first receive call to ask for 1024 as a maximum length then I can see all 4 bytes from the server in the response so I know all the data I want was sent. But I can't receive it in two subsequent calls to the connection. Do I misunderstand the way that receive is supposed to behave? If the server sends four bytes, do I have to read them all in one call to receive?
2
0
581
Oct ’23
Android phone can't discover services advertised from MacOS
I'm writing a MacOS Application to mimic some real hardware for debugging purposes. The application acts as a peripheral (using CBPeripheralManager). It advertises a single service, the primary service, with two characteristics. I have both iOS and Android applications that connect to the MacOS app. For the iOS application, everything works. I can connect to the app, discover services, and manipulate characteristics. The Android application does a BLE scan for peripherals with the service ID and the MacOS application shows up as being available. After connecting to the peripheral, however, when the Android application asks to discover the services of the peripheral, the one service my peripheral offers does not show up. Somehow the service makes it into the advertisement but does not show up during service discovery. Can anyone explain why my services would be advertised, but then not discoverable?
1
1
939
Oct ’22
Building an xcframework with MacOS and Mac Catalyst support
Using xcodebuild, I have built (and archived) several variations of a framework with the following destinations: 'generic/platform=iOS', 'generic/platform=iOS Simulator', 'generic/platform=macOS', 'generic/platform=macOS,variant=Mac Catalyst' I now wish to combine the frameworks into an xcframework using the -create-xcframework switch to xcodebuild. As arguments I am passing an instance of each Archive and the framework to xcodebuild. For example: xcodebuild -archive mycode_ios.xcarchive -framework mycode.framework -archive mycode_ios_simulator.xcarchive -framework mycode.framework [... others here ...] -output mycode.xframework With the destinations above I get an error message: A library with the identifier 'macos-arm64_x86_64' already exists. I assume that the macOS framework and the Mac Catalyst framework are conflicting with one another as they share the same platform and architectures. For that matter I guess the iOS simulator may also be considered macOS with those architectures. How are the "library identifiers" generated and is there a way I can ensure the Mac Catalyst, MacOS, and iOS simulator identifiers are distinct? Perhaps I do not need to? Then what is the minimum set of frameworks I would need to support MacOS, Mac Catalyst, iOS (device) and iOS Simulator in one xcframework?
1
0
1.1k
Sep ’23
`NSBrowser` inside `NSViewRepresentable`
I would like to use an NSBrowser in a MacOS app that is SwiftUI based. To that end, I created a view that implements NSViewRepresentable. My protocol methods are super basic:    func makeNSView(context: Context) -> NSBrowser {         let browser = NSBrowser()         browser.delegate = context.coordinator         return browser     }     func updateNSView(_ nsView: NSBrowser, context: NSViewRepresentableContext<RoomBrowser>) {     } The problem I am having is that the NSBrowser doesn't grow to fill the frame of the hosting View. The width seems fine, but the height is wrong. Looking at the view debugger in Xcode, I can see the there is a "Host View" which is 22 points tall and the NSBrowser is has layout constraints so the height of the browser matches the height of the "Host View". If I try to resize the window (which hugs the content pretty tightly) I can make the window a little smaller, but it will not drag larger. How can I change the size of the host view to manipulate the size of the NSBrowser?
1
0
795
Mar ’22
Unable to install a provisioning profile on an iPhone 14
I got a nice new iPhone to do some debugging on and I'm trying to run my application from Xcode on the new phone. When I run the application it fails and in the "Details" of the failure it tells me that the provisioning profile is invalid: "A valid provisioning profile for this executable was not found" Using "Automatically Manage Signing" and choosing my development team, when I click on the little (i) button next to "Xcode managed Profile" I see all check marks. Xcode seems to think I have everything I need. I do see my device listed in the supported devices area. I have turned "Automatically Manage Signing" off and on (to regenerate the profile) and I've tried manually copying the profile to the phone (emailing it to myself, and using AirDrop). The phone complains that the profile is invalid. Kicking it old school, I went to my account and created a new development signing certificate, and a provisioning profile that includes my device. I tried using Xcode with the manual certificate and profile and got the same result. All in all it looks like my phone refuses to accept a provisioning profile. Is there anything more I can try to allow me to use my device for debugging. (I have tried using Xcode 14 and 14.1b5, and while my phone is running both 16.1b4 and 16.1b5).
9
1
9.8k
Oct ’22
Creating an Archive fails to find headers from static library project
In my workspace I have a project that builds a static library. That project declares public header files and in the project we declare the Public Headers Folder Path as "include/TheLibrary". In the main application project, I am usually able to include public headers related to the static library as: #include <TheLibrary/HeaderFile.h> I include a header file this way from my applications Swift bridging header. The application builds and runs without trouble. However, when I Archive the project - either from Xcode, or from the command line using xcodebuild the archive command fails while precompiling the Swift Bridging Header stating that the <TheLibrary/HeaderFile.h> cannot be found. This only happens when Archiving. Building and testing work. Why is Xcode unable to find my static library project's public headers when archiving?
0
0
354
Apr ’23
Keys and Values for OSLog entries filtered by NSPredicate
It's very nice that I can enumerate the entries in my application logs. I've used NSPredicate to great effect over the past few decades. To use it most effectively, however, you need to know what keys an object has. I have not yet found any documentation which tells you what keys (and their value types) that you can use in the NSPredicate you pass to getEntries(with:at:matching:) By trial and error (ok... mostly trial and assumption). I found I can use "subsystem = %@". I might assume things like category and date are in there. How about log level? Are the available keys and associated value types documented?
1
0
1.1k
Oct ’22