Posts

Post marked as solved
1 Replies
738 Views
I am creating a SwiftUI 2 app with a HSplitView. The SplitView has several subviews (sidebar - main view - detail view). The user may resize the individual views with the normal split view behavior (dragging the divider bar). I want to persist the user's last used view sizes, so that when the user closes the app and comes back later, the same view layout (view sizes inside the splitview) is presented. How can/should this be achieved? Thanks for your help.
Posted
by HansKe.
Last updated
.
Post not yet marked as solved
6 Replies
5.9k Views
The good news: my request for privileged-file-operations entitlements has been approved by Apple. The bad: I cannot find the "Do you need additional entitlements?” page. Explanation: on approval, Apple sent an email with instructions. The first step is to generate a provisioning profile: To use this special entitlement you must create a new provisioning profile in the Certificates, Identifiers & Profiles section of your developer account and select the entitlement after the “Do you need additional entitlements?” page. However, I never get presented the "Do you need additional entitlements" question(!) What I did: log in at developer account go to section "Certificates, Identifiers & Profiles" click "generate a profile" (I had no previous profiles, I am still in development) choose "macOS App Development" select the appropriate Profile Type (mac) App id (myAppID) select (all) my development certificate select (all) my devices enter a Provisioning Profile Name In the last step I only get the option to "Generate" the profile. I would expect the question "Do you need additional entitlements?" first though. Please note that I am new to this. I have not have previous experience with provisioning profiles as I have not published an app before. Please be specific in a solution on how to if this. I would prefer to be pointed to some "step by step" instruction if possible. Help is much appreciated! PS: I have also tried several other options available in the provisioning section, to no avail (and there are way too many permutations possible to figure out which needle in the haystack I am supposed to find). I read the instructions apple points to, but these all deal with issues *after* having concluded the first step.
Posted
by HansKe.
Last updated
.
Post not yet marked as solved
2 Replies
1.1k Views
I am wondering how to validate menu items in SwiftUI (2.0, macOS). Given the following: @main struct MyApp: App {     var body: some Scene {         WindowGroup {             ContentView()         }         .commands {             CommandMenu("DEBUG") {                 Button(action: { }) {                     Text("menu item 1")                 }                 Button(action: { }) {                     Text("menu item 2")                 }             }         }     } } Suppose menu item 1 is conditional and should be shown or hidden depending on the app state. In AppKit we would use NSMenuItemValidation    func validateMenuItem(_ menuItem: NSMenuItem) -> Bool { // validate the menuItem to be shown } to determine if a menu item should be shown/disable/enabled. Question: how can we do menu validation in SwiftUI? From what I have found so far CommandMenu is build *once* and cannot be dynamically adapted to reflect the current AppState. Or am I missing something?
Posted
by HansKe.
Last updated
.
Post marked as solved
2 Replies
4.8k Views
SwiftUI List comes with embedded scroll functionalty, which is nice, except...that view has a (white) background at a higher lever than any modifyable view. Result: a background view is layered behind the white background of the scroll view. In the debugger I see that the List encapsulates a Hosting View>View Host>ListCoreScrollView. The latter shows opaque. Thusly, trying to change the background of the List has no effect: the background view will be behind the white scroll view.You can easily try it yourself. Create a list with some random rows.List { ForEach(rows.items)Run the app, then look at the View Debugger: rotate the view and you will see the auto generated while layer in the view hierarchy.My first attempt was setting the background color (to no avail, as described above). I also tried adding a custom ViewModifier. Inside a viewModifier one can set the UITableView.appearance(). However, that is IOS only, it does not work on macOS. Using VisualEffectBackground as described here did not get me anywhere either...The only thing that did yield some result is changing the listStyle. Adding .listStyle(SidebarListStyle()) does result in the background that I like, but has another, even worse, side effect: dragging does not work as needed. (I tried modifying that behavior as well, but that causes a whole range of new issues, so gave up).In the end I have spend many hours trying to change something simple as the (background) color of a List. I want to implement a sidebar that is more like the Finders sidebar (which is not white either). Just repeating to avoid irrelevant answers: macOS platform, not IOS.
Posted
by HansKe.
Last updated
.
Post not yet marked as solved
0 Replies
287 Views
Suppose you compose a number of sidebar items using SwiftUI's Outlinegroup:  OutlineGroup(section.children ?? [], children: \.children) { item in ItemRow(item) } View Modifier .listItemTint(.yellow) on the OutlineGroup applies to all of the items in thet group. One cannot use .listItemTint on ItemRow. How to tint just one of the child items with a particular color?
Posted
by HansKe.
Last updated
.
Post not yet marked as solved
4 Replies
2.8k Views
Hi, I am in the process of building a macOS app that needs access to file metadata (amongst which the ownerAccountId). Trying to change properties like owner and group id results in an Operation Not Permitted error. From what I understand one needs Privileged File Operation entitlements for such operations. I am having a hard time figuring out how to achieve this. I have been searching the internet and forums, to no avail. The documentation does not offer a solution either. And it is unclear to me if you have to apply for entitlements when (still) developing and debugging an application for macOS (not ready for publication in the AppStore yet). Does anybody know a proper 'how to' on using entitlements. Which entitlement, when and how to apply them? A step-by-step read would be perfect. In case you would like to answer directly... more specifically my code consists of a bunch of 'utility functions' in a framework. I included unit tests in the framework to be able to test the functionality. One of the tests would be testSettingAccountId, that tests some function that sets a file attribute (FileAttributeKey.ownerAccountID) on some test file. Right now that test fails due to insufficient permissions, which is understandable. I would like to know how I can set ups the environment to properly test the function. That is: do I need to set entitlements. If so, which one(s) and where would I set these in order for the unit test to run successfully? Any help would be much appreciated. Thanks!
Posted
by HansKe.
Last updated
.
Post not yet marked as solved
1 Replies
1k Views
I downloaded the installation profile for macOS Big Sur beta from my apple developer account. It downloads a DMG. When I try to open the DMG I receive an error: "macOSDeveloperBetaAccessUtility.dmg" is damaged and can't be opened. You should move it to the Trash. I checked my partition for errors, to no avail. Does anybody know how to fix this, so I can install the beta access utility. Alternatively: is there a way to install Big Sur directly, i.e. without installing the beta access utility first?
Posted
by HansKe.
Last updated
.