Is it possible to write shared libraries between iPhone, Android, Blackberry, Mac and Windows? - model-view-controller

I'm tasked with "porting" a few apps from a Windows environment to various mobile platforms and Mac as well.
I plan on writing MVC patterned apps in which I write as many controllers as I can in some sort of universal library, probably in C or C++. Then writing the views in various choice languages (Objective C, Java, .NET, whatever) for the target OSes.
I've never attempted anything like this before, so my questions are: Is it possible to write and compile one library that can be used on iPhone, Android, Blackberry, Windows and Mac? Is it even wise to try this?
I understand that certain native methods simply won't be available on each platform.

You can create a library whose source code is portable, assuming that you properly abstract away any platform-dependent calls. You can't, however, create such a library, compile it, then use it anywhere; you'll have to compile it for each platform.

Your should take a look at the Mono Project. http://www.mono-project.com
...more specifically at :
MonoTouch: To develop iPhone applications in .NET
MonoDroid (BETA): To develop Android applications in .NET
Mono plugin for MeeGo: To develop MeeGo applications in .NET
And you know that you can develop on Windows Mobile in .NET already.
I've haven't found anything related to BlackBerry yet.

There are services like Rhomobile and Appcelerator which will allow you to do this sort of cross compiling.
I've never used either however.

Related

Xamarin Cross Platform Development .net

We are developing a cross platform mobile application using Xamarin. I have noticed there are different ways of structuring your code using Shared code or PCL/.net standard.
I attempted to use .net standard and what i have found is that it doesn't include all the libraries such as using ado stuff , datatable/datasets using system.data. Or using system.net for example. Other functions have less overloads and seems that its a stripped version of .net to work across platforms. Is there any way to add this functionality or use a broader range of .net?
You are correct - .Net Standard and .Net Core are stripped down versions of the full .Net framework. They contain only features that can be used on all platforms (Mac, Android, iOS, Linux, Windows, etc.)
The full .Net framework only needs to work on Windows, so there are additional things that you can do based on the fact that there is less complexity in implementing and that the code base is more mature (cross platform is still pretty new by C# standards). To the best of my memory, System.Net should work if you have your references correct, but System.Data will not (or at least direct database access is not possible)
You can regain some functionality through NuGet packages, but it won't be the same as using WinForms or something like that...
My best advice would be to program against an API. You can use a web server that runs on the normal (full) .Net framework, and does all the heavy lifting using all the .Net features that you are accustomed to. Your Xamarin app would send and receive data from the API and basically provide a mobile front end for whatever you are doing. This approach makes sense for most apps anyway, and is generally what you would be doing anyway if you used Swift and Java to create separate iOS and Android apps.

Tutorials for Writing Common Code for use on Windows, OS X, iOS, and potentially Android

I'm looking at writing an application that I would like to use on Windows, OSX, and iOS (maybe pushing into Android if other people want to use it). I want to duplicate as little work as possible and I'm having a hard time finding information on the best way to do this.
From what I've found so far I can't use a framework like QT because iOS doesn't support QT so it looks like I'm stuck recreating the interface for each target. I'm looking at writing the business logic in C++ because it seems to be supported by the native tools (Visual Studio and xCode).
Has anyone had experience with a setup like this and if so can you point me towards a good reference for this kind of development?
Really there it not a lot of choice right now. Qt is certainly coming to iOS and WP7 so C++ is a good solid evolving platform.
However there is also the mono project which offers C# across platforms.
http://xamarin.com/monoforandroid
From my understanding, you write in c# and it compiles to the platforms preferred language.

MS Windows Programming advice for Mac/Unix developer

I have a few years of experience writing Unix command line tools (no GUI experience) in python, C and C++, and only recently crossed into the GUI world (Cocoa and IOS only). I've learned quite a bit of objective-C and am getting to understand how cocoa MVC works. However, one of the apps I am developing needs a Windows version and I was wondering what a good place to start would be given that I have absolutely no Windows development experience.
I was thinking about using Visual C++ 2010 Express as my development platform (because it's free and because I don't need to learn C++). My application is relatively simple, it will have only two windows and spend most of the time running in the background. It will however need to communicate with the OS (load dll's etc) and an online server (HTTP methods) and I'm not sure whether Visual C++ Express edition gives me access to the required API's. Would a Windows Forms application suffice? Am I going about this the wrong way? Do I need to learn C#? Any advice will be appreciated.
If you are already happy with proper c++, visual Studio C++ express should suit you fine. Given that you are not making a complicated GUI, you don't even need to dip into the managed code - C++ express allows you to create proper c++ console and GUI apps. You also don't need to install the platform SDK - it is part of VS C++ express.
Not being managed C++, you will be able to share source files between your various projects. managed c++, despite the c++ in the name, really is a different enough language that it will be annoying to work with if you simultaneously have to deal with iso C++.
--
Note: The native windows API is a C api, not a C++ framework. So it does not provide a rich set of classes in a coherent framework to deal with. On the other hand, while, large, it is actually quite simple to work with.
Also: Given that you are already familiar with Mac development, there is a LGPL (iirc) package called CFLite that builds on windows and that implements the C api that underlays the Objective-C Cocoa API.
If you use its abstratcions you can share a greater part of code between windows and Mac (and other platforms).
Other C++ IDE's you might want to consider:
Code::Blocks
QT Creator
both of which can be configured to use the MINGW port of GCC to windows.
you'll be better off with c++ than c# if you need more "low-level" stuff. Loading dlls (that is, libs) is simple (pragma comment lib...), as is pure HTTP transfer and communication.
So, VC++ with windows form will suffice, and it is "very c++".
You have access to all global APIs, and loading specific apis like http requires only two lines: one to include wininet header, and other lib (libs are actually "references" to dlls).
If you go the C++ Express way then you need to install Windows SDK separately, and set it up for Visual Studio to use it. And you can't use MFC.
I would however, suggest C#, because it feels like putting little toy bricks together. Easier to debug and maintain. Problem with C# is that it has so many library functions that you can not possibly know if what you want is already made to a function. But that's why we are here :-) If you feel that something you want to do should already exist then ask a question about it. One notable feature that C# lacks is zip archives (it has something similar, but not quite). For zips you can use public libraries, like SharpZipLib or DotNetZip.
If I were you, I wouldn't jump into a whole new API so quickly. Have you considered using Python on Windows? Most of the Python packages I've seen are also available for Windows, so you'll feel at home. And if you need some GUI, you can opt for wxPython, pyGTK or something similar.
For Windows specific things, you can always use ctypes. Especially if they're as simple as loading a DLL.
have you considered approaching Adobe AIR? it allows you to deploy on Mac, Linux, Windows, iOS, etc. communicating with and launching native processes has been possible since 2.0 and the the latest 2.5 SDK can target Android OS and TVs. with your experience you should be able to pick up ActionScript3 / MXML in no time.
additionally, there are a handful of free IDEs you can use with the Flex and AIR SDKs. or, if you're a student or low-income developer, you can get a free copy of Flash Builder 4 from Adobe: http://www.adobe.com/devnet-archive/flex/free/
edit: i believe deploying AIR applications on iPhone requires Flash Professional CS5, which includes the packager for iPhone options. at the same time, i've read that AIR and other cross-compilers for iOS are painfully slow, so it's perhaps best to develop natively in Objective-C for iOS.

Mac/Windows MIDI application programming language

What is the best programming language for writing MIDI-interactive musical application that would be run on MAC and on Windows?
I've written cross platform (Mac OS X and Windows) MIDI applications using C++. I used the RtMidi for MIDI I/O which was incredibly easy to get going (on every platform just it just worked out of the box). The advantage of C++ is that you can use native GUIs on each platform, but if you're not already into C++ I'd say a cross platform project is a pretty ambitious first project.
One possibility is .NET (C# or VB.Net), which runs on Windows (of course) and Mac (thanks to Mono). The downside is that .NET does not have any native support for MIDI, so you'd have to tap into two different native APIs for MIDI.
Java is another possibility, since it has a number of MIDI-supporting libraries available. Your UI is bound to look pretty terrible, though.
Python has substantial support for MIDI and runs on Mac and Win.
pygame.midi
PyPortMidi
PythonMIDI
pyrtmidi
For both mac and windows I would suggest Java. Midi is just a protocol so any language can do it. A good framework will speed things up a lot. Java has frameworks to work with Midi and other multimedia sources.
PortMidi is another popular cross-platform MIDI library. Qt is a nice cross-platform Framework, GUI and utility library.
It's an old thread, but nowdays you can use .NET. I mean official cross-platform .NET from Microsoft, not Mono. In this case I can recommend my library – DryWetMIDI. Its core part (working with MIDI files, processing MIDI data and so on) is cross-platform for any OS supported by .NET.
As for working with MIDI devices, this API supports Windows and macOS (that's what you need). Full documentation of the library availabale here: https://melanchall.github.io/drywetmidi. There you can find full API reference and help articles. For example, overview article on working with MIDI devices.
The library is distributed via NuGet package and can be installed via NuGet on both Windows and macOS.

How do you port a Cocoa/Mac application to Windows?

How do you port a Cocoa/Mac application to Windows? I mean how would you go about it? Assume the app was written with Objective-C and Cocoa, there's nothing fancy going on, no "engine" that could be factored out, etc.
Rewrite from scratch? I don't think there will be huge overlaps between the Mac and Windows codebases, right?
I have doubts about cocotron.
Its not clear from the cocotron website that cocotron is actually production ready yet. Id suspect that it would be possible to start new app development and use cocotron constantly to maintain and test windows builds on the go.
But to retrofit it into an existing project might be a much larger task. There are also no alternatives to cocotron - other than perhaps gnustep.
The practical approach to cross platform development involves developing the non gui components of your application, once, in C or C++. And then using a cross platform GUI library like QT - which is VERY good at generating and using native UI where possible or faking it where not. Please DO go to qt.nokia.com and download the latest build of QTCreator for windows and mac - See how the same QT application looks and feels very convincingly native on both platforms.
If QT doesn't provide a native enough solution, then you need to develop your GUI twice :- once in Cocoa, and once in Win32. The cocoa GUI would be in objective C of course, the Win32 GUI in C/C++.
Your non gui application code would - written in c++ - not be able to call Objective-C directly, but its not hard to write shim classes, implemented in .mm files - the provide a c++ interface, and wrap access to an objective c object or class.
You are also going to have to come up with an alternative to CoreData on windows - perhaps sqlite? Given that XCode has integrated support for the sqlite framework, and testing multiple code paths is, well, more work - perhaps dropping CoreData in favor of a common layer is a better approach?
The problem with Objective C is its very poor support on any platform that is not OS X. You can attempt to use the Cocotron, but I wouldn't consider it production ready yet.
For portability, a re-write is in order. With judicious use of standard C or C++ for the "core" of the application, you could still implement platform specific GUI code. If you don't like maintaining two GUIs, you can also try a toolkit such as Qt
Depending on which objects and framework you are using for your cocoa app, you might be able to get away with using gnustep, although the end result will probably look very weird to windows users, and the development environment might be a bit difficult to setup at first.
Are you aware of Cocotron? It looks like the project may have gone stale, but it's a good starting point anyway. It's a project to port Core APIs.
If your application is not cleanly separated (ie: a la MVC) then the only solution is a rewrite, I think.

Resources