-
Notifications
You must be signed in to change notification settings - Fork 59
Linking and using ObjectiveDDP
Special Note for 64 bit compilation: At this time, if you intend to run on a 64 bit device (or simulator) you must set Architectures equal to "Standard architectures (arm7, arm7s)" on your app's target and the Pods, Pods-ObjectiveDDP, Pods-SocketRocket targets (if you are using Pods). Do to this, go to the Project Settings, select the appropriate target(s) for your project and the Pods project and set the Architectures as required in the Architectures section of Build Settings.
Better support for 64 bit compilation is currently a feature on the roadmap.
For convenience, ObjectiveDDP is available via CocoaPods. Pods newbs may wish to reference the CocoaPods docs.
- Create a new iOS project with Xcode.
- Close Xcode.
- In the project's root, create a Podfile that looks something like this:
platform :ios, '7.0'
pod 'ObjectiveDDP', :git => 'git@github.com:boundsj/ObjectiveDDP.git', :branch => 'master'
Note: ObjectiveDDP depends on SocketRocket so it'll install that too on the next step.
4. Run pod install
, this will create a .xcworkspace for your project. Workspaces allow you to work on several projects together. This is how CocoaPods functions, if you don't like it then consider linking the source directly.
5. Open the workspace - you can do this by running `open .xcworkspace from the project root.
6. Double check that the workspace/project is functional by adding basic ObjectiveDDP header files and implementation to your app's AppDelegate.m file:
#import "AppDelegate.h"
#import <ObjectiveDDP/ObjectiveDDP.h>
#import <ObjectiveDDP/MeteorClient.h>
@implementation AppDelegate {
MeteorClient *mc;
ObjectiveDDP *ddp;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
mc = [[MeteorClient alloc] init];
// Testing against a local ddp server (i.e. meteor server)
ddp = [[ObjectiveDDP alloc] initWithURLString:@"ws://localhost:3000/websocket" delegate:mc];
mc.ddp = ddp;
// Testing against a remote ddp server (i.e. meteor server hosted on meteor.com)
//ddp = [[ObjectiveDDP alloc] initWithURLString:@"wss://<yoursubdomain>.meteor.com/websocket" delegate:mc];
[ddp connectWebSocket];
// Override point for customization after application launch.
return YES;
}
...
- In the future, you can run
pod update
to get new versions of ObjectiveDDP or pull down the develop branch after modifying your Podfile to do so.
Hate CocoaPod's guts? Try this approach.
- Create a new iOS project with Xcode.
- Somehow download a copy of the source, for example, here we will do a wget of an ObjectiveDDP release:
wget https://github.com/boundsj/ObjectiveDDP/archive/v0.1.5.tar.gz -O ObjDDP.tar.gz
tar -xvf ObjDDP.tar.gz
- You'll also need the SocketRocket source so download and extract it, too:
wget https://github.com/square/SocketRocket/archive/v0.3.1-beta2.tar.gz -O socketrocket.tar.gz
tar -xvf socketrocket.tar.gz
- Add the relevant source files to your Xcode project:
- Right click on project menu and choose "Add files to "
- Navigate to the folder where you extracted ObjectiveDDP source and choose the subfolder called ObjectiveDDP
- Click "Add" and keep the "Create groups for any added folders" checked
- Do the same thing for SocketRocket:
- Right click on project menu and choose "Add files to "
- Navigate to the folder where you extracted SocketRocket source and choose the subfolder called SocketRocket
- Click "Add" and keep the "Create groups for any added folders" checked
- You should now have two groups/folders in your project's directory tree, one for ObjDDP and one for SocketRocket.
- Update the Header Search Paths to consider globally the project root - open the project settings, build settings, edit the Header Search Paths and add $(SRCROOT) as a value and make it it "recursive"
- Also, in the project settings, build settings, set "Always Search User Paths" to be "Yes" (this allows for linking against the angle bracket <> header file imports like we would do if we were installing as a static lib via CocoaPods.
- Add the SocketRocket dependencies: libicucore.dylib, CFNetwork.framework, Security.framework, Foundation.framework
- You should now be able to modify your AppDelegate.m as noted above in the [with CocoaPods] (https://github.com/boundsj/ObjectiveDDP/wiki/Linking-and-using-ObjectiveDDP#with-cocoapods) section, step 6 and connect to a server.
-- ObjectiveDDP is a static library project - instructions forthcoming.