Debug Xamarin Bound iOS Library - xamarin.ios

Is there a way to debug the Objective C code of a static library bound to a Xamarin iOS project?
We have non-trivial code in the objective-c view controllers, that we would like to keep (using C# to provide the underlying data&handler). So debugging capabilities are highly necessary. Of course, I think in the long term the real/proper solution is to rewrite those controllers in C# (just keeping the .xib in xcode). We are far from there.
Thanks.

Related

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

Implementing dialogs from resource

I'm currently trying to port an application from owl to vcl.
In my old projekt-file I was able to load dialogs with something like
TBatchAcDialog(TWindow* parent) : TAPDialog(parent, BATCH_DIALOG)
However, using TTaskDialog instead it doesn't support the second argument.
I have found an explanation for the user interface designer that when rightclicking on a menu you can load the first declared menu from a rc-file.
However, I don't really know how to load those dialogs as dialogs in this IDE and linking them to my classes again.
Does anyone of you know about this or could link me to an article about a similar problem? I seem to have failed finding a proper solution although implementing rc-dialogs seems to be a common problem to me.
I'm currently trying to port an application from owl to vcl.
What is your exact goal? To be able to build the application with C++ Builder, or to use VCL instead of OWL?
If you want to use VCL for the dialogs, then you cannot port them, you need to rewrite all the UI from scratch, as VCL is very different from the standard Windows dialogs.
If you want just to build the application with C++ Builder, then you can do so by upgrading to OWLNext - it is an open-source upgrade for the OWL framework and works with the modern compilers like C++ Builder and Visual C++.
You can also use OWLNext for a gradual migration to VCL - as VCL and OWL can co-exist in the same application, so you can migrate your old OWL application to C++ Builder, write any new UI in VCL, and gradually rewrite the old UI in VCL - it might be easier and safer than rewriting the whole application with VCL.
C++Builder does not have any native functionality that wraps resource dialogs in classes. You have to set that up manually in your own code if you need it. Otherwise, just use Win32 API functions like CreateDialog() when working with resource dialogs, or else redesign your UI to make use of VCL TForm windows instead of resource dialogs.
TTaskDialog is not what you think it is. It is just a wrapper for the Win32 API TaskDialogIndirect() function (Vista and later only), which is not related to what you are attempting to accomplish.

Does MvvmCross support storyboards

I have been looking into using MvvmCross as our solution to cross platform development, with previous development being solely targeted at iOS. I have come to really like how storyboards encompass all the views together along with the flow between them.
I know Monotouch supports their usage with the storyboard projects which I have been able to work with, however I have not been able to find any reference/example to it being using with MvvmCross.
Is this currently supported? or can someone provide me some tips as to how I can get this setup. The initiation seems to be the issue as in the storyboard projects the FinishedLaunching method in the AppDelegate is usually empty
Is this currently supported?
I don't believe it is.
I've never used Storyboards to build anything other than a demo app - so I'm not an expert.
However, from what I know I think there are 3 problems that you would need to overcome.
1. Storyboards don't have code in FinishedLaunching
This is easy to solve I think - you can just add an override to FinishedLaunching which calls an MvvmCross Setup class in order to initialise IoC, Plugins, your App, etc.
2. MvvmCross vNext requires you to override the constructors to forms like
public DetailViewController (MvxShowViewModelRequest request) {
}
while Storyboards require the use of forms like:
public DetailViewController (IntPtr handle) {
}
Overcoming this is harder... but the good news is that it should be a lot easier in v3 - one of the stated aims of v3 is to somehow support storyboards - see http://slodge.blogspot.co.uk/2013/02/mvvmcross-v3.html
3. Clash of concepts
If you are using Storyboards, then the navigation logic is tied to the Storyboard and to the UIViewController.
If you are using MvvmCross, then the navigation logic is tied to the ViewModels.
Overcoming this would be relatively straight-forward - you can easily mix and match concepts - but you might find your ViewModels and Views feeling 'a bit odd' as a result.
Summary
Doing this today is possible but would require some hours of hacking.
A beta of v3 is due very soon (within weeks - just depends on my spare time). Once that is available I think you'd be able to get started much quicker.

Is it possible to reference native code from a monotouch C# library?

I'm trying to refactor some of the code of my monotouch app into a library (so I can use it in another app). Some of the code I want to move into the library is native (google analytics and facebook api native libraries), but I can't seem to find a way to get this to work, as you cannot link native code to monotouch libraries.
ie, this is what I'm trying to achieve:
[iPhoneApp facebookLib.a facebookWrapper.dll] ->
[iPhoneApp] [SharedLibrary facebookLib.a facebookWrapper.dll]
Am I missing something or is this not possible?
It seems to be possible, but perhaps I don't understand what you are trying to accomplish.
http://monotouch.net/Documentation/Linking_Native_Libraries
and here
Monotouch and native iOS code

Objective C interface and C# core

I am trying to port a C# window's application to ipad. I compiled everything on monotouch and it runs well. Now, I need to make an iPad user interface. If I implement the UI in Objective C, how hard is it to integrate it with my C# core? I saw monotouch can call objective C library, but I am doing the opposite direction. Any help is appreciate.
There's currently no support for you to execute the C# code from Objective-C. Your best bet is to just stay in MonoTouch and finish the iPad application with C#.
Working with UIKit in C# is at least as simple as it is with Obj-C, plus you get all the benefits of not having to deal with Memory allocation and the C# language and .NET framework. Developing UI code with lambda expressions and linq is a beatiful thing. Most obj-C sample code can be translated one-to-one to C# code, so almost every sample you find can be easily understood.
There is one possibility, you make your UI into a library, then you bind the library to C#, and then your C# code calls your Objective-C code to the UI, and this one in turn, calls back to C# for its business logic.
You are better off doing the UI directly in C# as well.

Resources