Making an iOS library or framework with C# and MonoTouch - c#

I'd like to look into the possibility of building a (cross-platform) library (no UI) using MonoTouch. From what I've seen so far, the Mono project looks like a very good candidate for such an endeavor.
Can MonoTouch compile libraries or frameworks for iOS?

It can compile them for use within MonoTouch apps for iOS, however don't expect it to compile into a native library that an obj-c application can then utilize...

checking here:
http://xamarin.com/monotouch
CROSS PLATFORM
Easily share code between iOS, Android and Windows Phone 7.
and then:
C# & .NET
Everything you love about .NET, including LINQ, Delegates and Events.
so apparently the answer is yes :)
also check this one: http://blog.xamarin.com/2011/10/12/monotouch-5-with-ios-5-support/

Related

Is C# used in iOS and Android projects created by VS2017?

I've recently started learning about Xamarin so please bear with me. I'm not sure if this is an obvious question
Creating a cross-platform mobile app in VS2017 will create 3 projects: Xamarin.Forms, iOS, Android.
So in my Xamarin.Forms project I was able to add a map to my Form, and now I can see the map in my Android emulator. That works great. I havent't touched the other two projects.
Now I have to add some functionality that's native of each platform, so I would need to go, for example, to the Android project to add the widgets, logic, etc.
Is C# used in these native projects or do I need to learn a new language?
I'm asking because Android Studio uses java and iOS uses Objective C, so I'm not sure if I need to learn these languages for cha
If you check the Microsoft website for Xamarin.Forms it answers your question then and there;
Xamarin.Forms expose a complete cross-platform UI toolkit for .NET developers. Build fully-native Android, iOS, and Universal Windows Platform apps using C# in Visual Studio.
But even F# is available as an option.
As far as your platform-specific question goes there is a whole separate guide that teaches you how and when you need platform specific code which can be found here
Is C# used in these native projects or do I need to learn a new language?
I'm asking because Android Studio uses java and iOS uses Objective C, so I'm not sure if I need to learn these languages.
Yes, that is the whole point for the Xamarin native and Xamarin.Forms framework that pure C#/F# developers can become mobile application developers without learning a new language.So existing .Net teams can execute mobile projects.
But in some cases, you might have to convert native Java and Objective-C code to C# so it's always better if you have a basic level of understanding in them.
I will suggest you read the Code Sharing Strategies available in Xamarin Forms before deciding which method do you wanna follow: I personally and the Community prefers using The .Net Standard methodology to share the code you can choose for yourself.
Good luck with your future endeavours and feel free to revert in case of further queries.
Yes, all Xamarin projects use C# (or F#). You do not need to use java or Obj-C/Swift, although there are ways to incorporate native libraries written in those languages into Xamarin projects.
Xamarin has a entire section of docs on how to incorporate platform specific behavior into a Xamarin Forms app.

Xamarin - Android - SQLite - Which C++ Library?

A bit of background...
SQLite is an open source C++ library compiled for multiple platforms. There are several commonly used C# wrappers for this library on several different platforms. Some of the common ones are:
https://github.com/praeclarum/sqlite-net.git
https://github.com/mattleibow/Mono.Data.Sqlite.git
https://github.com/oysteinkrog/SQLite.Net-PCL.git
Here is my one which is a stripped back fork from SQLite.Net-PCL.
https://github.com/MelbourneDeveloper/SQLite.Net.Standard.git
There are multiple versioning issues around SQLite on the different platforms, but recently, a big version issue came in to play on the Android platform. You can read about it here:
http://ericsink.com/entries/sqlite_android_n.html
According to Xamarin:
Note: Due to a change by Google, Android N will now only permit linking to NDK-provided native libraries. libsqlite.so is not an NDK-provided native library. Consequently, existing apps using e.g. Mono.Data.Sqlite.dll will crash when running on Android N. This may include other SQLite-using assemblies, not distributed with Xamarin.Android.
Xamarin.Android 7.0, which is part of Cycle 8, updates Mono.Data.Sqlite.dll to include a custom built version of libsqlite.so, named libsqlite3_xamarin.so.
https://developer.xamarin.com/releases/android/xamarin.android_7/xamarin.android_7.0/
So, my questions are: which Android C++ library should we be using for Android? Does the version depend on the version of the Android OS installed? Where do we get the C++ library from?
It sounds as though Google will only allow a customized version of the library. I guess this means that they will only accept signed libraries and the one compiled from Xamarin will be accepted. If this is the case, how do we get this library and package it up in a .NET Standard DLL, or include it in an Android app package?
I ask this question because this issue has been pointed out in my library here:
https://github.com/MelbourneDeveloper/SQLite.Net.Standard/issues/5
I feel like this is connected to the versioning issue. Anything that can shed some light on this would help. In my repo mentioned above, I have created a branches called Issues/5 which uses a different C++ library called libsqlite3_xamarin which seems to be bundled with Mono.Data.Sqlite but I still get the above issue when my phone goes to sleep.

