Post

Replies

Boosts

Views

Activity

Reply to How can I keep Installer from relocating packages?
It is possible to use pkgbuild without --component-plist, it looks like you are doing that. If you want more control, run pkgbuild with the --analyze option, then edit the template plist to your liking (this is where you could make the app bundle non-relocatable), and subsequently use pkgbuild with --component-plist. It has been forever since I did this, so this is as far as I think I could assist. I hope it helps.
Jan ’24
Reply to CGMouseMove doesn't trigger menu bar
So you're saying that when a full screen app is frontmost, if you move the mouse cursor to the top of the screen directly, the menu bar appears, but if you place the cursor programmatically using CGDisplayMoveCursorToPoint the menu bar does not appear? Are you also saying that the commented-out code which inserts a mouse-moved event doesn't work? If it doesn't, in what way does it not work - does it not move the cursor, or it does move the cursor but the menu bar doesn't appear as expected?
Topic: Programming Languages SubTopic: Swift Tags:
Jan ’24
Reply to CameraExtension and Uninstaller
your camera extension will be removed from the system when the user deletes the app from /Applications. They'll see a warning when they do so, it says something like "this app includes an extension which will be deleted if you delete this app, are you sure?". So if your app only contains a camera extension, you don't really need an uninstaller - everything goes away when the user deletes the app. Your installer can't deactivate the extension because the uninstaller's bundle ID is "com.my.app.unisntaller" and the extension you are trying to activate has a bundle ID which is not prefixed by "com.my.app.unisntaller". Two things here: did you intentionally mis-spell "uninstaller" in your bundle ID? If you have an uninstaller, it should just delete the app hosting the extension, and the OS will take care of unloading the extension
Topic: App & System Services SubTopic: General Tags:
Jan ’24
Reply to SwiftUI popover not updating binding
where are you using the TestPicker (aside from in its Preview)? it works for me when used in the ContentView below. I built this for iOS and ran it in a iPhone 15 simulator. To dismiss the picker, swipe down on the horizontal grey bar near the top of the screen. struct ContentView: View { @State private var selection = 1 var body: some View { VStack { TestPicker(selection: $selection) } .padding() } } #Preview { ContentView() } Lots of SwiftUI examples on Paul Hudson't site, for example https://www.hackingwithswift.com/quick-start/swiftui
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’24
Reply to iPadOS, IOKit and Sandbox/MACF
On macOS, libUSB uses the methods in IOKit/usb/IOUSBLib.h. These are unavailable on iPadOS. DriverKit is available on iPadOS on devices with M1 or later processors. DriverKit doesn't have the same APIs as IOUSBLib, you would use it to make a Driver Extension (dext) which provides the functions you require. You can read the device ID and the vendor ID without direct access to the device itself, by querying the IORegistry. In principle, you could communicate with a device using the user-space property accessors like IORegistryEntrySetCFPropert(y/ies) and IORegisteryEntryCreateCFPropert(y/ies), but in practice most drivers don't support the property setters, so you would have to write a driver extension which does. And if you go that far, you may as well support direct communication with the driver by implementing a user client and calling IOConnectCallMethod or its derivatives like IOConnectCallStructMethod. I don't think you need special entitlements to read the IORegistry, but you do need them to communicate with drivers, and you driver needs specific entitlements which are tied to one or more specific USB vendor IDs. Reportedly, you can develop a driver without the entitlements, but I could never get that to work and have since been granted the entitlements so I never revisited the topic. See https://developer.apple.com/documentation/driverkit
Topic: App & System Services SubTopic: Core OS Tags:
Jan ’24
Reply to Is there any way to tell if a file is on SSD volume?
I don't know of any API to get this kind of information directly. You might be better off using performance measurements to change your strategy on-the-fly. What differs between SSD and rotating rust that influences your strategy? You can query a volume to find out its BSD name, using statfs. The f_mntfromname field contains the BSD name, (e.g. /dev/disk1s2). You can search the IORegistry to find nodes with BSD names matching e.g. "disk1s2". Then look up the IORegistry to see if the controller is an NVMe controller or something else. The methods for iterating through the IORegistry are in IOKitLib.h, there's a tool called IORegistryExplorer which lets you inspect the registry.
Topic: Programming Languages SubTopic: Swift Tags:
Dec ’23
Reply to Simple barcode reader. Please help
The Vision framework can detect various types of barcodes (start here: https://developer.apple.com/documentation/vision/vndetectbarcodesrequest) If you need to create bar codes to work with, you can use a built-in CoreImage filter to generate a bar code. See https://developer.apple.com/documentation/coreimage/cibarcodedescriptor. The links above should give you a starting point, and some keywords to search with.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’23
Reply to Why would you use @State at the application level, or anywhere outside SwiftUI?
The answers you are looking for are linked from the documentation you provided a link to, here: https://developer.apple.com/documentation/swiftui/migrating-from-the-observable-object-protocol-to-the-observable-macro?language=objc The Observable macro is new and most of the Internet hasn't caught up yet. If you can use Observable, you can use @State instead of @StateObject, even for classes and structs. The library lives outside the App struct. Lexically, it appears to be inside the struct, but SwiftUI manages its lifetime because of that @State macro. You can put a breakpoint inside Library's init to see when it called.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’23
Reply to Build failed on Xcode 15
how long is it since you last built or linked your project? Is it an app, a library or a framework? What version of Xcode and did it last succeed on? It sounds like a tool has changed, and what used to look like a flag now looks like a file name to the build tools.
Dec ’23
Reply to What are command line tools?
use your favorite search engine to look for "what is in mac command line tools", and you might find this link, for example, which will tell you more https://mac.install.guide/commandlinetools/index.html You ask is it safe to install the tools - yes. Is it safe to use the tools - well, it depends on what you do with them. Why are they so large - they do a lot more than set the visibility attribute of files. The SetFile tool itself is 168KB. hope this helps, good luck
Topic: App & System Services SubTopic: Drivers Tags:
Dec ’23
Reply to SwiftUI - Infinite Loop - onDisappear without "."
with the dot, you're calling a function called onDisappear on the result of the function .onAppear. without the dot, you're calling a function called onDisappear on the view enclosing the one you are applying modifiers to. The latter is probably never what you want to do, but the compiler doesn't know that. All it knows is that the code compiles. I think that the Swift compiler should take a look at what you write, and question the intent (even if the code compiles). There are rumors that Apple is doing big things with AI, maybe improved code review in Xcode could be one of those things? You can use Feedback Assistant to request such improvements.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’23
Reply to How can I keep Installer from relocating packages?
It is possible to use pkgbuild without --component-plist, it looks like you are doing that. If you want more control, run pkgbuild with the --analyze option, then edit the template plist to your liking (this is where you could make the app bundle non-relocatable), and subsequently use pkgbuild with --component-plist. It has been forever since I did this, so this is as far as I think I could assist. I hope it helps.
Replies
Boosts
Views
Activity
Jan ’24
Reply to IOKit with Swift
import IOKit import IOKit.serial
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Jan ’24
Reply to How can I keep Installer from relocating packages?
Does your component.plist contain <key>BundleIsRelocatable</key> <true/> If so, changed it to <false/>. I thought this (BundleIsRelocatable=true) meant that the user can change the destination. In fact, it means that the Installer can relocate the bundle to the location of a previously-installed bundle, rather than put it at RootRelativeBundlePath
Replies
Boosts
Views
Activity
Jan ’24
Reply to CGMouseMove doesn't trigger menu bar
So you're saying that when a full screen app is frontmost, if you move the mouse cursor to the top of the screen directly, the menu bar appears, but if you place the cursor programmatically using CGDisplayMoveCursorToPoint the menu bar does not appear? Are you also saying that the commented-out code which inserts a mouse-moved event doesn't work? If it doesn't, in what way does it not work - does it not move the cursor, or it does move the cursor but the menu bar doesn't appear as expected?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jan ’24
Reply to CameraExtension and Uninstaller
your camera extension will be removed from the system when the user deletes the app from /Applications. They'll see a warning when they do so, it says something like "this app includes an extension which will be deleted if you delete this app, are you sure?". So if your app only contains a camera extension, you don't really need an uninstaller - everything goes away when the user deletes the app. Your installer can't deactivate the extension because the uninstaller's bundle ID is "com.my.app.unisntaller" and the extension you are trying to activate has a bundle ID which is not prefixed by "com.my.app.unisntaller". Two things here: did you intentionally mis-spell "uninstaller" in your bundle ID? If you have an uninstaller, it should just delete the app hosting the extension, and the OS will take care of unloading the extension
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Jan ’24
Reply to SwiftUI popover not updating binding
where are you using the TestPicker (aside from in its Preview)? it works for me when used in the ContentView below. I built this for iOS and ran it in a iPhone 15 simulator. To dismiss the picker, swipe down on the horizontal grey bar near the top of the screen. struct ContentView: View { @State private var selection = 1 var body: some View { VStack { TestPicker(selection: $selection) } .padding() } } #Preview { ContentView() } Lots of SwiftUI examples on Paul Hudson't site, for example https://www.hackingwithswift.com/quick-start/swiftui
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’24
Reply to SwiftUI macOS button size not changing
Buttons are special. Google "swiftui macos big button" and you'll get some useful links. e.g. https://sarunw.com/posts/swiftui-button-size/ and https://stackoverflow.com/questions/59290097/in-swiftui-how-do-i-increase-the-height-of-a-button
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’24
Reply to iPadOS, IOKit and Sandbox/MACF
On macOS, libUSB uses the methods in IOKit/usb/IOUSBLib.h. These are unavailable on iPadOS. DriverKit is available on iPadOS on devices with M1 or later processors. DriverKit doesn't have the same APIs as IOUSBLib, you would use it to make a Driver Extension (dext) which provides the functions you require. You can read the device ID and the vendor ID without direct access to the device itself, by querying the IORegistry. In principle, you could communicate with a device using the user-space property accessors like IORegistryEntrySetCFPropert(y/ies) and IORegisteryEntryCreateCFPropert(y/ies), but in practice most drivers don't support the property setters, so you would have to write a driver extension which does. And if you go that far, you may as well support direct communication with the driver by implementing a user client and calling IOConnectCallMethod or its derivatives like IOConnectCallStructMethod. I don't think you need special entitlements to read the IORegistry, but you do need them to communicate with drivers, and you driver needs specific entitlements which are tied to one or more specific USB vendor IDs. Reportedly, you can develop a driver without the entitlements, but I could never get that to work and have since been granted the entitlements so I never revisited the topic. See https://developer.apple.com/documentation/driverkit
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Jan ’24
Reply to linker error | undefined symbols
You've declared getTemperature but not defined it. readSMC should return a kern_return_t but it is returning a double (0.0) or a float. I think you got readSMC mixed up with getTemperature.
Replies
Boosts
Views
Activity
Dec ’23
Reply to Is there any way to tell if a file is on SSD volume?
I don't know of any API to get this kind of information directly. You might be better off using performance measurements to change your strategy on-the-fly. What differs between SSD and rotating rust that influences your strategy? You can query a volume to find out its BSD name, using statfs. The f_mntfromname field contains the BSD name, (e.g. /dev/disk1s2). You can search the IORegistry to find nodes with BSD names matching e.g. "disk1s2". Then look up the IORegistry to see if the controller is an NVMe controller or something else. The methods for iterating through the IORegistry are in IOKitLib.h, there's a tool called IORegistryExplorer which lets you inspect the registry.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Dec ’23
Reply to Simple barcode reader. Please help
The Vision framework can detect various types of barcodes (start here: https://developer.apple.com/documentation/vision/vndetectbarcodesrequest) If you need to create bar codes to work with, you can use a built-in CoreImage filter to generate a bar code. See https://developer.apple.com/documentation/coreimage/cibarcodedescriptor. The links above should give you a starting point, and some keywords to search with.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’23
Reply to Why would you use @State at the application level, or anywhere outside SwiftUI?
The answers you are looking for are linked from the documentation you provided a link to, here: https://developer.apple.com/documentation/swiftui/migrating-from-the-observable-object-protocol-to-the-observable-macro?language=objc The Observable macro is new and most of the Internet hasn't caught up yet. If you can use Observable, you can use @State instead of @StateObject, even for classes and structs. The library lives outside the App struct. Lexically, it appears to be inside the struct, but SwiftUI manages its lifetime because of that @State macro. You can put a breakpoint inside Library's init to see when it called.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’23
Reply to Build failed on Xcode 15
how long is it since you last built or linked your project? Is it an app, a library or a framework? What version of Xcode and did it last succeed on? It sounds like a tool has changed, and what used to look like a flag now looks like a file name to the build tools.
Replies
Boosts
Views
Activity
Dec ’23
Reply to What are command line tools?
use your favorite search engine to look for "what is in mac command line tools", and you might find this link, for example, which will tell you more https://mac.install.guide/commandlinetools/index.html You ask is it safe to install the tools - yes. Is it safe to use the tools - well, it depends on what you do with them. Why are they so large - they do a lot more than set the visibility attribute of files. The SetFile tool itself is 168KB. hope this helps, good luck
Topic: App & System Services SubTopic: Drivers Tags:
Replies
Boosts
Views
Activity
Dec ’23
Reply to SwiftUI - Infinite Loop - onDisappear without "."
with the dot, you're calling a function called onDisappear on the result of the function .onAppear. without the dot, you're calling a function called onDisappear on the view enclosing the one you are applying modifiers to. The latter is probably never what you want to do, but the compiler doesn't know that. All it knows is that the code compiles. I think that the Swift compiler should take a look at what you write, and question the intent (even if the code compiles). There are rumors that Apple is doing big things with AI, maybe improved code review in Xcode could be one of those things? You can use Feedback Assistant to request such improvements.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’23