Whilst not specific to Xamarin Forms development, at some point, having written your App, you will probably want to deploy it to an actual device. In my case I do not have an Android device (at least not anymore – a friend’s son lost his whilst at college, so I donated an old Android phone I had).
That leaves iOS deployment. Anyone who has looked into App development on iOS devices will know that it is completely locked down by Apple.The only official App deployment mechanism is via App store, and to get an App into App store requires, as a first step, that you become an Apple Developer for a fee of around $100 p/a. A bit OTT for learning and investigating.
However you can execute a limited deploy for Testing purposes to either a maximum of 100 users, in total per year using Apple’s Ad-Hoc Testing mechanism, or using the In House / Enterprise Deployment. I am hoping that I can use at least one of these mechanisms to deploy to my own devices.
In House / Enterprise Deployment
You can deploy to a device attached to your MAC without becoming an Apple Developer, but it is not easy. Steps:
First you need:
- Xcode 7 or higher
- iOS 9 or higher
- A free Apple ID
As you may gather, the fact you need Xcode means, without a developer licence, you can only deploy to an iOS device from PC/Laptop running Mac OS.
Once you have your Free Apple ID and XCode:
- Open Xcode
- Add your Apple ID account.
(Note: The role in your dialogue will probably state FREE rather than Account Holder)
Then connect your device to your Mac and create a new blank App project. In the Top menu bar select your device
(You may need to scroll up to see the full list of devices. )
Then Build and Run – well that’s the theory. Problem I had was I was using an old iPad, a very old iPad. Not going to use my new one am I just in case something goes wrong. The iOS on the iPad was 10.3, XCode was targeting 14.0. OK
Open up the projects xcodeproj file and adjust the target deployment.
The build and run failed because the default XCode project uses Swift, and the default blank app with Swift uses libraries that are not compatible with 10.3.
So, new XCode project, this time using Objective C, and using Storyboard Interface, as opposed to SwiftUI
Now Build and Run and it successfully deploys a Blank App to my iPad.
So, having successfully deployed a blank App, I went back to Xamarin and VS2019, and tried to deploy my Notes app.
- Open VS2019
- Preferences>Publishing>Apple Developer Accounts
- Add Account – Enter Apple Id and Password
- Account added – but no entry in the ‘Team” section
And the problem with not having an entry under the “Team” section is that when you attempt to deploy you will get the error message “Could not find any available provisioning profiles for iOS“
And from within VS2019 there is no way round this. There is a work around, but its cumbersome to say the least. What you have to do is first deploy an XCode project with the same Bundle Name as your project, then you can deploy your project from VS2019. Note: The initial deployment from VS2019 takes a long time, and I do mean a long time. Subsequent deployments are quite quick.
And one absolute gem… you can debug whilst running on the physical hardware. How neat is that.
End result though is that today Thursday 22 October 2020 I have successfully written, built and deployed a C# app to an iPad.
Code is available on GitHub at SteveD430/Notes