Skip to content

The official repository for the new and improved StackMob iOS SDK

License

Notifications You must be signed in to change notification settings

dav/stackmob-ios-sdk

Repository files navigation

StackMob iOS SDK


Getting started

Add the StackMob SDK to your app

Using CocoaPods

CocoaPods is a dependency management tool for iOS apps. Using it you can easily express the external libraries (like StackMob) your app relies on and install them.

Create a new iOS project in Xcode. Here we've created an app named "MobFind".

	$ cd MobFind
	$ ls -F
	MobFind/  MobFind.xcodeproj/  MobFindTests//

We need to create a Podfile to contain our project's configuration for CocoaPods.

	$ touch Podfile
	$ open Podfile 

Your Podfile defines your app's dependencies on other libraries. Add StackMob to it.

	platform :ios
	pod 'StackMob', '1.0.0beta.2'

Now you can use CocoaPods to install your dependencies.

	$ pod install

Your now have a workspace containing your app's project and a project build by CocoaPods which will build a static library containing all of the dependencies listed in your Podfile.

	$ ls -F 
	MobFind/  MobFind.xcodeproj/  MobFind.xcworkspace/  MobFindTests/  Podfile  		Podfile.lock  Pods/

Open the new workspace and we can start developing using the StackMob library

	$ open MobFind.xcworkspace

Configure the StackMob SDK to use your StackMob account

Development

Debugging

There are many log statements embedded throughout the iOS SDK to help with debugging. The syntax is DLog(), defined in StackMob.h.

To turn this feature on, do the following:

  1. If you installed with Cocoapods, go to the build settings tab for the Pods project in your workspace. Instructions coming soon if you imported the Static Library.
  2. Search for the Preprocessor Macros build setting.
  3. Add SMDEBUG=1 to Debug.
  4. Build and run under the Debug configuration to get log statements from the SDK.
  5. To turn off, change the setting to SMDEBUG=0, or just remove it.

Testing


In order to test you must download the full source code: `git clone [email protected]:stackmob/stackmob-ios-sdk.git`.

Kiwi specs run just like OCUnit tests. In Xcode ⌘U will run all the tests for the currently selected scheme.

	describe(@"a public method or feature", ^{
		beforeEach(^{
			//set up
			[[someClass stubAndReturn:aResult] aMethod];
		});
		context(@"when some precondition exists", ^{
			beforeEach(^{
				//set the precondition
			});
			it(@"should have a specific behavior", ^{
				//verify the behavior
				[[aThing shouldNot] equal:someOtherThing];
			});
		    pending(@"should eventually have another behavior", ^{
		    	//pending specs will not execute and generate warnings
		    	[[[anObject should] receive] aMethodWith:anArgument];
		    	[anObject doStuff];
		    });
		    context(@"and another condition exists", ^{
		    	//...
		    });
		});
	});

Integration Tests

Unit tests do not make network requests against StackMob. The project includes a seperate target of integration tests to verify communication with the StackMob API.

  1. cp integration\ tests/StackMobCredentials.plist.example integration\ tests/StackMobCredentials.plist
  2. open integration\ tests/StackMobCredentials.plist
  3. Set the public for the StackMob account you want the tests to use.
  4. Create a schema (using the StackMob web console) called places. Add a geopoint field called location and set all Schema Permissions to Open.
  5. Create a schema (using the StackMob web console) called oauth2test. Add a string field called name and set all Schema Permissions to Allow to any logged in user.
  6. Test the "integration tests" scheme.

Optional: Test Custom Code Methods


By default, custom code tests are turned off. This is because they require you to have specific custom code methods uploaded for your application. To test custom code, do the following:
  1. Clone the custom code example repository: $ git clone [email protected]:stackmob/stackmob-customcode-example.git.
  2. From the root folder navigate to /java/src/main/java/com/stackmob/example/.
  3. Replace the contents of the /example folder with the files provided by stackmob-ios-sdk. They can be found by navigating from the root of your local stackmob-ios-sdk folder to /integration tests/CustomCodeFiles. The files are EntryPointExtender.java, HelloWorld.java, and HelloWorldParams.java.
  4. Naviagate back to the root of your local stackmob-customcode-example folder and execute the command $ mvn clean package.
  5. Go to your dashboard on stackmob.com and click on Manage Custom Code in the left sidebar.
  6. Upload new code and choose the .jar file located, from the root of your local stackmob-customcode-example folder, in /java/target/. It's the only .jar file there, and NOT the .one-jar.jar. You should get feedback from the browser that the methods hello_world and hello_world_params have successfully been uploaded - it reports the version and create date.
  7. Once you upload the custom code files you are ready to test. In Xcode, navigate to the file SMIntegrationTestHelpers.h in the folder Integration Tests. You will see #define TEST_CUSTOM_CODE 0. Just change that to a 1 and when you test the "integration tests" scheme you will run the custom code tests found in SMCusCodeReqIntegrationSpec.m.

Submitting pull requests

  1. Fork the repository on github and clone your fork.
  2. Create a topic branch: git checkout -b make_sdk_better.
  3. Write some tests for your change.
  4. Make the tests pass.
  5. Commit your changes.
  6. (Go to #2.)
  7. Make sure your topic branch is up to date with any changes other developers have added to master while you were working: git checkout master && git pull && git checkout - && git merge master (git rebase master for local branches if you prefer).
  8. Push your topic branch to your fork: git push origin make_sdk_better.
  9. Create a pull request on github asking StackMob to merge your topic branch into StackMob's master branch.

About

The official repository for the new and improved StackMob iOS SDK

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages