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!
Requirements
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!
Now:
- 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.
Magic happened
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 | |
---|---|---|---|---|
Hot Restart | 19.49s | 22.66s | 2.24s | 3.89s |
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.
Limitations
- 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
Conclusions
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! 🙂
Test
April 19, 2022 @ 4:45 am
i followed your steps but app was not installed in my device
Graeme
March 9, 2021 @ 12:31 am
Just so you know, Microsoft will be releasing a fix for this. Apparently something to do with new certificates issued by Apple: https://developercommunity.visualstudio.com/t/xamarin-forms-application-deployed-with-hot-restar/1338291?from=email
Marco Troncone
March 10, 2021 @ 5:47 pm
That’s a good news!
Thanks for the update
John Kessenich
March 12, 2021 @ 6:15 pm
Thank you all for posting your issues… I had this same issue and it was driving me crazy. Trying with different iOS devices, PCs, user accounts. All craziness. So glad MSFT is coming with an update
Graeme
February 23, 2021 @ 3:37 am
That’s the same error I’m getting. And like you I’m at my wits end and losing valuable hours.
It works if I deploy via a Macbook (iPhone connected by USB to Macbook), but that method is way too slow to be practical. And I’m worried that if I release the app to the Appstore that the same will happen to all my users.
The exact same process works perfectly well on another PC I have. So I originally thought it was something screwed up on my desktop PC, hence me installing Windows from scratch on a new HD. But same issue. Therefore logic tells me it must be a Visual Studio problem.
Tom Paronis
February 23, 2021 @ 5:32 pm
Well; here’s the latest from the Microsoft bots:
Could you try closing VS, deleting the content of “%LOCALAPPDATA%\Temp\Xamarin\HotRestart\Terminal”, and then trying to deploy your app once more?
Also if the issue persist, please share with us log file from this directory “%LOCALAPPDATA%\Xamarin\Logs\HotRestart”.
If this doesn’t work I don’t know what to do. Reinstalling VS, buying a Mac, etc. all seem like obscene solutions to what is most likely something trivial.
Marco Troncone
February 23, 2021 @ 5:57 pm
Consider that this method works only for testing. You still need a Mac to publish your app on the app store.
Tom Paronis
February 23, 2021 @ 6:26 pm
Can I publish using MacinCloud? Hopefully.
Marco Troncone
February 23, 2021 @ 6:59 pm
Yes, you can of course
Graeme
February 22, 2021 @ 10:00 am
I am getting the same issue and I’ve been deploying to a USB-connected iPhone for a year now. It all seemed to start with the latest version of VS (16.8.5). I have a case logged with Microsoft but they are very slow to deal with issues.
I even tried a complete re-install of Windows and VS on a new hard disk – same problem.
Tom Paronis
February 22, 2021 @ 6:14 pm
Well, I’m back at it and am getting the same #@%& error message for all 3 projects I’m trying. For simplicity’s sake I’m trying to solve the problem with an empty shell app. All apps open and then close instantly. Here is the message:
Launching app with args: /private/var/containers/Bundle/Application/4401E48B-885C-4E6A-AAC0-3A5BD8C03263/TestIPad.iOS.app -monodevelop-port 10000 -connection-mode usb
Starting Apple Service ‘com.apple.debugserver’…
Stopping Apple Service ‘com.apple.debugserver’…
An error occurred while trying to launch the app ‘TestIPad.iOS’. Details: Error running hotrestart: ‘An error occurred while disposing the ‘com.apple.debugserver’ service. Details: Value cannot be null.’. Command: ‘launch -u=00008020-0016481C2E01402E -i=com.companyname.TestIPad -p=10000 -d=”C:\Users\Thomas\AppData\Local\Xamarin\iOS\DeveloperDiskImages\14.4\DeveloperDiskImage.dmg” -w=True’
Please launch the application ‘TestIPad’ on the device ‘Thomas’s iPad’ to continue
Marco Troncone
February 22, 2021 @ 6:26 pm
Hi Tom,
Have you tried with an empty project? (Not a shell one), really an empty one.
When you create a new project instead of Shell, just select the blank template.
At least we can see if the empty project works for you. I did this test and it worked.
Let me know!
Thomas Eric Paronis
February 22, 2021 @ 7:28 pm
Yup. That’s exactly what I did. I actually deleted the ios directory on my Windows 10 machine, created a new certificate in the Apple developer portal and tried that. Same result but different error message:
There is no developer image available to mount on ‘Thomas’s iPad’ with version ‘14.4’, so the app ‘TepcoChordScaleFinder.iOS’ will not be launched automatically
Please launch the application ‘TepcoChordScaleFinder’ on the device ‘Thomas’s iPad’ to continue
I’m at the point where I’m willing to pay a Xamarin ios pro (if they get results) as this is costing me valuable development time.
Marco Troncone
February 22, 2021 @ 7:39 pm
The message you got is normal. It just says that you have to manually launch the app on the iOS device, then it will work normally. I did it and it worked ok.
Tom Paronis
February 12, 2021 @ 6:12 pm
Hello Marco and thanks for your help. 1.) Yes 2.) No but I will now 2.) I assume so because I just bought it but I’ll check. 3.) Yes 4.) That’s what I did. It turns out my iPad wasn’t completely set up so that may have had something to do with it but all I did was add credit card info. I’m going to tackle it again now. If I’m still beating my head against the wall I hope you’ll consider some screen sharing as this problem is a showstopper as far as getting my app in the Apple Store is concerned.
Valentyn Andrushko
February 12, 2021 @ 5:17 pm
hi Tom,
Which Iphone are you trying this on? I have an idea that this is somehow related to security and the phone just doesn’t allow this app to launch.
Tom Paronis
February 12, 2021 @ 5:27 pm
Thank you for the response Valentyn. I am using a brand new iPad, purchased last week. That would make sense but I don’t know how to set permissions on the iPad.
Tom Paronis
February 12, 2021 @ 4:44 pm
Hello Marco; thanks for your response. This is driving me bonkers. I followed your schema and VS recognizes my iPda and the apps build properly and are visible on the iPad. They flash open for a nanosecond and then close (not crashing as far as I can tell). Any assistance would be greatly appreciated.
Marco Troncone
February 12, 2021 @ 5:31 pm
I’ve just tested it following this guide on an empty project and it worked perfectly fine on my iPad.
Few things to check:
1) Have you installed the 64 bit version of iTunes?
2) Have you run iTunes just in case you have to accept something like privacy policy?
2) Do you have a 64 bit device?
3) Do you have a valid Apple account?
4) Try on an empty project. Maybe some libraries on your project cause problems (I had issues with Maps and Storyboards)
Tom Paronis
February 12, 2021 @ 6:34 pm
Same thing! The blank project runs just fine in UWP and when I compile for Apple it builds and deploys just fine but when I run it in debug mode it just flashes the big blue X and then closes. It must be some sort of permission….
Tom Paronis
February 12, 2021 @ 10:02 pm
I can state with some modest certainty that I found the problem but I’m not sure what to do about it. All my apps (3 of them) give me this message:
An error occurred while trying to launch the app ‘TestIPad.iOS’. Details: Error running hotrestart: ‘An error occurred while disposing the ‘com.apple.debugserver’ service. Details: Value cannot be null.’. Command: ‘launch -u=00008020-0016481C2E01402E -i=com.companyname.TestIPad -p=10000 -d=”C:\Users\Thomas\AppData\Local\Xamarin\iOS\DeveloperDiskImages\14.4\DeveloperDiskImage.dmg” -w=True’
My iPad is brand new. Should I be targeting a lower version of ios?
Valentyn Andrushko
February 12, 2021 @ 1:50 pm
Same here! I’ve done all the steps multiple times. From the dive log I only get useless information and it’s impossible to find anything about it on the internet…
NSError: 0x2824742a0; domain: RBSRequestErrorDomain; code: 5; reason: “Launch failed.
Marco Troncone
February 12, 2021 @ 1:52 pm
I’ve used it just fine but this evening I’ll test it again with the latest version of Visual studio and I’ll update the guide if necessary.
Tom Paronis
February 11, 2021 @ 10:59 pm
Hello. I followed your instructions and my apps (4 of them) flash for a nanosecond on my iPad then shut down. They never hit a breakpoint that I set in main.cs where the programs start. 2 of the apps are empty shell projects that I spun up with VS 2019 just for testing and they do the same thing; run for a nanosecond then exit. Any suggestions?
Thomas Eric Paronis
February 11, 2021 @ 12:21 am
This could be the info I’ve been looking for. I can run on simulators from Macincloud but have been unable to find a way to test on my iPad through them. Fingers crossed….going bonkers…
William P Thornton
November 16, 2020 @ 8:40 pm
How do you get the deploy check box to be enabled? When I got to the configuration manager the deploy for iPhone is greyed out. I enabled the Xamarin hot reload and restarted.
Scruff
November 3, 2020 @ 11:51 am
Hi, I tried to follow your steps, but Hot Restart doesn’t detect my iTunes installation.
The issue was reported in the link below, but still no answer from Xamarin team. Any suggestion?
https://developercommunity.visualstudio.com/content/problem/1218793/xamarin-hot-restart-doesnt-recognize-itunes-instal.html