While trying to follow the Mobile SDK install instructions I hit a sticking point, so here is a short tutorial with more detailed steps and information than are to be found in the Particle Docs as of 5/22/15.
First, download the SDK from the link on the Mobile SDK page. Put the folder in Documents, or wherever you keep example code.
Create a Swift project however you wish, or to just get started, File -> New -> New Project -> IOS -> Application -> Single View. Store it wherever you like. Desktop might be a good place as you’ll be opening the folder in a minute.
After you create the project, quit Xcode. Open the project folder on your desktop so you can keep it in view, and then launch Terminal.
From Terminal, do this…
1 Update Ruby by typing: sudo gem update --system
2 Install cocoapods by typing: sudo gem install cocoapods
3 Navigate terminal to the project directory by typing: cd yourDirectoryName
4 Confirm you are there by typing: pwd
5 Create the podfile by typing: pod init
6 Edit the file by typing: open -a Xcode Podfile
7 Replace all text with this line: pod ‘Spark-SDK’ then save this file and quit Xcode.
8 In Terminal type: pod install
You should see some confirmation messages. Pay attention to this one.
[!] Please close any current Xcode sessions and use yourProjectName.xcworkspace for this project from now on.
To clarify that message a bit, it means, Do not open your project from the Xcode menu targeting the Project folder, or by clicking on the .xcodeproj file in the project folder. To be save, launch the project by double clicking the .xcworkspace file in the project folder.
You will need to repeat steps 3 - 8 for each project you want to use the Mobile SDK in.
DO NOT USE TextEdit TO EDIT THE PODFILE. If you simply click on the Podfile to launch an editor, you will launch TextEdit and the quotes TextEdit uses are not compatible with pod install. It won’t complete the install and you will get an error message like this one.
Podfile file: undefined local variable or method `‘Spark’ for #Pod::Podfile:0x007fd68411bea0. Updating CocoaPods might fix the issue.
This message has nothing to do with updating cocoapods and that won’t resolve the problem. Like a missing semicolon five lines away breaking some other line, those bad quotes cause some sort of cocoapods error and you won’t be able to run pod install.
After a successful installation of pod install, your project directory will look like this:
Here is a very detailed post on cocoapods http://www.raywenderlich.com/64546/introduction-to-cocoapods-2
I hope that saves some of you the days it took me to find out why the Podfile would not install. I’ll be creating mobile apps in Swift, so according to cocoapods there are more steps required to use cocoapods in Swift. Ive posted another short tutorial on how to create and install the Bridging Header file required to use the Spark SDK from Swift.
There is no need to read further. This entry had been updated with all the useful information.