The below should work both on macOS and iOS with one minor change. That is, use UIColor instead of NSColor if you’re planning to use it for iOS.
For various reasons you may want to convert the Color type to a String. And, below is a relatively cleaner way to do it.
In Swift, the switch statement doesn’t automatically fall through to the next case. Each case block is designed to execute only the code within that case, and it doesn’t continue to the next case unless you use the fallthrough keyword.
I was looking for the SF Symbol for the latest Twitter icon, yes the X icon, but I couldn’t find any online. So, I created one here: https://github.com/rampatra/assets/blob/main/SFSymbols/X%20Social%20Network.svg. This works with the latest SF Symbol 5 so you can either import it to your SF Symbols app or use it directly in your Xcode by creating a new Symbol Image Set like shown below.
To display both the app version and build number in a SwiftUI macOS/iOS app, you can use the Bundle class to access information from the app’s Info.plist file. The Info.plist file contains various details about your application, including its version and build number. Here’s how you can do it:
In Swift, if you encounter a “Result of call to ‘function’ is unused” warning, it means that you’re calling a function that returns a value (typically a result type, such as Result or any other type), but you’re not doing anything with the result. To get rid of this warning, you have a few options depending on the specific situation: