Code sharing between MonoTouch and MonoForAndroid - xamarin.ios

What would be the best practice to share busines logic c# code between MonoTouch and Mono For Android projects?
Edited:
Initially, my question was about the physical file sharing:
What do you propose to use: network file sharing or some code
version control (git, svn)? In my case I am using two workstations -
Mac (MonoDevelop with MonoTouch) and PC (Visual Studio with
MonoDroid).
What about Solution/Project folder structure? In
"Blog Post: Xamarin Mobile World Congress 2012 Unofficial
Conference App Released!" example structure is quite confusing:
several solutions in one folder and then different platform projects in one
subfolder with different folder and project names. It can not be accomplished nativly
with IDE. Are they editing content of solution files and folder names manualy
outside of IDE environment?
And for projects of common code what kind of profile (template) to
use? Monotouch has several: Empty Project, MonoTouch Library
Project and MonoTouch Binding Projects? In Android i supose -
Android class library?

This is a very general question, but here are a few resources that may help you get started:
Video: Cross-platform Mobile Development
Blog Post: Shared Libraries For Windows Phone 7, MonoDroid and Beyond
Book: Mobile Development with C#
Blog Post: Xamarin Mobile World Congress 2012 Unofficial Conference App Released!
Edit (to answer your new questions)
The idea behind linking files across projects is that there is only one actual copy of the file, rather than having to manage multiple copies and keep them in sync yourself. The file will actually exist in just one project and be linked into the others, but when the projects are compiled it treats the file as if it were actually there.
I can't speak to exactly how they created their folder structure, but I know there have been many cases where I would manually edit project or solution files to get the folder structure I want, because there was no way to get what I wanted through the IDE alone. This really boils down to personal preference on how you want your folders to be structured.
In the end, what you need is a class library project for every platform you want to target. When going with the linked file approach, it's totally up to you where you put the physical files. One approach I use often is to actually create a standard .NET 4.0 class library, put the files in there, and then link them into my Mono for Android and MonoTouch class libraries. If all you care about is targeting iOS and Android, that may be more trouble than it's worth, and you can just let the files live in one project and link them into the other.

Disclaimer: I've got a particular Mvvm methodology that I use for sharing code across multi-platform projects...
Despite this, I genuinely don't believe in "one size fits all" frameworks - I think you need to be careful to pick an approach that best suits your project, your developers and your organisation.
With that said, some of the tools you can use within the Mono development approach are:
using Portable Class Libraries to share exactly the same code between platforms
using platform specific Class Libraries to share code between platforms, linking these using the Project Linker tool from Microsoft
using #define code within your class libraries to provide platform specific implementations of the projects (I personally try to avoid this approach, but it does often provide the quickest route to market)
using DI/IoC techniques to provide components for those occasions when platform specific implementations really are required.
using a assembly linking to provide IoC - e.g. this is what the Xamarin MobileAPI does
using server-based logic for genuine shared functionality - e.g. using REST or SOAP-XML services to implement logic
sharing tests (e.g. NUnit) between platforms to assure the quality of your logic
using shared code techniques - MVC (MonoCross) or MVVM (MonoMobile.Views or MvvmCross) for UI "controller" logic; MonoTouch.Dialog and MonoDroid.Dialog for "View-level" abstractions; CrossGraphics for UI "drawing"; SQLite.Net for database; etc.
I'm finding the MonoTouch, MonoDroid and the Microsoft tools provide real and signigicant benefits in developing cross platform code - but you do have to work and think to achieve this.

Related

Share Code Between 2 Projects in Android Studio

I have 2 apps, one for the clients and one for the managers. They are based on similar code (Classes, Layouts, Activities).
How do I "share" those files between the 2 apps? So if I change a shared class or a layout, the change would be visible in both apps. (So I make only ONE change, and not have to make two).
I work on Android Studio.
Thank you.
Here is an excellent discussion about sharing code: StackOverFlow #24592027 I'm doing a pair of apps for Wear and Phone products and the Android docs recommend to build both in the same project file as separate modules. Based on the comments in the link, I created a third Module called 'sharedcode' that I can then link between the Wear and Phone apps. This give me a common shared code module. I think the point is that your two apps will also need to be combined into a single project. Each app gets its own compilation target, but they then both share the same code.
Then go into the dependency settings (File | Project Structure; tab to Dependencies) and set each app to depend on the SharedCode module. Good luck.

