Getting to know my mac better
As I have already mentioned in my previous post, I’m rather an unexperienced mac user. I own MacBook Air 11, which was necessary to build my iOS project while I was working with xamarin forms. What I like about my mac is its compact size and solid aluminium enclosure, which makes it a perfect notebook to travel with ;). The eleven inch version doesn’t have a memory card slot, though, that’s a pity. I took my macbook with me during my last trips to Asia and Australia, but I have to confess that I actually worked with Windows 7 installed on the mac with bootcamp :) Since I want to develop an iOS project in Xcode, the time has come to get my mac to know better…
In terms of blogging about my project’s progress, the first thing I thought I need to figure out, is how to make screenshots on mac. At work I use greenshot a lot, it is a light weight and free windows tool for capturing screenshots with the ability to draw arrows, annotate and highlight or obfuscate selected areas. I googled for greenshot mac and was really happy to discover that it’s available in App Store, yeah! But it’s not free anymore. It reminds me of a joke: Why there are no viruses for mac? Actually there are, but you have to pay for them :) So I looked for some kind of free alternative and found out that capturing selected region is already build in system under keyboard shortcut: cmd + shift + 4. Shift key is the one with up arrow :) If you want to save your whole screen press cmd + shift + 3. What I don’t like is that screenshots are saved on a desktop, so after a while I had a whole bunch of files there, it looked messy. I ofter hear opinions like Mac is very user friendly OS, so I was sure that this default setting can be easily changed somewhere in system preferences. Nope.
In order to change the default location for saving screenshots on your mac you have to:
- Open Finder and create a new folder for your files. I created Screens directory in my Documents folder.
- Start terminal by pressing cmd + space (this will show Spotlight search window), typing „terminal” and hitting enter.
- In terminal window type two commands:
defaults write com.apple.screencapture location ~/Documents/Screens killall SystemUIServer
That’s it. From now on your screenshots will be placed in your desired location:
Forget ctrl + c, ctrl + v
Every programmer once in a while does copy paste programming ;) However, you can’t control + c on mac. Forget it and get used to cmd key :) I can’t count how many times I „copied” files, example commands and text using the well known windows shortcut only to discover that after pressing ctrl + v nothing happened. The same goes for fast switching between bold and italics while writing wordpress posts. Basically the cmd key on mac does what ctrl key on windows. If your keyboard lacks delete key, press fn + backspace instead.
Setting Xcode to work with GitHub
Now it’s time to create my first iOS project and integrate it with GitHub. I want to make sure everything runs smoothly before I actually begin with my project development. I start Xcode, create new project, fill in required data and just before hitting „create” button I can see a checkbox Create git repository on My Mac.
It has to be checked. My GitHub repository for Magic hours project is placed under https://github.com/catqbat/magic-hours. I set it up just before enrolling for Get noticed contest. Important note: it has to be created without initialising with readme file *. So now it’s time to hook up those two together. In Source Control menu in Xcode you can see Configure Magic hours option.
I click it and switch to Remotes tab in the new window. I press the „plus” button in the bottom and choose Add Remote… then enter my data like this:
That’s basically it. I test if everything is OK by applying space in one of project’s files. The file has been checked out for me and now I can test committing my changes. From Source Control menu I choose Commit… and there’s a window popping out showing my changes:
Note there’s a checkbox on the bottom allowing me to push my change to the remote repository. I confirm and verify that my checkin is also visible on GitHub. Hurray! :)
* Yes, I did initialize my first GitHub repo with a readme file and was struggling with getting those to work together. Xcode was getting me errors like The local repository is out of date or Magic hours/master is not a valid branch to pull from. After reading this stackoverflow question I deleted my remote repo and created a new one ;)