Post

Replies

Boosts

Views

Activity

Reply to SwiftUI Controls Documentation
OK, after quite a bit more searching, I came across several links. One of the links was Gosh Darn SwiftUI - Cheat Sheet, which the link can not be displayed here Fabula For SwiftUI Human Interface Guidelines Interactful Another link, hackingwithswift quick-start/swiftui which can not be displayed. I still have not found a guide that shows controls graphics and their usage. Jim
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’25
Reply to How To Position Controls With SwiftUI
Hi Ptit-Xav, I placed the controls in the same manner as Claude31 recommended. If there is a better placement methods, please specify I don't know what you mean by "placement constraint" My view above is what I thought was a logical subview Regarding ZStack, I thought this was used to control depth of controls, such as various picture objects on top of each other. Don't know what you mean by global view, or what an overlay is I have spent about one month attempting to find comprehensive documentation on SwiftUI and its controls and how to place them, but have come up short. Even Rust has better documentation when it comes to the types of controls available (think FLTK or Iced), what they look like, and how to use them. 99% of the designs are a single vertical column. I have several SwiftUI books, and they cover a lot of material, but answering specific questions about how to place controls on a Form, epecially when the design is more complex, is seemingly hard to come by. Sorry for all the questions, but SwiftUI and its terminology is completely foreign to me. I am used to StoryBoards, which is also very similar to C# WinForms. In the WinForms editor, one simply places controls where they want them.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’25
Reply to How To Position Controls With SwiftUI
After a bunch of more digging around, I am finally getting a little traction on how to create a SwiftUI interface. And I am posting this here in hopes of helping someone else in my position. struct MyCustomView: View { @State private var volume: Double = 0 var body: some View { Group { HStack { Text("oo") .padding(2) .border(Color.black) Button("Stop") { } Button("Play") { } Button("Jump") { } } .padding(.top, 10) VStack { Slider(value: $volume, in: -10...100) .offset(x: 13,y: 0) .frame(width: 150, height: 40) } } .offset(x: -150, y: 0) } } I did a screenshot of a portion of the original music player controls and the same thing using SwiftUI. Now there is the basis for improving the SwiftUI code to better match that of the original screen. I hope this helps someone else.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’25
Reply to How To Position Controls With SwiftUI
Thanks to the responses above, as I appreciate the feedback. After more digging, I may have found more information about how SwiftUI works. It seems that View is an integral part of how Swift places controls on Forms. At the time I thought that the keyword View was used to differentiate between Controls on the Form, but this does seem to be the case as seen below. I found an example in the book from Paul Hudson, Hacking With MacOS, Chapter 13. There, Paul has as example with a series of controls appearing on the right side of a Form, which project down the right side, top to bottom. The skeleton sample code that creates this display is shown below. var body: some View { HStack(spacing: 20) { RenderView(document: document) .draggable(snapshotToURL()) .dropDestination(for: URL.self) { items, location in handleDrop(of: items)} VStack(spacing: 20) { VStack(alignment: .leading) { // stuff here } VStack(alignment: .leading) { // stuff here } .labelsHidden() VStack(alignment: .leading) { // stuff here } } .frame(width: 250) } .padding() .toolbar { Button("Export", action: export) } { export() } } Apparently, the use of VStack, HStack, and so on is considered a form of "View". Seeing the code above gives me a much better idea of how SwiftUI expects to see code that generates controls on the Form. To those that posted above, I saved that information for later use. Thankyou.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’25
Reply to How To Position Controls With SwiftUI
Thanks Claude31, for the screenSize info. That will come in very handy. From your red rectangles above, I am starting to understand that one needs to make use of Views, and more specifically, multiple Views, one for each of the red rectangles above. The code below shows how to stack two Views. Notice MyCustomView is embedded inside the first View below. I have looked at many videos on how to stack more Views, but have not come across any examples. Is there any documentation of how to stack multiple Views. import SwiftUI struct ContentView: View { var body: some View { VStack { MyCustomView() Image(systemName: "star.fill") .font(.largeTitle) .foregroundColor(.yellow) } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’25
Reply to How To Position Controls With SwiftUI
Hi Claude31, Thanks for the response. You gave me some good suggestions on how to approach the issue using Views. I guess another question that I would have is, if I use your View approach, how do I locate each one of those in exact locations on the screen? I have found videos about Views, but not how to locate them. Maybe they have to be adjacent to each other? Based on your response, I did some more digging and found a video by Paul Hudson. Here Paul places some text at an absolute location on the screen as in the sample below. I wonder if it's possible to do this with other controls as well?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’25
Reply to Not Allowed To Open Rust Binary In Terminal
Late Update: Earlier above, I asked the question... Ok, so how do I convert my Rust binary into an Apple app? It turns out that this is indeed, an Apple function, which has been clarified on StackOverFlow. Search for the following... Running Rust app without showing the terminal - for MacOS To sum up, yes, a Rust app (binary) can be converted into an app that can be run natively on Apple OS systems. It should be noted that the release settings (with/without aarch64...) for the Rust binary did not seem to make any difference in running on MacOS. Jim
Topic: Code Signing SubTopic: General Tags:
Jan ’25
Reply to Not Allowed To Open Rust Binary In Terminal
For anyone else that might have been struggling with running a Rust binary on Mac M1, here is some additional information that helped me. Do a web search for... Executable compiled in M1 mac not running on Apple Silicon Mac In the discussion, one of the posters highlighted this code... cargo build --target aarch64-apple-darwin --release So I tried building a Rust GUI that has a single button on the form, and built the code using the above target info. It worked! Note that if one tries to run the binary using Commander One, the request will fail. And THIS is what caused me to start this thread in the first place. For whatever reason, Commander One does not want to run this executable. So in this case, I used Double Commander and double clicked the binary and it worked just fine. I also made a shortcut and ran it from there, and again the Rust binary ran on Mac. I hope this helps others in the same situation. Jim
Topic: Code Signing SubTopic: General Tags:
Jan ’25
Reply to SwiftUI Entry Point - Proper Location In Project
Update on 12-23-2024: I purchased the book... "Hacking With Swift" by author Paul Hudson. Paul has a Github presence... github.com/twostraws/macos I downloaded the zip file and found sample code that shows how the @main makes a call to the first of many "func" calls. In the zip file, look at... project13 ...for a good example of how Swift makes calls to various "func" calls. Seeing this helped me a great deal. I noticed that Swift handles "func" calls to other classes quite a bit different than C#, but this is the reason for the book purchase. I am highlighting this here in the hope that it helps others who are starting their journey with Swift as well.
Dec ’24
Reply to SwiftUI Entry Point - Proper Location In Project
endecotp wrote: What do you actually want to happen? How/where do I declare global variables in the same file as "main" location? On a large project, there will be multiple associated files that contain related functions. How do make calls to these functions from the "main" file? In C# for example, I can't simply call the function name, it has to be associated the "class" that the function is stored in first. Do I have to declare these related functions in the "main" form ahead of usage? I used "print(hi)" just to ensure that my function call was being called. eoonline wrote: Note, if this is your first foray into a declarative language, I might suggest going through some of the tutorials on the SwiftUI page. Or perhaps watch some of the SwiftUI videos, such as WWDC 2024’s SwiftUI essentials (or any of the videos linked on that page). Is it that obvious? Yes, you are correct, in the Swift is quite a shock and seems to be a large learning curve. And yes, I am trying to find whatever I can to learn this language. Thanks for the links, I will certainly check these out.
Dec ’24
Reply to Overall Code Structure Of Swift Project
Quinn wrote: But getting started is really easy: So I tried what you had written, and it worked great for me. However, for some reason I was expecting that the binary would be a GUI background with Hello World printed on top. This is my main interest in learning Swift. Thanks for the push to learn Swift, as I just purchased... Hacking With MacOS And will start learning with that text. Thanks again.
Dec ’24
Reply to Not Allowed To Open Rust Binary In Terminal
Etresoft wrote: If you choose an odd combination, then the burden will be on you to figure it out. Good point. And so far, that is exactly what has happened. It's been quite the journey. endecotp wrote: What GUI toolkit is this using? I stumbled on FLTK after starting out trying "TK" and then later, "Iced", ending up using "FLTK". It's interesting in that the dependencies while using "Iced", were about twice as much as FLTK, with the expected longer compile times.
Topic: Code Signing SubTopic: General Tags:
Dec ’24
Reply to Overall Code Structure Of Swift Project
etresoft wrote: When you're ready to distribute, you'll perform an archive build and you'll have to specify what you want to do with the build product. You can choose to submit it to the App Store, distribute it using a different method, or just save it to disk. When you save the file to disk, does Xcode add a certain extension to the binary? In Windows it's EXE and running Linux, Rust has no binary extension at all. DTS Engineer wrote: The project only contains files that are source of definitive information, such as your source code or your build settings. Anything that's derived from that source of truth can be discarded and recreated at any time. Hence DerivedData. Below is a Rust folder screenshot that shows a file structure very similar to C#. This example is from Github. When Rust compiles, it creates up to 1 gig of "extra stuff" during the build, and Rust leaves it alone until you send "cargo" a clean command. Note that FLTK is the GUI part of Rust code. Does Xcode clean up manually or automatically? endecotp wrote: I’m going to mention the Swift Package Manager: Yes, this something that sounds very interesting. I would definitely like to look into this. DTS Engineer wrote: It’s able to build macOS standalone executables and that’s about it. This sounds really good for my code usage. Does anyone have any other resources on this topic?
Dec ’24
Reply to Not Allowed To Open Rust Binary In Terminal
Quinn wrote: A mechanism to import Apple’s UI frameworks, allowing you to create an app that’s native to the Apple environment After some digging, I found Building an iOS App with Rust Using UniFFI So as Quinn mentioned, the Rust community developed a wrapper system that involves the use of UniFFI. I don't know anything about it at this point, but it looks like a direction to head in. Etresoft wrote: If you are trying to build any of that stuff on a Mac, you might find it easier to discard those build systems and port it all to Xcode. This may be a very good point. Two things come to mind. Rust is much easier for me to work with on Linux Trying the same thing on a Mac gets much harder for my skill level. With this in mind, I am going to post another thread with the title... "Overall Code Structure Of Swift Project" ... and see where this takes us. I have watched numerous videos and they seemed promising, but trying to figure out the structure of a UI project was daunting, to the point where I gave up trying to learn Swift.
Topic: Code Signing SubTopic: General Tags:
Dec ’24