Sharing code between a dot42 project and a mono desktop project - dot42

The idea is to share code between a desktop app using Mono and a dot42 app. So my question is: Is there any way to import a Portable Class Library or even a common library in a dot42 ? If not, is there any way to share code at all between them ?
Thanks.

A dot42 project is either a Visual Studio or SharpDevelop project. There is nothing preventing you to add a class library project to your solution consisting of the same C# source code that is used in your Mono project.
The .NET types are implemented on top of the Android API. For example, the .NET Dictionary class is implemented as a wrapper of java.util.Map and System.String as a wrapper of java.lang.String. In other words, we take the API from .NET but the implementation from Java. This is in contrast to Mono.
When you refer to .NET types and compile your dot42 project to an APK, the .NET types compile to a minimum amount of wrapper DEX code that invokes the Android framework. It therefore does not require an extra runtime and makes the APKs really small.
Here is the API reference of all .NET types that are currently supported (work in progress):
http://docs.dot42.com/Reference/NS.System
We are working on adding support for Portable Class Libraries.
Disclosure: I work at dot42

Related

Jni layer in Android

I am confused with Jni layer, NDk LAYER and the C/C++ source code components LAYER in the Android system.
When writing feature on Android based platform, introducing new custom components:
Can I refer any component written in c/C++ as NDK component ?
What is jni, a file which helps loading c/C++ shared objects ?
I have refered below link: It talks about how to use it but not exactly clarifies the naming convention used in Android platform.
https://developer.android.com/training/articles/perf-jni.html
Can someone please clarify the distinction between JNI,NDK and c/c++components?
Here's a worlflow.
You have a class named NativeGoodAlgorithm written in C/C++.
Write a wrapper for NativeGoodAlgorithm called NativeGoodAlgorithmInterface(JNI).
Write a Android.mk that links your native code and wrapper to generate a library(.so).
In Android, you load the generated library and write a Java class named GoodAlgorithm.
Then you call GoodAlgorithm wherever you want.
The Java Native Interface (JNI) is a way for you to call C++ code from your Java code, and the other way around.
The Native Development Kit (NDK) uses JNI to let you call C++ from an Android application.
You will most likely have to do some work to call existing C/C++ from an Android app using NDK. For example, you'd have to make sure your C/C++ ran on the ARM CPU on the phones you want to support. You'll have to define the data structures you want to pass back and forth between the two layers. I'm not sure what the limitations on OS-level calls are for native code running in an app, but there probably are some.

Build MonoTouch .NET libraries on Windows

I have a project of which I want to develop (and build/release to internal nuget) on Windows. There are multiple versions of my assembly (NET40, NET20, etc) that are created as part of my build process.
I have a new project that wishes to use my libraries on Mono and MonoTouch. Is it possible to build libraries on Windows that are ready to run on MonoTouch/MAC? Note that I do not wish to program against any MonoTouch.dll or Apple/iOS specific libraries. My assemblies are strictly .NET libraries.
Is changing my target framework to .NET 4.0 "Client Profile" sufficient to get support on Mono platforms (including MonoTouch/iOS)?
You can use portable class library's to do this. there is a great article on how to get this set up.
It is quite easy to get set up thanks to the great write up by #slodge on twitter.

Delivering an xcode framework with other dependencies

We are trying to release an iOS version of our library and are planning on delivering it as a compiled static framework. Using Xcode the framework and test app we have are compiling successfully and running fine.
The question is: What is the best way to deliver it?
Our library is dependent on some other opensource frameworks, and we also want to ship a test app with the framework to show how to actually use the library properly.
Should we use an umbrella framework? Apple suggests "Don't Create Umbrella Frameworks" (http://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPFrameworks/Concepts/CreationGuidelines.html)
Should we just deliver a zip that has our framework as well as all the frameworks we're dependent on and just tell the clients that they have to include those frameworks in their projects?
What's the best way to include the test app?
Thanks in advance!
Take a look at CocoaPods as a means to manage the dependencies (especially if those dependencies are open-source).
https://github.com/CocoaPods/CocoaPods
I would include the required frameworks with your compiled framework with the exception of frameworks that come standard with the iOS SDK. Most every framework is going to rely on Foundation and UIKit, those are frameworks that will most likely already be included. Anything else they won't have access to, include with your framework you send over.

Referencing a .net 4 library via COM in vs2005

I have a visual studio 2005 c++ project (that uses QT framework). I would like to reference and use a .net 4 library that I have via COM. I know that if I have a .net project (.net 2 or .net 3.5) in 2005, I cannot reference the .net 4 library but I am curious to know if I would have any issues trying to use it in a c++ project thru COM. I'm not at a point were I can create and test a proof-of-concept application yet so I was wondering if anyone else has tried this or know anything about it.
Thanks
Using COM is a fine way to get the CLR loaded so you can execute managed code. But you'll have to use COM programming techniques in the C++ code. Using Add Reference doesn't work, that's a option that's only available if you write managed code in the C++/CLI language.
One good way is to use the #import directive in your C++ code. That can load a type library and auto-generates smart pointer types and method wrappers that you can directly call in your C++ code. Generate the type library you need with the Tlbexp.exe utility or the Regasm.exe /tlb command line option. QT has built-in COM support as well, I don't know enough about it.

AS3 to C++ conversion – possible?

I built an iPad app in actionscript. A potential partner wants to pull my app into their app. They built their app natively using XCode. From what I understand, if my app had been built natively, I could simply export the code as a static library (.a file) for use by their app. Alas, I built mine in actionscript. So...
Is there a way to convert ActionScript 3 to C++?
Is one possible solution to do this conversion via AS3 to Haxe to C++?
Am I simply SOL and need to rebuild the game using XCode?
Thanks in advance.
Jason
You might consider the Tamarin project or Tamarin redux.
http://www-archive.mozilla.org/projects/tamarin/
It can be compiled in XCode as well. However, if your application is heavily depended on Flash runtime you have to implement all classes by yourself, because AVM contains only the basic AS3 classes.