How to Fix Xcode: “Could Not Locate Device Support Files” Error

There may be a time when you try to run your app in your device and you get the following error: Could not locate device support files. This iPhone (Model …) is running iOS 13.4 (11E608c), which may not be supported by this version of Xcode. This issue usually happened when you are still developing your app using old version of Xcode but your device have already been upgraded to latest iOS version that is not supported by Xcode.
Read more →

How to Completely Remove Git Submodules Within a Repository

I found myself having to google this multiple times so I decide to write it here as a quick references for myself. Git submodules is a way for you to keep a git repository as a subdirectory of another git repository. It’s useful when you want to incorporate and keep track of external code or framework that your project depends on. It’s like a poor man’s version of npm or cocoapods.
Read more →

How to Connect to Google Cloud SQL with Cloud SQL Proxy

Cloud SQL Proxy is one of the ways to connect to your Cloud SQL instance. It’s useful if you want to securely connect to Cloud SQL from your local applications. Here are the steps to setup Cloud SQL Proxy on your local machines: 1. Download and Setup Cloud SQL Proxy (macOS) First of all you have to download it. I would recommend putting it at root (~/) folder. $~ cd ~/ $~ curl -o cloud_sql_proxy https://dl.
Read more →

What Does “x.(T)” Syntax Supposed to Mean in Go?

It is called type assertion. Here is how it looks like: str := value.(string) It gives you access to the interface’s concrete value. It asserts if the values stored in x is of type T and that x is not nil. Type assertion can also return two values: the concrete underlying value and a boolean value that check if the assertion is true. t, ok := x.(T) Here is some code examples for a much easier references.
Read more →

How to Create Multiple Screen Previews in SwiftUI

Today I learned that you can actually create multiple Xcode screen previews in SwiftUI. Assuming you have a SwiftUI View named ContentView. In the PreviewProvider, create a Group and init multiple ContentView() children inside of it. For example: struct ContentView_Previews: PreviewProvider { static var previews: some View { Group { ContentView() .previewDevice(PreviewDevice(rawValue: "iPhone 11")) .previewDisplayName("iPhone 11") // Optional ContentView() .previewDevice(PreviewDevice(rawValue: "iPhone 8")) .previewDisplayName("iPhone 8 Dark") .environment(.colorScheme, .dark) .environment(.sizeCategory, .accessibilityLarge) ContentView() .
Read more →

How to Use SwiftUI in UIKit Project

Did you know that SwiftUI can be use in UIKit project? To use SwiftUI in UIKit project, you have to make use of UIHostingViewController. It is a UIViewController that basically “host” a SwiftUI view. Assuming you have a SwiftUI View named SwiftUIView like so: let swiftUIView = SwiftUIView() Initializing it programmatically To initialize it programmatically, set the SwiftUI View as the rootView of the UIHostingController. let vc = UIHostingController(rootView: swiftUIView) self.
Read more →

How to Skip Long Running Test in Go

Here’s a quick tip on how to skip long running tests in Go. In your test function that you want to skip, add a t.Short() boolean check. For example: func TestLongRunning(t *testing.T) { if t.Short() { t.Skip("skip long running test") } // tests that will take a while to run … } Then when you run go test, simply provide a -short flag to skip the test. For example:
Read more →

How To Enable Go Fmt On Save In GoLand

One thing I miss when switching from VS Code to GoLand is the ability to auto-format the code with go fmt when saving the files. You need to navigate to Tools > Go Tools > Go Fmt Project to run it, or use the keyboard shortcut which is ⌥⇧⌘P. Still, this is something that you can easily forget to run every single time. Luckily, GoLand have built in file watchers that you can use to run go fmt every time there’s a file changes.
Read more →