Posts

Post not yet marked as solved
2 Replies
1.3k Views
Is the following code accurate/safe? final class ObjectWithPublished: @unchecked Sendable { @Published var property: Int? } I've tried testing this with the following test, which passes: final class PublishedThreadSafetyTests: XCTestCase { func testSettingValueFromMultipleThreads() { let object = ObjectWithPublished() let iterations = 1000 let completesIterationExpectation = expectation(description: "Completes iterations") completesIterationExpectation.expectedFulfillmentCount = iterations let receivesNewValueExpectation = expectation(description: "Received new value") receivesNewValueExpectation.expectedFulfillmentCount = iterations var cancellables: Set<AnyCancellable> = [] object .$property .dropFirst() .sink { _ in receivesNewValueExpectation.fulfill() } .store(in: &cancellables) DispatchQueue.concurrentPerform(iterations: iterations) { iteration in object.property = iteration completesIterationExpectation.fulfill() } waitForExpectations(timeout: 1) } } There are also no warnings when using the address sanitizer, so it seems like subscriptions and updating @Published values is thread-safe, but the Published type is not marked Sendable so I can't be 100% sure. If this isn't safe, what do I need to protect to have the Sendable conformance be correct?
Posted Last updated
.
Post not yet marked as solved
5 Replies
1.9k Views
Is it possible to read the files from a DMG from a sandboxed app? I have tried using hdiutil using Process but always run in to the error "hdiutil: attach failed - Device not configured". I am running hdiutil attach -verbose -debug -mountroot /path/to/mount/ /path/to/dmg.dmg where both the mount root and DMG file have been chosen via an NSOpenPanel and support writing by the application. I have also tried moving the DMG to a directory within the app's storage (as returned via FileManager.default.urls(for:in:)) and mounting it within the same directory but get the same error. The full output is: fileURL file:///path/to/dmg.dmg directoryURL file:///path/to/mount/ calling DIHLDiskImageAttach with debug: true image-options: quiet: false mount-type: in drive-options: main-url: file:///path/to/dmg.dmg mount-point: file:///path/to/mount/ verbose: true agent: hdiutil 2020-07-28 17:24:35.848455+0100 hdiutil[15701:1369864] DIHLDiskImageAttach: input dictionary { agent = hdiutil; debug = 1; "drive-options" = { }; "image-options" = { }; "main-url" = "file:///path/to/dmg.dmg"; "mount-point" = "file:///path/to/mount/"; "mount-type" = in; quiet = 0; verbose = 1; } 2020-07-28 17:24:35.848677+0100 hdiutil[15701:1369864] DIHLDiskImageAttach: disabling legacy image format attach 2020-07-28 17:24:35.848700+0100 hdiutil[15701:1369864] DIHLDiskImageAttach: newImagekeys = { "legacy-disabled" = 1; } 2020-07-28 17:24:35.848729+0100 hdiutil[15701:1369864] DIHLDiskImageAttach: creating DIHelperProxy 2020-07-28 17:24:35.848769+0100 hdiutil[15701:1369864] with dictionary: { agent = hdiutil; debug = 1; "drive-options" = {length = 42, bytes = 0x62706c69 73743030 d0080000 00000000 ... 00000000 00000009 }; "image-options" = {length = 65, bytes = 0x62706c69 73743030 d101025f 100f6c65 ... 00000000 0000001e }; "main-url" = "file:///path/to/dmg.dmg"; "mount-point" = "file:///path/to/mount/"; "mount-type" = in; operation = DIHelperAttach; quiet = 0; verbose = 1; } 2020-07-28 17:24:35.848787+0100 hdiutil[15701:1369864] [DIHelperProxy alloc] 2020-07-28 17:24:35.848815+0100 hdiutil[15701:1369864] [DIHelperProxy alloc] returning self 0x600002c0c480, retainCount 1 2020-07-28 17:24:35.852410+0100 hdiutil[15701:1369864] DIHLDiskImageAttach: running DIHelperProxy 2020-07-28 17:24:35.852426+0100 hdiutil[15701:1369864] [DIHelperProxy performOperationReturning] entry 2020-07-28 17:24:35.852438+0100 hdiutil[15701:1369864] [DIHelperProxy performOperationReturning] detaching thread 2020-07-28 17:24:35.852675+0100 hdiutil[15701:1369867] [DIHelperProxy workerThread] entry 2020-07-28 17:24:35.852696+0100 hdiutil[15701:1369867] [DIHelperProxy workerThread] setting up server 2020-07-28 17:24:35.852706+0100 hdiutil[15701:1369867] [DIHelperProxy threadSetupServer] entry 2020-07-28 17:24:35.852737+0100 hdiutil[15701:1369867] [DIHelperProxy threadSetupServer] Cannot start hdiejectd because app is sandboxed 2020-07-28 17:24:35.852750+0100 hdiutil[15701:1369867] [DIHelperProxy threadSetupServer] exiting 2020-07-28 17:24:35.852759+0100 hdiutil[15701:1369867] error: unable to set up framework server. 2020-07-28 17:24:35.852767+0100 hdiutil[15701:1369867] [DIHelperProxy workerThread] waiting for task to terminate to avoid zombies 2020-07-28 17:24:35.852775+0100 hdiutil[15701:1369867] checkHelperStatusWaitingForExit: no helper process, skipping 2020-07-28 17:24:35.852783+0100 hdiutil[15701:1369867] [DIHelperProxy workerThread] helper exited 2020-07-28 17:24:35.852793+0100 hdiutil[15701:1369867] [DIHelperProxy workerThread] exiting 2020-07-28 17:24:35.852824+0100 hdiutil[15701:1369864] [DIHelperProxy performOperationReturning] returning 6 2020-07-28 17:24:35.852847+0100 hdiutil[15701:1369864] DIHLDiskImageAttach: DIHelperProxy returned 6 2020-07-28 17:24:35.852860+0100 hdiutil[15701:1369864] [DIHelperProxy dealloc] DIHLDiskImageAttach() returned 6 (null) hdiutil: attach failed - Device not configured The issue appears to be "Cannot start hdiejectd because app is sandboxed", does this mean it's not possible to read a DMG in a sandboxed app, or is there another method available?
Posted Last updated
.
Post not yet marked as solved
2 Replies
1.4k Views
Is it possible to open the native app from a web extension? I have tried creating a new tab that uses the app's URL scheme but the UI asking the user to open the app is not shown until the new page UI is dismissed. Creating a tab with an HTTPS URL that the app is setup to handle does not work and always the link in a new tab. I tried sending a message to the app extension and using NSExtensionContext.open(_:completionHandler:) but the URL is not opened and the closure received false, indicating it was not handled. Having the option to link back to the native app would be very useful.
Posted Last updated
.
Post marked as solved
2 Replies
2k Views
What are the correct sizes and colours to provide for the toolbar icon of a Safari Extension on iOS? For the size I tried creating a solid black icon and measuring the size. They seem to render at 24x24pt but providing 24px, 48px, and 72px images still look blurry. This also only covers the default text size; the icons scales with the system text size. The MDN documentation (which I cannot link here) says that an SVG can be used but supplying an SVG displays the app icon instead. The example icons are all black (like other toolbar icons on iOS) but when displayed in dark mode they are still black, which does not match the other icons in the list. Do I need to specify black and white icons? I tried using browser_action's theme_icons but they seem to be ignored. I've seen other solutions to switch out the icon at runtime but that requires a content script to be injected in to every page or for the popup to be opened by the user. iOS is already tinting the icon blue when the extension is active, can it tint it white when inactive in dark mode?
Posted Last updated
.
Post marked as Apple Recommended
936 Views
Is is possible to use DocC to generate a single .doccarchive that contains documentation for multiple platforms, e.g. macOS and iOS? When publishing a package that has a lot of shared code but some differences between platforms it would be nice to not have to publish a website per-platform.
Posted Last updated
.
Post not yet marked as solved
0 Replies
571 Views
On iOS I am using the ?mode=developer option described at https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_associated-domains, which requires the "Associated Domains Development" option to be enabled in the Develop screen on the Settings app. I am trying to use this option on macOS but cannot find a "Associated Domains Development" option anywhere. How can I enable this on macOS?
Posted Last updated
.
Post not yet marked as solved
0 Replies
606 Views
The documentation for the types within SensorKit show as available from iOS 13, although the framework itself shows as available from iOS 14. Running an app that uses SensorKit works on the iOS 13 simulator, but not on an iOS 13.5.1 device. Is SensorKit going to be usable on iOS 13?
Posted Last updated
.
Post not yet marked as solved
1 Replies
1.5k Views
Following on my question at https://forums.swift.org/t/how-to-allow-process-to-receive-user-input-when-run-as-part-of-an-executable-e-g-to-enabled-sudo-commands/34357 I am trying to spawn an interactive process using a swift executable, specifically `sudo`.I've tried a few things but nothing is working so I think I'm missing something fundemental.I tried using `openpty` but I believe the issue is that I need to pass input to `amaster`, which I'm unsure how to do:public func runOpenpty(_ command: [String]) throws { var amaster: Int32 = 0 var aslave: Int32 = 0 if openpty(&amp;amaster, &amp;aslave, nil, nil, nil) == -1 { print("Failed to open pty") } let masterHandle = FileHandle(fileDescriptor: amaster, closeOnDealloc: true) let slaveHandle = FileHandle(fileDescriptor: aslave, closeOnDealloc: true) let process = Process() process.launchPath = "/usr/bin/env" process.arguments = command process.standardInput = FileHandle.standardInput process.standardOutput = FileHandle.standardOutput try process.run() process.waitUntilExit() }I also came across https://github.com/eonil/PseudoTeletypewriter.Swift, which uses `forkpty`, but I've been unable to get it working from a swift executable.How can I allow the user to provide input to a process that I spawn from my swift executable?
Posted Last updated
.