How to test your Xamarin.Forms iOS apps on your iPhone or iPad without a Mac
Wouldn’t be nice if you could try your Xamarin.Forms iOS apps on your Apple device without using a Mac? Yes it would. And now you can!
Follow me and I’ll show you how to deploy your Xamarin.Forms iOS app on you Iphone or iPad without using a Mac thank to Xamarin Hot Restart!
To use Xamarin Hot Restart you need:
- Visual Studio 2019 16.5 or higher
- iTunes (64-bit, installed on your PC)
- Apple Developer account and paid Apple Developer Program enrollment
- Your Xamarin.Forms app for iOS
Do you have everything?
Let’s start having fun
Remember that Xamarin Hot Reload is still in preview so you will need to enable this feature in your Visual Studio.
To do it, go to Tools > Options > Environment > Preview Features > Enable Xamarin Hot Restart.
Enable it and remember to restart Visual Studio to actually enable it!
- Set your iOS project as startup project
- Set the build configuration to Debug – Iphone
- In Configuration Manager enable “Deploy” for your iOS project
Don’t connect your iPhone/iPad yet (the first time you have to configure this, then it doesn’t matter anymore)
Select “Local Device” and launch your app.
Now follow the instructions and if needed download and install iTunes.
After iTunes is installed, connect your iPhone/iPad to your pc.
Now you need to insert your Apple credentials and then enable the “Automatic provisioning“. This last step is not necessary but trust me, it’s very handy and your machine will automatically setup everything to run the app on your device.
If everything worked (if not you can write here a comment and I’ll try to help you) you will see your device listed among the available devices (where “Local Device” was). Now you can run your app on your local Apple device connected to your pc.
After installing your app on your device, Visual Studio will show a popup telling you to manually run the app. Do it and the popup will disappear and you will be able to test your app on your device.
Xamarin Hot Restart
Not only you can test your Xamarin.iOS app without a Mac, you can now even change your code in real time. After you have done your changes, you just need to press the restart button (next to the stop button on Visual Studio). Visual Studio will compile your changes and quickly relaunch your app. According to Microsoft These are the timing with the new Hot Restart:
|Initial Build||Initial Deploy||Incremental Build||Incremental Deploy|
|w/o Hot Restart||163.38s||11.24s||41.40s||8.12s|
That’s quite impressive, and you have to consider that it’s just a preview so they can improve it.
- The Hot Restart works only on Xamarin.Forms and iOS devices, only on a Visual Studio (They will add compatibility for Visual Studio for Mac later).
- Only 64 bit devices are supported
- Storyboard and Xib files are not supported
- Static iOS libraries and frameworks are not supported (your app will crash)
- You still need a Mac to publish your app on the App Store
Xamarin Hot Reload is just a preview but it’s already a great tool to use. We can now try our Xamarin.Forms app on our Apple devices without using a Mac. I tried it with the app I’m currently working on right now and I’m very impressed. I cannot use storyboards (I don’t) and the app crashed if I open Maps (it’s integrated in the app I’m creating) but other than that it works very well and I’m very excited to try it.
Try it yourself and write in the comments what do you think. If you need any help, leave a comment and I’ll reply asap.
Happy Coding! 🙂