How do I create transferable dll's for a specific website functionality?

VS2013 update 5, MVC5 using Areas
I have a stand-alone function programmed for a website. The functionality is a specific user interface to collect survey responses in a particular way. It has several controllers, a model and a group of views. The functionality is completely contained in an Area of the project, except for the Shared _Layout file that provides the main menu for consistency.
'Is it possible for me to' / 'how do I' compile this Area into a single or set of .dll file(s) that I could then add conveniently to other websites? I'm assuming creating something for transfer/download is very standard functionality. For example, I used Elmah.MVC for this site. What I want to do is pretty much create a package that can be downloaded in a similar way to how we integrate Elmah.MVC into a site. (Be certain I'm not talking about creating error logging software, I'm only using Elmah.MVC as an example of software that is easily integrated into other website applications.)
I've never compiled any website functionality into a .dll(s) for use elsewhere and would appreciate either some specific guidance, or perhaps what would be easier is to provide a link with a good step by step tutorial or explanation for how to do this. Most of what I've found on the web describes bits and pieces of doing this, but it's not enough for me to feel confident with it.
It seems to me there are a lot of 'moving parts' to taking a particular piece of an MVC application and turning it into something that is easily added to other projects.
A particular issue I don't quite grasp is the difference in downloaded packages between getting code and getting just the .dll(s). For instance, when I download an MVC5 site, I get controllers, models and views, but when I download Elmah I get a .dll and no code files. Also, I do understand the concept of transforms, but I'm just struggling right now with even getting from my programmed application into a 'package' regardless of the transforms that make it easy to integrate into another website.
These are just some of my questions I have about how to perform this particular process in developing deliverable and/or shareable software.
What you are looking to do is create a portable MVC Area project. A Portable Area is a set of reusable multi page functionality can be dropped into an application to provide rich functionality without having to custom build functionality that is literally the same in every application. An MVC Portable Area is really just a dll that contains the views, controllers, scripts, etc… needed to use in a website that is either a Web Forms website or an MVC website. A developer can use them for a reusable widget or a complete engine. I have actually used them for both. Here is a link with some basic info to get started. http://elegantcode.com/2012/04/06/mvc-portable-areas/

Convert Objective C project to Xamarin

We have an app written in Objective C. It uses CoreData, RestKit, about 10 viewcontrollers.
We would like to migrate it to Xamarin (so we can target Android and Windows).
I was hoping there was a way to bind the current code to a Xamarin solution and kind of rewrite features step by step within Xamarin (eg: replacing a viewcontroller at a time, and at the end replacing RestKit+CoreData, by SQLite + ServiceStack).
I am aware of the binding to Objective C option that they provide, however, it doesn't look to be the appropriate fit for this (way too complex, probably easier to rewrite the app from scratch).
Is there a way to migrate our current project to Xamarin so we can convert? or do we start from scratch?
Thanks.
Options:
Migrate full project - no;
Automatically create binding for libraries, rewrite business-code, UI-code - yes;
Rewrite from scratch using .Net/Mono classes - yes.
If code size is relatively small, you should rewrite the whole app. Moreover, thus you could have a chance to separate business-logic from UI code and tools libraries (RestKit, CoreData). In perspective, that code will be more reliable and cross-platformish.
This tool can help. It does Obj-c to C# translation (some manual cleanup required):
Automagical
Quite probably, a re-write, from scratch. One thing to keep in mind, if your back-end is .net.. and you are using DTO's.. like with AutoMapper from Entity Framework objects.. you'll be able to re-use those DTO objects on your mobile side with Xamarin. If you are using OData, I'm not sure if this is still a problem, but Xamarin studio wasn't generating OData service clients. So you had to generate them in Visual Studio, then take the generated client code and throw them into your Mobile projects.
sqllite-net is awesome. I've never had any problems with it.
https://github.com/praeclarum/sqlite-net
I currently have a project, with DTO Objects from an Azure WCF service, that I push directly down into SQLLite objects on IOS and Android with Xamarin. I use RestSharp, rather than Service Stack. I should probably go learn the difference.
If you are looking to use SQLCipher from the Component store, to encrypt your sqllite db locally on your device (Good advice to do so), you should be aware that there is an issue in android.. going to 2.2 or 2.3 with SQLCipher. Works for ICS and above though, if I remember right.
Just be careful on your security implementation for allowing clients to connect. I want to say.. don't take too much advice.. and don't take too little either. : )

