Thursday, May 28, 2015

Random Storyboard Autolayout Situational Help

I'm just going to put random helpful links here that explain how to perform certain tasks in the xcode storyboard that might be helpful.

- Spreading out Items (like UIButtons) evenly. Helps to put them all in a separate UIView as well so you can move them all together.

- Simple Getting Started Tutorial with font sizing. Helps understand constraints that only work in certain devices as well as a nice font sizing section.

-How to unwind a segue with the push of a button. Frustrating if you don't know it. Explains how to setup and properly close a segue from any parent view controller. There is a programmatic version here.


Tuesday, May 26, 2015

Using CocoaPods and setting up Facebook SDK 4.1 in an xcode workspace in iOS8

Cocoapods are the new external framework. They are easy to setup, easy to update and easy to incorporate... one you have done it a few times. The most common external framework people use is the FacebookSDK. I will walk you through the basics of setting up a xcode workspace that incorporates the new facebookSDK which are now three parts; 'FBSDKCoreKit', 'FBSDKLoginKit', and 'FBSDKShareKit'.

I will probably go through some basic facebook usage in another post... maybe.

First you need to setup cocoapods. If you have not done so already, go into a terminal from your launchpad/utilities and type;
 $ sudo gem install cocoapods
This should use your integrated Ruby and setup cocoapods so you can use them whenever you want. It will most likely ask for your computer password and give you a warning but that is normal. Your mac should then  install a bunch of files and you are off to the races.

Next you will need to setup a work location. To be clean, create a new folder for your new app.
$ mkdir NewApp
$ cd NewApp
$ touch Podfile

You should be in your new app folder and in that folder should be an empty file called Podfile. This file is the instructions for cocoapods on what pods you want installed for this particular app. Since we want the app to have the new facebook pods installed, open up the Podfile in whichever prefered editor you want and copy this in;

source 'https://github.com/CocoaPods/Specs.git'
xcodeproj 'NewApp'
platform :ios, '7.0'
#Facebook Stuff
pod 'FBSDKCoreKit', '~> 4.1'
pod 'FBSDKLoginKit', '~> 4.1'
pod 'FBSDKShareKit', '~> 4.1'

What this does; The first line is to tell Cocoapods where on the internet you wish to look for the pods. The second line says what project you want your pods to work with. The third line says what target you want to setup. The lines with a # at the beginning are just comments and the last three lines are the actual facebook pods you wish to install into your workspace. Close this up and open up xcode.

In xcode, create a new project called NewApp (or whatever you decided to call it in the other areas) and put it in the same directory as the Podfile. Now go back to your terminal session and type;
$pod install

If everything was done correctly, you should see some green command lines installing the facebook pods and then the folder should also have a new xcworkspace file. Open up that file and you should see both your project and and 'Pods' in your workspace directory in xcode.

And you are done!

Why do this? Well, not only can you copy and paste this into all future projects but you can also update the pods at any point by just typing 'pod install' or 'pod update'. You can also create your own local pods and do the same thing. The way to do that is just specify a local directory for the pod you wish to incorporate;


#pod 'D2TSounds', :path => '/Users/yourname/Documents/CocoaPods/D2TSounds'

You might need to do a little setup for the local files but if you have several items that you use a lot, this will save you a lot of time in the long run.

Helpful links;
Cocoapods initial setup
Cocoapod pod link page
Facebook Login
Facebook Sharing
Facebook App Links
Facebook Graph API