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.
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.
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() .
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.
Similar like Cocoapods or Carthage, you can use Swift Package Manager to manage the dependencies in your Cocoa project.
With the latest Xcode 11, there is now a native support for Swift Package Manager for you to use it directly in your project.
Adding a new package To add a new package with Swift Package Manager is really easy. Go to the following Xcode’s menu:
File > Swift Packages > Add Package Dependency.