I don't have a physical Mac at the moment but I have a IPhone which I love! So how do I get my app running on my phone?
If you are like me this guide will help you get your Xamarin app to your IPhone (and your testers IPhones) without needing to buy a Mac!
Apps built using Xamarin look and feel native, because they are. Native User Interfaces Apps built using Xamarin contain standard, native user interface controls.
The following steps will walk you through creating your first blank Xamarin.Forms project on both Windows and Mac and building your first Xamarin app! These steps assume you have followed the relevant installation guide above and have all the tools required to. Xamarin.Mac exposes the complete macOS SDK for.NET developers to build native Mac applications using C#.
To be able to run Xamarin apps legally on your IPhone you will need a physical Mac you'll need to buy an access to a Mac in the cloud.
I can't find information on it but the reason for you needing a Mac to build iOS code is either:
But the fact is that you will need a Mac (legal or not) to build your iOS code so it will run on your phone.
I have been doing Xamarin development on and off since 2014 and dabbling in XCode/ objective-c for 1.5 years in 2011.
I have been doing some light teaching of Xamarin.Forms so I have the developing skills up to date (even though Xamarin is moving fast these days).
But in the last 2 years I have just been using the simulator and this year the LivePlayer in Visual Studio to develop the code.
Its been a long time since I connected a local Mac to Visual Studio to get the apps to my physical device.
So this weekend I wanted to try out some code on my IPhone. I can't use the LivePlayer since I am using the Prism framework and the LivePlayer doesn't work with 3rd party libraries.
And I didn't have a Mac to connect to! And I wasn't going to go out to buy one for this test (it might pay off in the long run though)
So what to do?
Since I had previously (two years ago) bought access to a MacInCloud I decided to do that again since I knew (so I thought) I had some leftover prepaid credits.
What I came to realize was that I had 28 left of my 30 build minutes in the Pay-As-You-Go plan but since I had not logged on in the last 60 days it was void and I need to buy more.
While looking at the plans I saw something new, VSTS Build Agent
So the next step was to connect MacInCloud to VSTS.
I managed to get this working by going over the 'Getting Started with the MacinCloud VSTS Build Agent Plan' guide. Somebody really should update this since some steps were not straight forward in my case.
Now I when I build an iOS app it will use my MacInCloud to do it.
So what I first thought of was to open up VSTS and check if I could use the build tasks there to build and deploy a app.
So I added a Xamarin.iOS build step and got this (overload).
I tried to config and run this build and got some errors and warnings so I decided to quit that route and try something else and easier to start up (AppCenter).
I know VSTS is very powerful because I work with it every day. But I just wanted to get my mobile app pipeline up and running fast. I really didn't want to spend more time than needed setting this up.
And maybe it wasn't so hard in VSTS but I didn't want to find out. I'll try it out next time.
Last year I used AppCenter for building and distributing Android apps so I knew (hoped) it would be a little easier to setup.
I'm not going to show you how to setup an app in AppCenter and hook it up to your repository since they do a good job of guiding you through the process.
So for distributed test (Ad-Hoc) apps you will need to set up the build configuration as following in AppCenter.
And then upload your provisioning profile and certificate (that I'm going to show you how to create).
This was the thing that took me the longest to do!
Everybody that has ever tried to get an app to the store or even to their testers know this. Articles like 'Why I hate iOS as a developer' are a testament of that.
This is totally normal when dealing with Apple but its still easier if you have a Mac!
Again this all would have been a breeze if I had had a Mac. Because then I could probably have used use the new Automatic provisioning to do deal with this all for me.
By combining Automatic provisioning with a Pay-As-You-Go subscription (paired to Visual Studio) I could have had these files.
Yes... Welcome to the jungle!
I tried to find out how to do this and just got lost fast.
I had allready found this article 'Where do I get the code signing files I need' but it told me nothing about how to create the these files on Windows.
To create a certificate in you Apple development portal you need a .CSR file. There are millions of examples on how to do it on a Mac when doing iOS mobile developement. But I did´t see any (there probably are) mentioning that.
So I googled 'creating a .csr file on windows' that led me to downloading the CSR creation program where I filled out the information about me and saved the .csr file.
Then I was able to choose 'App Store and Hoc' type of certificate in the Apple portal and upload the .CSR and create the certificate!
Next step is to create a provisioning profile for Ad Hoc. You will need a device setup under Devices where you need the UDID of your phone. You can get it by using e.g SuperUDIDI.
Download the provisioning profile (.mobileprovision). You'll need to upload it to AppCenter.
Then you need to download the certificate you created. Double click it and install on your computer under your user and then export the private key to a .pfx file (.pfx .p12).
Just that. Upload these two files to AppCenter and you should be ready to go.
Now you should be able to build the app and get a notification email where you are can just download and install the new version of the app.
There where few other problems I had getting this up and running. They where mostly easily fixed.
Open the Info.plist in Visual Studio and change the Bundle Identifier to the one you set in the Apple development portal.
I was so excited when the build got green! It said 'App distributed'. I waited for 20 minutes and no notification!
For some reason I (the only user anywhere) wasn't in the distribution group! So just make sure you are in the group set to get the updates.
I think I will look around and see if I can find a used older Mac Mini after this trial month. Lets see how many hours of build time I really need.
But at the moment I will be developing Xamarin.Forms using the simulator. And when I want/need to try the app on my IPhone I will just queue a build.
I'm sorry if some steps in here aren't as super detailed as I think they need to be.
The reason for it is that I thought setting this all up wouldn't be a problem. Specially after watching so many (obviously 'hello world') CI/CD videos.
I just didn't start taking notes on what I was doing until after I was c.a 30% done.
If I ever need to do this again or help somebody else to do it I'll add more details to this article.
But I really hope somebody learned something reading this.
Will it pay off in the long run just to buy a Mac Mini? Yes I think so. It would take c.a 1 year to pay up the Mac Mini vs. MacInCloud, so I'm thinking of getting one eventually.