How is your approach for creating your own set of controls aka own Extensions Library?

What is your approach for creating your own set of controls aka own Extensions Library? After a few years of Xpages development we have a huge set of controls that are general purpose for building UI, some web services etc. (Probably as most other developers.) When we start a new project now we have to copy the entire stuff from one database to new one which involves controls, jars, css, images, JAVA code ... and then you completely loose control to maintain some central version of this controls & codes, everything is scattered among several projects/databases and things get messy fast.
We have thought about creating our own extension library as described here
http://www-10.lotus.com/ldd/ddwiki.nsf/dx/Master_Table_of_Contents_for_XPages_Extensibility_APIs_Developer_Guide but there is not enough documentation for this topic and the entire development process is quite complicated (at least seems to me. I tried two times based on docs above going through eclipse plugin project -> feature project -> update site and still having some bugs around)
What is your experience and approach for creating and maintaining shared Xpages controls in your Domino environment? Is there some hidden feature we miss here that can help us?
Take a look at the XSP Starter Kit on OpenNTF and the XPages SDK to setup an eclipse environment for plugin development. You'll also want Eclipse IDE for RCP and RAP Developers. Install the starter kit and SDK into eclipse and you should be all set.
The starter kit is a sample plugin with all kinds of examples of phase listeners, components, etc. Once you want to deploy your plugin, create an update site from within eclipse and use the Update Site NSF available on your server install to place your update site. Once that's done, you can replicate that NSF to any other servers that may need the plugin.
For more information about the starter kit, take a look at this slide deck. There is also a github project for the starter kit. Documentation for the XPages SDK can be found here. And a video for setting up the SDK is available on youtube. Lastly, here's the documentation for setting up the update site NSF.
While we haven't gotten to that yet in XPages, our model for regular Notes design elements is to have a central template that contains the elements that are shared, with those specific design elements marked to inherit from that template. Sometimes, a database inherits design elements from two different central templates.
That way, those centrally controlled design elements remain the same in all databases.
I would recommend looking at some example's on github for how they have library/components setup. One of the more simpler examples that has just a single component built into a Library is Steve Pridemore's App Layout Extension...https://github.com/DominoDev, Another good one is Nathan Freeman's Starterkit: https://github.com/the-ntf/xspstarterkit. Hopefully these will help you get the file structure down on which files you need and how they work.

How to develop for MRP (Mythroad, platform for chinese mobile application)?

Hello dearest community
I just given a task to develop a mobile application for chinese mobile phone, Nexian NX-G920. At first, I think it can just run the J2ME application. But it didn't, it only support MRP application. Having read about it here : MRP, I think my best case is, if any, convert my *.JAR application into *.MRP. Is there any tool that can do it?
My Plan B is, to develop using specific MRP SDK. But that is just to costly, in term of effort to be use.
As far as I know there are only Java to C translators or Java bytecode to assembly translators like those listed in this question.
These include JCGO, Toba, gcj and llvm. However a Java to C translator or similar is only part of the solution because it would only help you if you were translating classes that didn't interact with Java libraries that are not part of the MRP platform. This is because MRP platform won't have the libraries you link to and will have different GUI and hardware API calls than J2ME.
The only SDK for MRP is the OpenSDK which you have already mentioned.
I think I've found one solution, but I have to use my C languages, not the plain J2ME as first I thought it will. Here is the SDK, Open SDK by Sky Mobi.
Haven't try it though, but I think this is one solution that fit the problem.
Sky-Mobi SDK is saved this archive on Wayback Machine
The Sky-Mobi is saved this page of site in the Internet Archive

Resources