Using Xcode 11's Swift Package Manager in Your Project

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.

Keep Test Logic out of Production

I’m currently reading xUnit Test Patterns: Refactoring Test code and so far it’s been a great read. Here’s some advices on keeping the test logic out of production code. Don’t. Testing is about verifying the behavior of a system. If the system behaves differently when under test, then how can we be certain that the production code actually works? The production code should not contain any conditional statements of the if testing then sort.

Understanding LLDB Contexts in Xcode

Sometimes when debugging on Xcode with LLDB’s p or po, it will throw a syntax error at you and you might be wondering out why? You checked for any typos but everything seems to be correct. So what gives? Well, that’s because you might be using it in the wrong context. Here’s a quick rundown: When you stop in Objective-C code using breakpoint, LLDB will use Objective-C debugging context.

Useful XCTest Keyboard Shortcuts

Here are some helpful keyboard shortcuts that can help you run your unit tests much more quickly To run all tests: CMD + U To run whichever test your text caret (those blinking thing) is currently in: CTRL + Alt + CMD + U To run the last test that you have ran: CTRL + Alt + CMD + G

Using Go Dep to Manage Dependencies

dep is a dependency management tool for golang. If you have done any software development before, dep is similar to npm, pod or pip. In simple words, it is a package manager to manage your project’s third party libraries. How to install it There’s a few ways to install dep. Personally I prefer to install it with Homebrew $~ brew install dep Initializing a project with dep To initialize it in your go project, go to your project directory and run the following

How to Change Git Branch Name

A quick one. Here’s how to change your git branch name: If you want to rename of your current local branch: git branch -m new-branch-name If you want to change the name of a different local branch git branch -m old-branch new-branch-name That’s it. Bye.

Set Default Git Push Behaviour

I tend to forget that I have to specify the current branch name when pushing it to a remote. For example: $~ git push or like this $~ git push -u origin Either way, these commands tend to fail when I haven’t yet set the upstream branch. git will return an error similar like this: fatal: The current branch develop has no upstream branch. To push the current branch and set the remote as upstream, use git push --set-upstream origin <INSERT BRANCH NAME HERE> To avoid this, I have to set the upstream branch name explicitly first before pushing it to the remote repository.

zsh a Default Terminal Shell

I prefer zsh over bash as my everyday shell. Unfortunately zsh is not the default shell on macOS. To make it as a default shell for your machine, simply do the following: 1. Install zsh Make sure zsh is available on your system. If not, install it with brew. $~ brew install zsh $~ which zsh /usr/local/bin/zsh #output 2. Set zsh as default shell To set is as default shell, run the following in your terminal: