I'm trying to create a custom control similar to a DisclosureGroup.
I would like to align the leading edges of "11" and "First". There is a Button preceding "First", but none preceding "11".
Bonus question. I'm using SF Symbols for the arrows, but I would like to use the > and V used in DisclosureGroup. Are those symbols available?
Thanks, Mark
var body: some View {
List(items, selection: $selection) { master in
HStack {
if master.master {
Button {
if master.master {
expanded.formSymmetricDifference([master.id])
}
} label: {
Image(systemName: expanded.contains(master.id) ? "arrowtriangle.down" : "arrowtriangle.forward")
}
.buttonStyle(BorderlessButtonStyle())
}
Text(master.name)
}
}
.frame(width: 200)
}
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
While I appreciate the work that Apple puts into the developer documentation, I find it very hard to use.
Among other things, I'm looking for a reference (free / paid / online / dead tree) that describes the views available in SwiftUI with the applicable view modifiers and examples of how to use them.
.commands{
SidebarCommands()
}
If I add the above to a MacOS app, the program gains a Show Sidebar / Hide Sidebar menu option on the View menu. I'd like to add a button to show or hide the sidebar such as the one in Xcode, but I can't find a way to do it? I would have thought that there would be a simple framework call, but my internet searches haven't turned up anything.
I also like the way that Xcode places the Hide Sidebar button on the sidebar, but when the sidebar is hidden, the Show Sidebar button is on the left side of the window. Has any one figured out how to do this with SwiftUI?
This morning the Canvas preview on the app I am developing starting displaying "Cannot preview in this file...". The diagnostics display complains:
MessageSendFailure: Message send failure for send previewInstances message to agent
==================================
| RemoteHumanReadableError
|
| LoadingError: failed to load library at path "/Users/mark/Library/Containers/com.microenh.BoxDesigner/Data/MainView.1.preview-thunk.dylib": Optional(dlopen(/Users/mark/Library/Containers/com.microenh.BoxDesigner/Data/MainView.1.preview-thunk.dylib, 0x0002): tried: '/Users/mark/Library/Developer/Xcode/DerivedData/BoxDesigner-gbhzycedtosmdoetkpwtcpuwawhb/Build/Intermediates.noindex/Previews/BoxDesigner/Products/Debug/MainView.1.preview-thunk.dylib' (no such file), '/Users/mark/Library/Containers/com.microenh.BoxDesigner/Data/MainView.1.preview-thunk.dylib' (code signature in <D4EED909-712E-3055-B429-BBA7EB77A196> '/Users/mark/Library/Containers/com.microenh.BoxDesigner/Data/MainView.1.preview-thunk.dylib' not valid for use in process: mapped file has no Team ID and is not a platform binary (signed with custom identity or adhoc?)))
The file /Users/mark/Library/Containers/com.microenh.BoxDesigner/Data/MainView.1.preview-thunk.dylib is present.
I tried deleting the /Users/mark/Library/Containers/com.microenh.BoxDesigner folder and rebuilding. No change.
I have a Mac Mini M1 with OSX Monterey. I just upgraded to 12.4. I'm currently using Xcode 13.4, but I've had this problem for a while now.
I have two Acer CB282K monitors. CB282K(2) is connected to the Mini's HDMI port and is configured as the main display. CB282K(1) is connected to a USB-C port via a USB-C / HDMI adapter and is configured as extended. Both monitors appear to be working perfectly.
If I hover my mouse over the green button at the top of the most windows, one of the pop up options is "move to CB282K(1)" or "move to CB282K(2)" depending on which monitor is currently displaying the window.
This works fine with most if not all of my programs (including Mail and Safari), but not with Xcode. When I first open any window, while the option is there, selecting it does not move the window to the other monitor. However, if I drag the window to the other window, the option works to move the window back and forth between the monitors. If I close the window and re-open it, it is again "locked" to the main display until I drag it.
I see this behavior with the first Xcode window I open, with a second Xcode window I open (say I want to view two projects at the same time), or with the Developer Help window.
I'm pretty sure that when I started with Xcode last summer, this feature worked, but it has stopped at some point in the past.
I am currently working with XCode 13.3.1 on OSX Monterey 12.3.1 on a Mac Mini M1. I have written some programs in Swift for personal use using a personal team certificate. I haven't paid the $99.
Every couple of weeks or so, some of my programs will pop up a message saying "This Program Could Harm Your Mac" and won't let me run it when I try to launch them. It seems I have to recompile it and then it will work for a few more weeks. Other programs have run for several months.
The programs are using Sandbox and Hardened runtime.
Someone suggested that I try compiling the program without a certificate. I did that last night and the program ran. But this morning when I launched the program, I got a message that the program had unexpectedly quit. The "report" message said something about a code signature.
FWIW, I am copying the program to my Applications folder.
Can someone tell me how Xcode provides the row of images (see above) at the top of the Navigator panel to switch among the various options? It does the same thing with the Inspector panel.
Thanks, Mark
I'm looking for some in-person contacts to help me learn MacOS programming. I'm willing to share what I've learned.
Thanks,
Mark
func zoomOne() {
region.span.latitudeDelta = 10_000
region.span.longitudeDelta = 10_000
}
func zoomIn() {
region.span.latitudeDelta /= 2
region.span.longitudeDelta /= 2
}
func zoomOut() {
region.span.latitudeDelta *= 2
region.span.longitudeDelta *= 2
}
My MacOS app has three methods for adjusting the zoom on a MapKit map display. Each is tied to a separate view Button.
zoomIn() and zoomOut() work as expected, but when the program calls zoomOne(), Xcode breaks and reports a runtime issue in the Issue Navigator:
NSHostingView is being laid out reentrantly while rendering its SwiftUI content. This is not supported and the current layout pass will be skipped.
As a fix, I tried embedding the zoomOne() region update in a DispatchQueue.main.async closure, but it still failed with the same issue.
Thanks, Mark
I have an app that displays a MapKit map with a Text as an a MapAnnotation. When the map is first displayed, the map is centered on the coordinates of the MapAnnotation and once things settle down, the CPU usage reported by Xcode's Debug Navigator goes to 0%.
If the map is dragged or zoomed so that the MapAnnotation is not at the center, the CPU usage goes up during the motion, but does not go back to 0%, but settles down to a few per cent. If you look closely at the map, you can sometimes see that the MapAnnotation is vibrating. Other map features do not appear to move.
I assume that the MapAnnotation is not tied to a fixed map location as are the map features and if the MapAnnotation is not at the center, its display position needs to be constantly recalculated.
I have a MacOS app that displays a MapKit Map on the main scene. The user can drag the map around with the mouse and the motion is smooth, until I enable the Settings scene.
With the Settings scene enabled, the map doesn't follow the mouse but moves when the mouse is released.
If I replace the Settings scene with a "Hello, World" view, the map dragging is fine.
var body: some Scene {
WindowGroup {
LicenseLookupView(fccData: fccData)
.navigationTitle(title)
}
Settings {
FCCDatabaseSettings(fccData: fccData)
}
}
I put a print statement in the constructor to the Setttings scene and the program prints multiple times as the map is dragged, so it appears that even though the Settings scene is not displayed to the user, it is being recreated every time the main Scene is updated. Is there a way to keep that from happening and only build the Settings scene when it is going to be shown to the user?
As a comparison, the Preferences... dialog for Xcode is complex, yet it doesn't impact the performance of the app. Of course, Xcode may not be written in SwiftUI.
Thanks in advance, Mark
I've copied a couple of tutorial Mac OS apps using MapKit. One uses SwiftUI, the other AppKit. Both initially display a map and allow the user to pan and zoom with the mouse. According to XCode's debug navigator, once the user has stopped panning or zooming, the CPU usage goes to 0%.
Both apps allow the user to enter a location and add a MapAnnotation to the map.
On the AppKit version, once the annotation is added, the CPU usage drops back to 0%, but on the SwiftUI version, the CPU usage remains around 5 - 15%. If you look closely at the SwiftUI version, you can see the annotation vibrating by a pixel or so on the display. It seems to me that the display is being constantly updated.
If the annotation is removed, the CPU usage goes back to 0%
I placed a breakpoint in the code that draws the annotation in the SwiftUI version. When adding an annotation, the breakpoint is hit twice, but then no more, so I don't think the CPU is spending time in the Swift code.
Xcode 13.3.1
OSX Monterey 12.3.1
Mac Mini M1
I am developing a Mac app that will control an external device (an amateur radio transceiver). The device is connected via ethernet and continually sends data describing various parameters. The display needs to continually update as these parameters change. I have partially executed this in SwiftUI using the Combine Framework to update views
My issue is that with my understanding of SwiftUI, whenever a view is updated, SwiftUI recreates sibling views. So for example, if there is a stack with 2 views each corresponding to a different parameter, when one of the parameters is updated, both views are recreated. This isn't a problem with 2 views, but what if there are a large number of parameters (and views). Is there a way to design the app so that only the view for an individual parameter is recreated? The app would be designed such that the size of a view never changed, so the sibling views would not be moving. Or am I misunderstanding how SwiftUI works?
Would UIKit be better suited for this, or does it also need to reevaluate constraints (or something else) each time a single view updates?
Another issue I haven't been able to figure out with SwiftUI is how to have multiple windows. I'd like to have separate windows for related sets of parameters that the user can open or close and position on the screen as desired. The best I've been able to find in SwiftUI is different windows for different "documents" where the documents are similar to each other.
Thanks in advance for any advice.
Mark
I have posted a learning project on github. I have gone through the book "Learning Core Audio" by Adamson & Avila and converted the examples from Objective-C to Swift 5.
I hope that this helps others trying to learn CoreAudio and if anyone sees issues in my code, please let me know.
Thanks,
Mark
With a recent update to XCode 13, something has happened to Developer Help.
I am running two identical monitors on my development machine, a M1 Mac Mini (XCode 13.2, OSX 12.3.1)
On most apps, if you hold the mouse button down on the green dot button at the top left of the window, there is a dropdown that gives choices:
Enter Full Screen
Tile Window to Left of Screen
Tile Window to Right of Screen
Move to CB282K(1)
CB282K(1) refers to one of my monitors that is set up as extended display. CB282K(2) is the other one, set up as main display, the one currently displaying the window.
Usually, selecting the Move to CB282K(1) option moves the window to the other monitor. This works for most apps, including Xcode.
But, if I bring up Developer Help, selecting this option does not move the Developer Help window.
If, I manually drag the Developer Help window to the other monitor and select the Move to CB282K(2) option, it moves back to the main monitor. If I then select Move to CB282K(1) the Developer Help window will move and continues to move between monitors as needed.
After closing the Developer Help window, if I open it again, it again refuses to move the second monitor until being dragged manually.
As I said, I think this used to work. Has anyone else seen this behavior and is there some setting I can change to get it working again?
Also, while not relevant to the question, is there a way to change the name of the monitor that shows up in the list. Is there a way I can change the menu to have options "Move to Extended Display" and "Move to Main Display"?
Thanks,
Mark