In Xcode, you can enable multi-line cursor editing, which allows you to type or edit text at multiple locations simultaneously. This can be incredibly useful for making the same edit on several lines at once. Here’s how you can do it:
Comparing two strings in Swift is straightforward and can be done using the equality operator ==. This operator checks if two strings are exactly the same in terms of their characters and the order in which these characters appear.
In Swift, there are several ways to check for nil and assign a value to a variable, depending on the context and what you want to achieve. Here are some common approaches:
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:
In macOS 14.0 (Sonoma), Apple removed support for NSApp.sendAction to open the Settings view in your SwiftUI app. You now have to use SettingsLink like below:
Setting your app’s icon on the menu bar as a template makes it to adapt to light and dark modes automatically without you doing anything. To do this, you have to use this constructor of MenuBarExtra class.
With Xcode 13 and later, notarization via command-line has come down to these 2 basically:
Submitting your app to the Apple App Store is somewhat “straightforward”, however, if you want to export your app to list it on a 3rd party app store or sell it directly to your customers then you have to notarize your app.
You can ignore mouse events in a window/view by adding just a single line of code.
To use Presentify with any video conference apps, like Zoom, Teams, etc. you have to select the entire screen while sharing instead of a single app (or window) as shown below:
I always used an extension like Awesome Screenshot in Chrome to take screenshots of any website. However, you do not need an extension to capture a screenshot of a webpage.
I have been facing this issue lately with Brave browser and after some digging, I learned that it has something to do with GPUs. Disabling ‘Use hardware acceleration when available’ option resolved the issue for me.
If you go to Xcode > File > Swift Packages, you can see options to add a new Swift package, update them, reset caches, and resolve package versions. However, you do not see an option to remove a particular Swift package.
We know that Jekyll uses Liquid as its templating language. This means all your Liquid code will be executed by Jekyllby default.
You can open your app’s window on top of all other open application windows with the below code:
Before launching the window, just use the appropriate window level, and you’re done.
Reliance Jio has done a commendable job releasing a video conferencing app in a short time frame, however, it received criticisms that it copied pixel by pixel from Zoom. I actually agree with some of the criticisms but that’s for another blog post.