What Xamarin is actually doing when using an iOS build host? - ios

I've noticed that there is a possibility in Xamarin to connect Visual Studio to an iOS build host.
What is this build host, is there any documentation about its architecture? What code does Xamarin.iOS send to this build host?
[Edit]
I want, as a personal project, make an iOS build host in Windows. I know that this can be achieved, and I'm sure that technically, I have all the needed tools to re-create one. My concerns is about the architecture of an original iOS build host. I want to know what is the communication between Xamarin and a iOS build host, and what is the build flow. And this is not documented.

A great explanation from here.
Xamarin.iOS compiles c# source code against a special subset of the
mono framework. This cut down version of the mono framework includes
additional libraries which allow access to iOS platform specific
features. The Xamarin.iOS compiler, smsc, takes source code and
compiles it into an intermediate language, ECMA CIL (common
intermediate language), however it does not produce ECMA ABI
compatible binaries unlike the normal mono compiler, gmcs or dmsc.
This means any 3rd party .Net libraries you want to include in your
application will need to be recompiled against the Xamarin.iOS subset
of the mono framework using smsc.
Once a Xamarin.iOS application has been compiled into CIL it needs to
be compiled again into native machine code that can run on an iOS
device. This process is carried out by the SDK tool ‘mtouch’, the
result of which is an application bundle that can be deployed to
either the iOS simulator or an actual iOS device, such as an iPhone or
iPad.
Due to restrictions placed by Apple, the iOS kernel will not allow
programs to generate code at runtime. This restriction has severe
implications for software systems that run inside a virtual machine
using just-in-time compilation. Just-in-time compilation takes the
intermediate code, for example mono CIL and compiles it at runtime
into machine code. This machine code is compatible for the device it
is running on at the time of execution.
To work around this restriction the mtouch tool compiles the CIL ahead
of time. A process that the mono team describe as AOT, ahead of time
compilation.
Some quotes from Xamarin docs:
Xamarin iOS for Visual Studio accomplishes an amazing feat: it lets
you create, build and debug iOS applications on a Windows computer
using the Visual Studio IDE. It cannot do this alone, however - iOS
applications cannot be created without Apple’s compiler, and they
cannot be deployed without Apple’s certificates and code-signing
tools. This means that your Xamarin iOS for Visual Studio installation
requires a connection to a networked Mac OS-X computer to perform
these tasks for you. Once configured, Xamarin’s tools will make the
process as seamless as possible.
Starting with Xamarin.iOS 4.0, there are two code generation backends
to Xamarin.iOS. The regular Mono code generation engine and one based
on the LLVM Optimizing Compiler. Each engine has its pros and cons.
Typically, during the development process, you will likely use the
Mono code generation engine as it will let you iterate quickly. For
release builds and AppStore deployment, you will want to switch to the
LLVM code generation engine.
Conclusion
So there is no way to make an iOS build host in Windows, as you said.
I guess Xamarin send to the build host the .Net assembly file (Orange part of the picture), to be compile into native ARM code using Apple llvm, and others tools like xcode-build to signed, link and build your application.

Related

Advantage of using visual studio on windows for iphone app development over native environment

I am reading a way to setup iphone application development environment on my windows. It states that “A network-accessible Mac set up with Apple's build tool” is required. My confusion is that, if i need to buy a mac machine and need to setup an envionment then why i will use windows and visual studio?
I am exploring why it is advantageous for me to build ios app in xamarin when i need to buy mac machine and install xcode. Why i will use xamarin when i am new to both C# and swift?
Please ignore my limited knowledge and flaw in question.
Using Xamarin to build apps
enables C# developers (there are millions of them) to leverage the language and framework they already know instead of learning a completely new one
allows them to share code between existing C# apps written for the web or desktop (very important in an Enterprise environment)
using Xamarin Forms, allows you to create a single codebase that targets multiple platforms (iOS, Android, UWP, etc)
if all you care about is iOS and you don't already know C#, then Xamarin may be of limited benefit to you

Is it possible to build static(.a) lib for iOS from visual studio 2013?

I have c code and i have not used any OS related calls. I had build static lib for windows using visual studio 2013. Now I want to build static lib for an iOS.
Is there any way do it without using Mac OS (XCode) ?
If not then what are those technical reasons (only because of compiler)? Because i read Static libraries are simply a collection of ordinary object files.
No, you will have to use a MAC for that.
Theoretically it is possible, for example by getting a version of gcc able to cross-compile to ARM architecture with the proper file format/ABI and setting up Visual Studio to use it for compilation. Not sure it would be worth it unless you just need to compile some library for several platforms and want to do it from one place.
There seem to be even tools for compiling whole applications for iOS on Windows, but having never used them cannot say how usable it would be.
So all in all, it is possible to compile the library, but probably not the simplest thing to do.
I doubt it very much... you are going to have to upgrade to a Mac.
By the way, you don't need to use the XCode integrated environment on the Mac, the compilation toolchain can be controlled from the command line, with make and other tools. So you could just get a Mac, install XCode there and mount a shared Windows file system and use putty to launch the tools from Windows via ssh.

How is Microsoft's iOS bridge IslandWood implemented?

