Convert Objective C project to Xamarin - xamarin.ios

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. : )

Related

Xamarin.Forms or Xamarin.Android/Xamarin.IOS

I am new to Xamarin and not sure if chose Xamarin.Forms to create a application for ios and android platform has a problem or not.
The application has some features below:
The application will be able to running some code in background without launching application by user.
The application can be launched by a href link or a notification.
The application is able to launch a builtin Camera application, and receive picture data from Camera application.
Thanks,
Bo
The features you are mentioning can be done with both. Actually, anything you can do on Xamarin.iOS and Xamarin.Android can be done with Forms. Because Forms is only an abstraction layer for the UI which is installed by a NuGet package.
Now, having that said when to use Forms or when to use iOS/Android? It is mostly about UI. Are you going to do some advanced or platform specific stuff is is easier to implement that with the platform specific project.
If you UI will be the same in both platforms and mostly consists of some lists and input fields, then that is a very good candidate for a Forms project.
Notice how I said it is easier to do in the platform specific projects. Again here, you can do anything in Forms as well by the means of Custom Renderers, it is just a bit harder to do.
Ideally try it out yourself and see what suits you best.
In regard with your need to execute code in the background. This will be tricky and is very dependent on the platform that you're on. You will definitely have to write platform specific code for that for which you can use the DependencyService to abstract it to your shared code.
However like AlancLui mentioned executing code in the background isn't something that is easy to do on mobile. On iOS it is restricted to accessing location data or playing music, but still your app needs to be running (in the background). Android has something called Services for this, which makes it a bit easier.

Keep old VS project when migrating to new controls suite or not?

The project I’m working on is revamping an existing web portal.
Migration from the old controls (Infragistics) to a new suite (Telerik) is part of the revamp.
Would you recommend to keep the old Visual studio project and put the new controls in or starting a new VS project altogether?
It depends on how much you are using the third party controls and what portion of your site it is. If it is a small portion it may be better to continue with the existing project. If you have very heavy usage of the third party controls that you are removing on each page a rewrite may be easier.
If you are looking at possibly rewriting using a new project you may also want to consider the technology that you are using as well. For example if you were using ASP.NET Web Forms before, maybe it would make sense to use ASP.NET MVC now.
I believe the best answer to your question is that you need to evaluate what you are using and the amount of work that each approach will require and determine what is best for your specific scenario.

Converting ASP.NET MVC Project to ServiceStack.Razor

I have an existing ASP.NET MVC 4 project that already uses ServiceStack for REST services, and I just read all about ServiceStack.Razor and would love to move the entire project onto ServiceStack. Right now there is only one controller and view besides the built-in AccountController, and that controller just returns the view and the view is really just HTML; everything else is HTML/CSS/JS + ServiceStack REST.
The only real legacy constraint here is that this new app still needs to make use of SimpleMembership. At present I'm using a custom auth provider to authenticate against SimpleMembership and I would like to be able to continue to do so.
So, what would be the best recommended path to achieve this end? Can I get what I want by modifying my existing project by removing some references, or should I start fresh with an empty ASP.NET app and move the old stuff into it? Can I have SimpleMembership without introducing dependencies that will step all over ServiceStack.Razor?
If you were to start a new solution using only servicestack then MVC would never be there to get in the way.
I use servicestack.razor and love it. It is a lot simpler than MVC in my opinion. Moving everything to the new solution is pretty much going to be copy and paste since what you have works. I wouldn't hesitate and would make the move sooner than later. In the end you are not gaining anything from MVC. You only gain using servicestack. A big deal for me is self-hosting and eventually moving to mono.
This is a question that will have answers based off opinion so I suspect you will receive a few. I have not personally performed such a migration so this is only opinion but is how I would approach it. However, my recommended approach would be:
Retain the existing application/ Given its current simplicity, creating a new app and moving existing items into it seems unnecessary.
You should be able to use your existing auth solution via SimpleMembership and use ServiceStack.Razor. I would proceed as such however it does depend on what other ServiceStack features you may use which could cause conflict. A ServiceStack expert could comment more on this. Even if that did occur, you would be able to work around it relatively easy. At worst, implementing a simple handler would get around almost all issues from an authentication perspective.
Working with different razor engines is relatively easy to do and you can use/enable/disable existing or new build engines via a few lines of code. See here for an example. This should alleviate any concerns around dependencies of other built in or custom engines.
Consider looking at ASp.Net 4.5.1/VS 2013 (since your project is in early days) as it has enhanced membership support and is moving to a more "less dependent" model of components via the Owin stack Asp.Net 4.5.1 and VS 2013. Katana is a microsoft project that also provides some Owin based authentication components see here and here which you could use now and this would remove a lot of dependencies and enable you to migrate other framework with relative ease. Downside is that Katana/Owin has a little ramp up time/learning curve. Again, given your project is in its formative days I would recommend looking into Katana and the ASP.Net vNext stuff as this will make it easier for you and means you dont have to migrate to the new version once it is released.

Can existing .net application be converted to MonoDroid?

Can existing .net application(in C#) be converted to MonoDroid? or
Can we port an existing .NET web app to Android using MonoDroid?
MonoDroid is intended to allow you to develop applications in C# as opposed to Java; not as a means to drop an existing application into place.
You asked about a web app, but I'm assuming you mean an ASP.NET web app, which wouldn't map to the Android API, and couldn't simply be copied over. Even taking your HTML and dropping it into something like Titanium would still require a lot of JS tweaking to make it work.
I have a feeling you're looking at a re-write. Maybe if you can provide more details (is this an ASP.NET app, etc.), I could give a better answer.
Yes no problem. But it wouldn't be an automatic process, nor a particularly simple one. All the UI elements, persistence stuff and so on (the platform specific parts of your application) will need to be redone. Depending on your app, and how it is written, this may be a major part, or a relatively small one. The more corners that were cut originally, the more it will cost to port over.
In addition to Tom's answer, I would say it has some limitations(link 1 and link 2) . I blogged some other interesting moments here.
Here is a good example of cross-platform mobile application (monoDroid, monoTouch, WP7).

Is it possible to modify code generated by PhoneGap and how would this effect apps market application process?

Is it possible to modify/supplement code generated by PhoneGap to modify/add functionality? And how does this effect the application's likelihood of being accepted into the apps market?
The reason I am asking is because there are certain components of the desired iPhone application that we would like to have that we can not achieve with our converted CakePHP web application. These desired items include QR code scanning and augmented reality.
Yes, you can do that.
https://github.com/phonegap/phonegap-plugins
You can look there for already written (and validated) plugins.
If I remember correctly, a qrscanner plugin already exists.
Augmented reality it not really possible with phonegap. (At least not as far as I know) As you can't manipulate the camera view with phonegap.
Maby if you would write a plugin for it. But that would mean writing almost the whole application in objective-C.

Resources