Posts

Post marked as unsolved
97 Views

How to add a label to the side of a TextField on macOS

In the latest beta most of the SwiftUI controls have now a labels that are displayed on the left side of the controls. The alignment of the controls and labels works pretty well. Also the TextField is aligned with the other controls. But its title parameter is used as a placeholder inside the TextField while the left side of the TextField is empty. In my application I have a SwiftUI form with some controls and some number input fields. After the user has entered values the placeholders are not visible and the user cannot see the meaning of each value he entered anymore. Is there a way that the title of a TextField can be displayed as a label on the left side similar to the other controls instead of a placeholder inside the input field?
Asked
Last updated .
Post marked as unsolved
163 Views

How to add a label to a SwiftUI Textfield in macOS

Is there a way to add a label to SwiftUI Textfield inside a SwiftUI Form so that the label is aligned with the other controls? Placeholder in textfields will disappear when you enter values so this won't help much. All other controls have labels in macOS form with the same width so that their controls are correctly aligned. Textfield seems not to have this option. I tried several workaround like HStacks of Text and Textfields or custom alignment guides but without success.
Asked
Last updated .
Post marked as unsolved
114 Views

Search for max value coordinate in a MTLTexture

I struggle with the implementation of a compute kernel to solve a relative simple search problem. I want to find the coordinate with the highest pixel value within a MTLTexture. I have already an implementation where I copy the content of the MTLTexture into CPU memory and apply some min/max commands from the accelerate framework. But maybe there is also a simple solution for this task using Metal which I haven't found yet.
Asked
Last updated .
Post marked as unsolved
104 Views

Metal Triple Buffering and Capture Scope

Can someone help me with this hopefully simple problem? I use triple buffering in my metal app similar to Apples Best Practice Guide. Three threads are simultaneously encoding rendering commands to command buffers enqueued in into one MTLCommandQueue. What is the best way to debug this scenario with the Xcode's frame debugger? I have some problems setting the capture scopes begin and end point in such a multithreaded environment to isolate the commands encoded from one thread.
Asked
Last updated .
Post marked as unsolved
216 Views

Swift TextField with label on macOS

Why is there no label for SwiftUI TextField but only a placeholder text? Or is there a modifier that I haven't found yet or a style property? On macOS every control seems to have now a label that is shown on the left side and that is correctly aligned with the other controls in a form. The TextField is also aligned with the other controls but has an empty space left to it. Using the label parameter as a placeholder is not very helpful having multiple textfields and the user entered already some values in them. In this case you cannot see anymore the meaning for all these values. I tried to implement a HStack with a Text and a TextField as a workaround but had trouble to align it with the other controls that have already label parameters in their SwiftUI syntax.
Asked
Last updated .
Post marked as unsolved
154 Views

Xcode app cannot see the driver anymore on Big Sur

My app uses an external PCI board connected with the thunderbolt cable to a 2019 MacBook Pro (Big Sur beta 10). The strange thing is that the external example apps coming with the driver can communicate with it. The same apps compiled with Xcode 12.2 beta cannot communicate with the driver even it is the same code. When I installed the driver together with the example apps a window appeared that these software come from an external source and the usage must be granted in the security settings. I did it and therefor the apps work fine. Is there maybe a similar setting now in Xcode where I must allow the compiled app to communicate with third party drivers? The code of the app was unchanged and worked with a previous macOS version.
Asked
Last updated .
Post marked as unsolved
78 Views

Does SwiftUI support BigSur's new toolbar features

Is there a way to add separators to SwiftUI toolbar so that when you change the size of a splitview segment all the toolbar buttons will stay aligned with this segment? Or does it only work without SwiftUI?
Asked
Last updated .
Post marked as unsolved
82 Views

How to implement a Xcode style SwiftUI tabview

Above Xcode's navigator area or uitilty area there are some buttons for switching the content views below. I implemented the standard SwiftUI TabView and also a Picker with the segmented style to get the same appearance in my macOS app but both are looking different. Plain buttons in a HStack above my content area are solving the problem. But it seems more like a workaround. Is there maybe a simpler solution to implement a Xcode style tabview that I have overseen.
Asked
Last updated .
Post marked as unsolved
329 Views

How can I change the color of the slider in SwiftUI

My goal is to hide the SwiftUI slider line on macOS by using a clear color because I set a color gradient as a background view. But whatever color I use (.clear, .red, ...) with the accentColor or foregroundColor modifier the line does not change or can be hidden and appears still on top of the sliders background view.
Asked
Last updated .
Post marked as solved
346 Views

How to position child views within a parent view

Please apologize if this question is really trival. I implementent a content view with two buttons on it. One button should be 8px below the top, the other 8px above the bottom. Maybe I am doing something wrong. But I would use a simple ZStack here. Only problem is that I can set only one alignment for the ZStack at a time. So I can either align all views from the top border or from the bottom border but not one from the top and one from the bottom. Is there a way to solve this layout problem with these three views and a ZStack?
Asked
Last updated .
Post marked as unsolved
717 Views

Why does @Published removes the codable protocol conformance

I have a simple class conforming to the codable protocol. Here is an example which is the same like in the developer documentation...class Landmark: Codable { var name: String var foundingYear: Int }Because the two properties inside the class body are basic Swift types the compiler has nothing to complain.But if I want to edit these properties using SwiftUI I must also make sure that the class conforms also to the ObservableObject protocol.class Landmark: Codable, ObservableObject { @Published var name: String @Published var foundingYear: Int }Now I get an Xcode error message that type Landmark does not conform to the codable protocol anymore.This is something I cannot understand. The property wrapper @Published should not change the type of the properties String and Int. The codable conformance should imho still be given to the class without additional lines of codes.
Asked
Last updated .
Post marked as unsolved
423 Views

How to use a SwiftUI touchbar with a NSWindow

Inside the app delegate I uses a simple SwiftUI view as the root for my macOS main window.func applicationDidFinishLaunching(_ aNotification: Notification) { // Create the SwiftUI view that provides the window contents. let contentView = ContentView().touchBar(myTouchbar) // Create the window and set the content view. window = NSWindow( contentRect: NSRect(x: 0, y: 0, width: 480, height: 300), styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView], backing: .buffered, defer: false) window.center() window.setFrameAutosaveName("Main Window") window.contentView = NSHostingView(rootView: contentView) window.makeKeyAndOrderFront(nil) }This contentView has a touchbar asigned to it. If the contentView is a simple view that can hold a focus (like a Textield) then the touchbar becomes visible on my MacBook. But in my application the contentView (the root view of the NSWindow) is a layout container like a HSplitView. In this case the window appears but the touchbar is not visible. How can I use a SwiftUI touchbar with a window without focusable or input elements so that the touchbar is always visible together with the window.
Asked
Last updated .
Post marked as solved
602 Views

How to align slider labels in SwiftUI

On macOS we can add labels directly to SwiftUI slider. Has someone found a way how we can align two or more sliders in a VStack?- label text right aligned- all labels should have the same width (given by the largest text)- all slider bars should have the same but flexible width within the containers frame
Asked
Last updated .
Post marked as unsolved
4.7k Views

How to use the CarPlay simulator in Xcode 11

Can someone explain how to use the CarPlay simulator in Xcode 11 GM? Maybe I am doing something wrong.In the simulator I choosed hardware->external displays and then a small rectangle window appears. But the screen stays black. My goal is to start the iOS app in the simulator and see the CarPlay screen in this window side by side.In the internet I saw a video where this simulator scenario was working. But I get only the black screen and an iPhone simulator with no CarPlay option in the settings.Some people write you must enter first some commands in the terminal window before you can use the CarPlay simulator. I am not sure if this is still neccessary in Xcode 11 but here is what I used in terminal:defaults write com.apple.iphonesimulator CarPlay -bool YESdefaults write com.apple.iphonesimulator CarPlayExtraOptions -bool YESdefaults write com.apple.iphonesimulator CarPlayProtocols -array-add com.brand.carplay.featureMust I request first the MFI profile from apple when you test only in the simulator? Or does CarPlay simulator not work in Xcode 11 because I saw another thread in the developer forum where someone said he gets also the black screen.
Asked
Last updated .
Post marked as unsolved
596 Views

GPU channels, how do they work?

Does someone know how they GPU channels work exactly in Metal?I implemented a blit command encoder in two different ways and metal system traces showed me that one blit command was sheduled to the GPUs blit channel while the other is running on the gfx channel.- First Blit Copy: Shared MTLBuffer -> Private MTLBuffer- Second Blit Copy: CVMetalTexture -> Private MTLTextureBoth blit commands were commited to the queue in seperate command buffers and on seperate threads.A blit commander for generateMipmaps() on the private MTLTexture from above is also running on the gfx channel and not on the blit channel. Copying parts from one private texture to another region of a destination private texture also runs on the gfx channel.So only the blit copy from one buffer to another buffer seems to run in the blit channel or is this wrong?
Asked
Last updated .