This project provides early access to advanced or experimental functionality. It may lack usability, completeness, documentation, and robustness, and may be outdated.
However, StrongLoop supports this project. Community users, please report bugs on GitHub.
For more information, see StrongLoop Labs.
Xamarin enables you to create iOS, Android, and Windows mobile client apps from a single C# codebase.
The LoopBack Xamarin SDK includes a tool that creates a Xamarin C# client API based on a LoopBack server backend API. The client API has a standard set of CRUD methods.
In addition, relation methods and custom remote methods in your LoopBack API are generated by the tool as a corresponding C# API.
These are documented in Xamarin client API.
There are currently some restrictions on support for custom remote methods.
For example, methods with with several return arguments or with multiple body-type parameters are not currently supported.
Also, the SDK doesn’t currently support custom remote methods that return a custom type not exposed in the API.
Non-public InformationSo, for example, if there’s an inner model called “Email” that hasn’t been defined as public in loopback’s model-config.json, you can’t write custom methods that return an Email model, simply because the
SDK is not privy to it, it doesn’t know there is such a model.</div>
Although called Xamarin SDK, this SDK is compatible with any C# application.
Get the SDK from GitHub: https://github.com/strongloop/loopback-sdk-xamarin.
$ git clone https://github.com/strongloop/loopback-sdk-xamarin.git
A sample application is at https://github.com/strongloop/loopback-example-xamarin.
The SDK has the following folders:
If you need only a functional SDK generator without source code or examples, you need only the folders lib, bin and the files in the root directory.
On Windows or MacOS:
$ cd loopback-sdk-xamarin
$ npm install
By default the SDK generator command will not be installed on your path, so you must either run it from the lbxamarinsdk-generator/bin
directory or provide the full path to it on the command line.
To create a Xamarin client based on a LoopBack API:
Create C# code for the SDK; for example:
$ cd bin
$ node lb-xm d:/your-server-app/server/server.js
Where d:/your-server-app/server/server.js is the full path to your LoopBack application main server script.
The above command shows an example of running the command directly from the lbxamarinsdk-generator/bin directory.
If you were running the command from another directory, you would instead use (for example):
$ node d:/loopback-sdk-xamarin/bin/lb-xm d:/your-server-app/server/server.js
You can also run the lb-xm command with options, to (for example) compile a DLL, add compatibility with Xamarin-Forms, and so on.
See the command reference below for more information.
Use the lb-xm command to generate a Loopback client in C# based on a LoopBack server API.
The general syntax (when running it in the lbxamarinsdk-generator/bin directory) is:
node lb-xm path-to-server-script [options]
By default the SDK generator command will not be installed on your path, so you must either run it from the
lbxamarinsdk-generator/bin directory or provide the full path to it on the command line.
Full absolute path to the LoopBack application main script.
In the standard project layout, <_app-dir_>/server/server.js. Required.
You can provide one or more of the following options:
Compile a dll containing the SDK
Ensure compatibility with Xamarin-Forms
Remove unsupported functions
Check if the SDK compiles successfully as C# code
For example, the following command generates a C# (.cs) file:
$ node lb-xm c:/testServer/server/server.js
The following command generates a compiled DLL:
$ node lb-xm c:/testServer/server/server.js dll
The command saves the result in the bin/output folder.