Building Connichiwa from Source

Mario Schreiner edited this page Jan 13, 2015 · 14 revisions

If you want more control you can build the framework by yourself. This allows you to make changes to the framework's source code. This way, you can also include the framework into your project so that an update of the framework is automatically reflected in your project.

Prerequisites

When building, XCode will run a number of scripts that put everything into place. These scripts require the following things to be installed on your system:

Build the Connichiwa Framework

  1. Download Connichiwa from the Project Page or clone it and all submodules:

git clone https://github.com/BlackWolf/Connichiwa.git --recursive

  1. Open Connichiwa.xcodeproj
  2. Make sure "Connichiwa Fat Binary" is selected as the current target at the top
  3. Build the framework by pressing the start button or CMD+B

Include Connichiwa into your Project

To include the framework into your project we need to find it:

  1. In Xcode, go to the Project navigator (CMD+1)
  2. Open the Products folder. Right-click libConnichiwa.a and select Show in Finder. Here are all the files we need.
  3. Close the Connichiwa XCode project and open your own XCode project
  4. Drag Connichiwa.framework into the root of your Project. Check Copy items if needed
  5. Drag ConnichiwaResources.bundle into the Supporting Files folder of your project. Check Copy items if needed as well

Dependency: Add Nodelike

Nodelike is a must-have dependency of Connichiwa. It is part of the repository and was already built when you built the Connichiwa Fat Binary. Actually, it sits in the same folder as the files from the previous step and the files are called Nodelike.framework and NodelikeResources.bundle. Perform the same steps as with Connichiwa before.

Dependency: System Frameworks

As a last step, you need to include the necessary iOS Frameworks that Connichiwa depends on. For this, in your XCode project:

  1. Select the project at the top of your Project navigator
  2. Select the Build Phases tab
  3. Expand the Link Binary With Libraries phase
  4. Search for and add: JavaScriptCore.framework, CoreBluetooth.framework, CoreLocation.framework and MultipeerConnectivity.framework

Code Setup

In order to make everything work, your code should setup a single instance of CWWebApplication at some point:

self.webApp = [[CWWebApplication alloc] init];

You further need to forward applicationWillResignActive, applicationDidEnterBackground, applicationWillEnterForeground, applicationDidBecomeActive and applicationWillTerminate from your AppDelegate to CWWebApplication, for example:

- (void)applicationWillResignActive:(UIApplication *)application
{    
    [self.webApp applicationWillResignActive];
}

Then, finally, launch your Connichiwa application:

//Set the UIWebView that will be used if this device is used as a remote device
[self.webApp setRemoteWebView:self.remoteWebView];

//Set this device's name that will be sent to other devices
[self.webApp setDeviceName:[[UIDevice currentDevice] name]];

//Launch the web application at the given documentRoot and display it on the given UIWebView
//The document root should be the root of your web application (where your index.html lies)
//To set the document root to the root of your application, use [[NSBundle mainBundle] bundlePath]
[self.webApp launchWithDocumentRoot:documentRoot onWebview:self.webView];

Create a web application

You are ready to create a Connichiwa web application! Check out this page to find out how.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.