In my previous post, I had talked about the very basic commands of taco-cli. In this, we will see how we can use one of the most powerful features of Taco – the remote build. As of this writing, remote build is available only for iOS builds.

What is a remote build ?

A remote build in the context of hybrid apps development is building your iOS Cordova app on a remote MAC machine from a local Windows machine [for the very obvious reason that Mac OS X is required to build for the platform iOS].  This feature helps us a lot by allowing us to work on only windows machine and use the MAC for building as and when required. This is definitely a productivity booster as it avoids switching between multiple machines just for the build sake.

How does this work ?

Visual Studio TACO – Tools for Apache Cordova – have a few NPM libraries which facilitates this work for us. Note that, remote build works great from full blown Visual Studio 2015 TACO tools as well. For this post, I will be using taco-cli.

Below are the steps involved in creating the first remote build using taco-cli.

Setting up the Windows dev machine

Install taco-cli

npm install –g taco-cli

Run the below command for creating a new app from taco-cli  [For other commands available in taco-cli refer to my previous post]

 taco create myNewApp 

Setting up the MAC build machine

Install remote build npm module

 npm install –g remotebuild 

To get to know the commands that remotebuild supports

 remotebuild --help 

Commands:
start............... Starts the server
test ................ Run tests against remotebuild
certificates ........ Generates a new client SSL certificate for configuring a new secure connection
saveconfig.......... Saves the specified configuration to a file
help ................ Gets help for a command or a module
version ............. Displays the current remotebuild version

To check if the remotebuild configurations are fine, we can fire the below command.

 remotebuild test 

This will give us the sense of the setup we currently have with the MAC machine. While running this command, I encountered the below issue in my machine

Failed to fetch platform ios\nProbably this is either a connection problem, or platform spec is incorrect.\nCheck your connection and platform name/version/URL.\n

After a quite bit of research, I could figure out that the above error was happening while adding platform iOS to the test project, the command was trying to build. This can be overcome by running the below command:

Rm -rf ~/.cordova

After this, if you re run the remotebuild test command, that should get through fine. That indicates that our MAC machine is ready to act as remote build server. Now, its time to start up the server by running the below command

remotebuild start
Warning: No server modules selected. Defaulting to configuration "modules": {"taco-remote": { "mountPath": "cordova"} }
Remote build server listening on [https] port 3000
Please view/edit server configuration at /Users/z066157/.taco_home/RemoteBuild.config. You many need to run 'remotebuild saveconfig' to generate it. You will have to restart the server if you update the server configurations

One last step before we get into the windows machine to fire the build is to get the certificates and other connection configuration of our mac build machine. That is done by running the command


remotebuild certificates generate

Use the following information in Visual Studio under Tools, Options, Tools for Apache Cordova, Remote Agent Configuration to use this agent:

Enable remote iOS processing: True
Host: 6c4008bd6670
Port: 3000
Secure mode: True
Security PIN: 659050

Alternately to use the taco-cli run 'taco remote add PLATFORM' to configure the taco CLI to use this build server for the chosen platform, specifying

Host: 6c4008bd6670
Port: 3000
PIN: 659050
The security PIN is for one-time use and expires in 10 minutes. To generate additional PINs, use the following command:

remotebuild certificates generate

Now, that the build server is up and running, its time trigger the builds from windows machine.

taco remote add ios

The above command will prompt to feed in the details of the host, port and PIN number, once those are given properly, the connection will be established to the remote build server

On your remote machine’s terminal where the server is listening, we should start seeing logs written about the communication between MAC and Windows machines

GET /certs/659050 200 14.661 ms - 4178

To perform the actual build, trigger the below command from windows machine

taco build ios
...
** BUILD SUCCEEDED **
Command finished with error code 0: /Users/z066157/.taco_home/remote-builds/taco
-remote/builds/14946/cordovaApp/platforms/ios/cordova/build --debug
Done building 14946
Remote build log written to C:\Projects\SampleProjects\TacoSamples\firstTacoApp\
remote\ios\debug\build.log

The build logs will be posted to the windows machine from the remote machine.

On the remote machine, you should be seeing logs like this:

New build request submitted:
/build/tasks?command=build&vcordova=5.2.0&vcli=1.2.0&cfg=debug&platform=ios{"accept-language":"en","host":"6c4008bd6670:3000","connection":"close","transfer-encoding":"chunked"}
Downloading: taco-remote-lib@1.3.0
...
taco-remote-lib@1.3.0 downloaded and installed.
Build will be executed under: /Users/z066157/.taco_home/remote-builds/taco-remote/builds/14946
Saving build request payload to : /Users/z066157/.taco_home/remote-builds/taco-remote/builds/14946
Saved uploaded build to /Users/z066157/.taco_home/remote-builds/taco-remote/builds/14946/upload_14946.tgz
POST /cordova/build/tasks?command=build&vcordova=5.2.0&vcli=1.2.0&cfg=debug&platform=ios 202 21927.777 ms - 688
...
Done with current build. Checking for next build in queue.

That’s it, we just did our first remote build. Its as simple as that by running a few commands over the CLI.

Advertisements