Swift: Unit Testing

I’ve recently stumbled upon severe issues, while trying to write a Unit Test, in Swift, that would access Swift Code that belongs to the main app.

Contrary to what almost everyone mentions, you should not import the Main App’s files into the Testing target.

Instead, this is what you should do:

  • Enable Defines Module in the main target.
  • Add an import at the top of the Unit Test, to make the main project visible.
  • Make sure that the classes to be tested are set to public.

Reference Here!

Fixing Violent OSX GPU Crashes

I’ve been experiencing, for months and months, quite violent OSX crashes, attributed to the GPU.

My awesome friend Dennis suggested me to try disabling Integrated <> Discrete GPU switching. And guess what? i’ve been crash free for almost two weeks.

I’m just documenting right here what has to be done, for future reference. Just uncheck this Energy Preference.
I’ve been told that the exact string for the checkmark might look different across the latest Yosemite releases, but the setting should still be lurking there:

Automatic Graphic Switching

P.s.: Again, thank you Dennis!!

Fish Shell

Installing Fish:

brew install fish

Displaying the branch name in the prompt:

Place the following script here: ~/.config/fish/config.fish

set fish_git_dirty_color red
set fish_git_not_dirty_color green

function parse_git_branch
  set -l branch (git branch 2> /dev/null | grep -e '\* ' | sed 's/^..\(.*\)/\1/')
  set -l git_diff (git diff)

  if test -n "$git_diff"
    echo (set_color $fish_git_dirty_color)$branch(set_color normal)
  else
    echo (set_color $fish_git_not_dirty_color)$branch(set_color normal)
  end
end

function fish_prompt
  if test -d .git
    printf '%s@%s %s%s%s:%s> ' (whoami) (hostname|cut -d . -f 1) (set_color $fish_color_cwd) (prompt_pwd) (set_color normal) (parse_git_branch)
  else
    printf '%s@%s %s%s%s> ' (whoami) (hostname|cut -d . -f 1) (set_color $fish_color_cwd) (prompt_pwd) (set_color normal)
  end
end

Reference here (Thanks for sharing the snippet!)