Microsoft's newly announced Project Islandwood is interesting, as it allows Objective-C code written for iOS to be repurposed into a Universal Windows app.
I couldn't find any information on the details, so:
Has Microsoft effectively implemented an iOS subsystem in Windows 10?
Is it built on existing software (e.g. the old OpenStep source code) or built from scratch?
Are all the various iOS frameworks - Core Data, Core Text, Core Graphics, OpenGl, etc - implemented?
It allows writing Universal Windows Apps in Objective-C using the normal Windows Runtime along with an iOS API compat layer.
Visual Studio 2015 has a language projection for Objective-C so that you can compile Objective-C into a Windows app. The most common iOS API (CoreGraphics, CoreText, OpenGL, etc.) are provided .
You can import an Xcode project into Visual Studio and then compile it as a Windows app.
See the Project Islandwood site at http://aka.ms/islandwood and the Build talk Compiling Objective-C Using the Visual Studio 2015 C++ Code Generation that Builds Windows, SQL, .Net, and Office for details. Jim Radigan talks about the Objective C code generation in the first half. Salmaan Ahmed starts talking specifically about Project Islandwood about 33 minutes in.

How to use Xamarin in Visual Studio and Mac in the same time

I have just developed and android app using eclipse and now I want to develope its IOS version. I want to use Visual Studio and C# (I feel pretty much comfortable in these environments).
I read that, to achieve this I can use Xamarine. Everything is OK with configuring Xamarine on Visual Studio and using it in Visual Studio (I understood this part). I couldnt understant the "mac" part. They are saying that in order to build this app I need a mac running in my local network. Unfortunately I have no idea about Mac. Instead of using it in a local network, could I just install it in a Virtual Machine in windows and configure it on that way that I can see this mac from Visual Studio (How can I do this ?! :S).
I am sorry if my question is unclear but I would be greateful if any of you helps me understand these issues and help me develop my first IOS app in Visual Studio.
If you are going to do iOS development using Xamarin you need a Mac. A Mac will always be required to submit the app to the app store, and the way Xamarin works, you need to use a Mac to create the UI for iOS apps as well.
To get the most of the Xamarin, you ideally would develop your base code using Xamarin and C#, then build separate UI's for both Android and iOS. While your UIs are separate, your base core code is all the same for both apps.
It really does not make sense to have a native Android app all in Java, and then write the entire iOS app in C#. Either stick to completely native apps for both platforms, or use a wrapper like Xamarin for both.
Xamarin.iOS for Visual Studio makes it possible to develop iOS
applications on Windows, but you will still need a Mac in order to
compile and run the code.
Today, Xamarin.iOS integration in Visual Studio is focused on enabling
developers to develop in C#. Xamarin developers who write Xamarin.iOS
applications on Windows typically hand-code their user interfaces—or
they will need to switch to the Mac to use Xcode (or a beta version of
Xamarin’s new iOS Designer) to interactively design an iOS user
interface layout.
"or use a wrapper like Xamarin for both"
I have discovered the term wrapping is not correct for this product.
Unlike other products (Corona, Phonegap, Titanium, ...) that wrap up in a common, genericized library, Xamarin compiles at core level with no penalty. It is 100% native. All functionality in all it's supported platforms is 100% available and not watered down.
Wrappers can be faster to program in, in theory, but when you factor in the time you will spend looking for workarounds for the one piece of functionality that is available natively but not in your wrapper library. When you factor in the constant bugs because wrapping for 3 or more platforms is a constantly moving target and you can't count on it working from day to day.
When you factor all those things in, writing native in c# for all platforms is the better option.
I tried them all, and xamarin was my last choice as I was distracted chasing that perfect golden goose wrapper product.

OpenCV and Windows Store App using C# on a x64 platform

We are trying to integrate an OpenCV C++ Windows Runtime Component with a C# Windows Store App. We are currently working on Windows 8 (x64) platform and using Visual Studio 2012 with OpenCV 2.4.5. The actual aim is to detect faces in a C# Windows Store App working on x64 platform. We successfully set up OpenCV 2.4.5 with Visual Studio 2012 (x64 platform) and copied all the dll's of openCV to the "system32" folder so that we are able to build and run the openCV projects on the above mentioned platform.
Here are the problems faced by us:
We are successful in building the C++ Windows Runtime Component that contains the code for the face detection. But as soon as we integrate that with the Store App and try to make the object of the WinRT's class. It throws an exception.
But the whole project works fine if we comment the lines where we are trying to work on images and cascades.
Solely we are able to detect faces in Win32 Console application using the above code. But not able to do the this task.
I am giving the link to the project we are working on.
"https://www.dropbox.com/l/OkEZNMrazzFmV6UOj59KMb"
About the project:
1. "FaceDetectWinRT" is the C++ Windows Runtime Component project which contains "Class1.cpp" and "Class1.h" which contains the code for the face detection.
2. "FaceDetectStoreApp" is the C# Windows Store App project that has the reference to the above project and is declared as the "Start up" project.
3. There is a button in the " FaceDetectStoreApp " under "MainPage.xaml.cs" class which when clicked calls the " FaceDetectWinRT " project's function "face" which when working is expected to return the coordinate of the face that is detected.
I did the same thing with very similar results. I had success when deploying the WinRT app on an ARM device. You need to:
Include the OpenCV dlls in the C# project marked as "Content"
Don't forget the highgui dll. The objdetect dll depends on it.
Make sure you reference all the OpenCV .lib files, one per OpenCV dll
Switch the configuration to ARM in the Configuration Manager
Deploy to a device running ARM (i.e. the Surface) usually done through Remote Debugger
I have not yet had success running the app on a x86 device (i.e. the Surface Pro). I believe the problem is that the objdetect dll depends on the highgui dll. The ARM build of the highgui dll only depends on a few standard libraries. The x86 build depends on several additional libraries that aren't available for WinRT. I think you might be able to get it to work by building OpenCV for x86 without highgui. You can do this by setting the BUILD_opencv_highgui CMake variable to OFF.

Resources