DLL project should be of which type for cross platform use

We have one application for both C# .NET and Apple iPad. This application will perform similar functionalities. For this we have one protocol layer which we are thinking to keep as common code. For this we are thinking of creating a C++ dll for the protocol module so that it can be used across both C# and iPad. For creating a C++ dll, I have a basic question:
While creating a dll project, which option should we select? We can create a dll for MFC, Win32, ATL etc. What would be the best option for my requirement?
You should not use MFC as these are the Microsoft Foundation Classes not available on iOS anyway. Probably Win32 would be your best guess - but make sure not to include any non-standard Windows header files if you want to use the DLL in non-Windows environments.
I would recommend to frequently compile your file in both environments. You might also want to take a look at multi-platform libraries like boost if you need advanced functionality.
I recommend looking at Mono for building C# apps on both Windows and iOS.
If you want to target the iPad, you need to build for iOS, not Mac OS.
You cannot build dynamic link libraries for iOS, only static libraries. Note, there are equivalents to DLLs on iOS, but only Apple can build them (or you can build them yourself if your iPad is jailbroken, but this will disqualify your app from the AppStore).
iOS is not related to Windows in any way, so Win32 libraries will not run on iOS. Your generic 'protocol module' (if you mean low-level code that can interface to other devices over TCP/IP or similar) will need to have significant differences depending on which platform it is running upon.

Is it possible to use WPF on unix?

I heard about Mono project but only in regards to winforms. Will it work with WPF?
WPF under Mono does not exist.
At this point, no group in the Mono project has plans to implement Windows Presentation Foundation APIs as part of the project.
The mono team propose using Silverlight/Moonlight instead:
Silverlight implement a subset of the WPF APIs and is available on Windows, MacOS X and through our own open source effort Moonlight it is available on Linux and other Unix systems.
There is a library called Silverform SDK that aims to provide cross-platform WPF and Silverlight implementation.
The library is implemented in managed code and currently works with OpenTK and Unity3D as render backends. Major functionality, such as binding, layout, main controls and primitives, has already been implemented (check Unity web player demos here). Initially it has been focused on Unity3d render, while support for standalone Mono applications will be added as a separate build in the future.
Disclaimer: I am one of the developers of the library.

Is it possible to create a Mono bundle that includes WPF libraries?

I know WPF libraries arenĀ“t implemented by mono class library, however(as far as I know) the mono 2.6 runtime is fully compatible with the .NET 2.0/3.5 runtime, so if the WPF libraries only make PInvoke calls to windows api it is theoretically possible to run a wpf application on windows using the mono runtime.
The reason for wanting that is deploying a wpf application as a standalone executable for windows. Has anyone tried something like that before? If so, what were the results?
In short... No
At this point, the Mono project does not have plans to implement Windows Presentation Foundation APIs as part of the project
Mono will provide Moonlight support which, from what I understand, would also use a subset of XAML to create its UI (the same as Silverlight does) but there are legal complications involved. Such as, it's limited to non-microsoft and non-mac platforms.
If you want to find a list of open-source cross-platform alternatives to WPF/XAML I'm working to compile a list of viable alternatives.
Well I did give it a try with little success. I first checked with corflags if required dll-s are implemented in mixed mode (PresentationFramework, PresenationCore, WindowsBase, System.Xaml). They are all pure CIL implementations so that should work fine with mono. Next I installed mentioned DLLs into mono's GAC and tried running a very simple WPF application. This is what I got:
Assertion at mini-codegen.c:1186, condition `reginfo [sreg].born_in
0' not met
This application has requested the Runtime to terminate it in an
unusual way. Please contact the application's support team for more
information.
So although in theory this should all work, WPF is probably way to complex to run out of the box on mono, it would be cool if there was a pure CIL implementation of WPF that was compatabile with both mono and .NET Framework.
As much as I know, Mono does not support WPF.
Also, WPF uses graphics modules and interacts directly with the GPU. So I can't see how u can use WPF with no hidden pinvokes.
Sounds like you need to read about WPF architecture to better understand it.
http://msdn.microsoft.com/en-us/library/ms750441.aspx
Many pieces are missing in Mono and solely available in .NET. Therefore, your "theory" is not correct, and you cannot run WPF applications on Mono, even on Windows.
At MIX 2010 Miguel de Icaza said in his session that Mono isn't going to support WPF. Anything tangentially related to WPF-like support is only to provide what is needed for Moonlight.
Not fully, but..
You can use Moonlight 4 ( silverlight 4 ) in a desktop mode:-
https://github.com/inorton/MoonBase - MVVM helpers
https://github.com/inorton/XamlPreviewer - XamlPad clone

Categories