Automatic provisioning in Visual Studio for Mac now attempts to create and use wildcard App ID and provisioning profiles by default, instead of creating an App ID based on the Bundle Identifier specified in the Info.plist file.
-->Free provisioning allows Xamarin.iOS developers to deploy and test theirapps on iOS devices without being part of the Apple Developer Program.While simulator testing is valuable and convenient, it is also essential totest apps on physical iOS devices to verify that they function properlyunder real-world memory, storage, and network connectivity constraints.
To use free provisioning to deploy an app to a device:
- Use Xcode to create the necessary signing identity (developercertificate and private key) and provisioning profile (containing anexplicit App ID and the UDID of a connected iOS device).
- Use the signing identity and provisioning profile created by Xcode inVisual Studio for Mac or Visual Studio 2019 to deploy your Xamarin.iOSapplication.
Important
Automatic provisioningallows Visual Studio for Mac or Visual Studio 2019 to automatically setup a device for developer testing. However, automatic provisioning is notcompatible with free provisioning. In order to use automatic provisioning,you must have a paid Apple Developer Program account.
Requirements
To deploy your Xamarin.iOS applications to a device with free provisioning:
- The Apple ID being used must not be connected to the Apple Developer Program.
- Your Xamarin.iOS app must use an explicit App ID, not a wildcard App ID.
- The bundle identifier used in your Xamarin.iOS app must be unique and cannot have been used in another app previously. Any bundle identifier used with free provisioning cannot be re-used.
- If you have already distributed an app, you cannot deploy that app with free provisioning.
- If your app uses App Services, you will need to create a provisioning profile as detailed in the device provisioning guide.
Take a look at the Limitations section of this documentfor more information about limitations associated with free provisioning,and refer to the App distributionguides for more informationabout distributing iOS applications.
Testing on device with free provisioning
Follow these steps below to test your Xamarin.iOS app with free provisioning.
Use Xcode to create a signing identity and provisioning profile
If you do not have an Apple ID, create one.
Open Xcode and navigate to Xcode > Preferences.
Under Accounts, use the + button to add your existing Apple ID. It should look similar to the screenshot below:
Close Xcode preferences.
Plug in the iOS device to which you'd like to deploy your app.
In Xcode, create a new project. Choose File > New > Project and select Single View App.
In the new project dialog, set Team to the Apple ID that you just added. In the drop-down list, it should look similar to Your Name (Personal Team):
Once the new project has been created, choose an Xcode build scheme that targets your iOS device (rather than a simulator).
Open your app's project settings by selecting its top-level node in Xcode's Project Navigator.
Under General > Identity, make sure that the Bundle Identifierexactly matches your Xamarin.iOS app's bundle identifier.
Important
Xcode will only create a provisioning profile for an explicit AppID, and it must be identical to the App ID of your Xamarin.iOS app.If they differ, you will not be able to use free provisioning todeploy your Xamarin.iOS app.
Under Deployment Info, ensure that the deployment target matches or is lower than the version of iOS installed on your connected iOS device.
Under Signing, select Automatically manage signing and select your team from the drop-down list:
Xcode will automatically generate a provisioning profile and signing identity for you. You can view this by clicking on the information icon next to provisioning profile:
Tip
If there is a failure when Xcode attempts to generate a provisioningprofile, make sure that Xcode's currently-selected build schemetargets the connected iOS device rather than a simulator.
To test in Xcode, deploy the blank application to your device by clicking the run button.
Deploy your Xamarin.iOS app
Connect your iOS device to the Mac build host via USB or wirelessly.
In the Visual Studio for Mac Solution Pad, double-click on Info.plist.
In Signing, select Manual Provisioning.
Click the iOS Bundle Signing… button.
For Configuration, select Debug.
For Platform, select iPhone.
Select the Signing Identity created by Xcode.
Select the Provisioning Profile created by Xcode.
Tip
If you cannot see your signing identity or the correct provisioningprofile, you may need to restart Visual Studio for Mac.
Click OK to save and close the Project Options.
Select your iOS device and run the app.
Make sure that Visual Studio 2019 or Visual Studio 2017 has been paired to a Mac build host.
Connect your iOS device to the Mac build host via USB or wirelessly.
In the Visual Studio 2019 or Visual Studio 2017 Solution Explorer, right-click on your Xamarin.iOS project and select Properties.
Navigate to iOS Bundle Signing.
For Configuration, select Debug.
For Platform, select iPhone.
Select Manual Provisioning.
Select the Signing Identity created by Xcode.
Select the Provisioning Profile created by Xcode.
Tip
Xcode created this signing identity and provisioning profile andstored them on your Mac build host. They are accessible toVisual Studio 2019 or Visual Studio 2017 since it has been pairedto the Mac build host. If they are not listed, you may need to restartVisual Studio 2019 or Visual Studio 2017.
Save and close the project properties.
Select your iOS device and run the app.
Visual Studio
Limitations
Apple has imposed a number of limitations on when and how you can use free provisioning to run your application on an iOS device, ensuring that you can only deploy to your device:
- Access to iTunes Connect is limited and therefore services such as publishing to the App Store and TestFlight are unavailable to developers provisioning their applications freely. An Apple Developer Account (Enterprise or Personal) is required to distribute via Ad Hoc and In-House means.
- Provisioning profiles created with free provisioning will expire after one week, and signing identities will expire after one year.
- Since Xcode will only create provisioning profiles for explicit App IDs, you will need to follow the instructions above for every app that you wish to install.
- Provisioning for most application services is not possible with free provisioning. This includes Apple Pay, Game Center, iCloud, In-App Purchasing, Push Notifications, and Wallet. Apple provides a full list of capabilities in the Supported capabilities (iOS) guide. To provision your app for use with application services, visit the Working with capabilities guides.
Summary
Visual Studio For Mac Tutorial
This guide explored the advantages and limitations of using free provisioning to install applications on an iOS device. It provided a step-by-step walkthrough that demonstrated how to use free provisioning to install a Xamarin.iOS app.
Related links
I have created a PCL project, I host Mac with Visual Studio but when run iOS project, it gives error:
I tried to change in iOs building signing like below but nothing works for me.
Please help me solve this issue.
3 Answers
For iOS you need to register your app/device with Apple.
You will have to go to your Apple developer account and create a listing for your app and register the device you are testing on.
Also you will have to import your developer account into Xcode, this needs to be done because your development app also needs to be signed before it can be put on a physical device.
More information can be found in the Xamarin documentation.
The excerpt is this;
- Go to Xcode and add your Apple ID (Choose Xcode Menu >Preferences..., Click the Accounts tab, Click the Add (+) button and select Add Apple ID... from the popup menu)
- If you have an Apple ID that belongs to an Apple Developer Program, enter your Apple ID and password, and click the Add button.
Otherwise you can click the Join a Program button and a web browser will be opened where you can sign-up.
Now you need to add your device to Xcode.
- Connect the device to your Mac with a USB cable
- From the Windows menu select Devices
- Select the desired iOS device from the Devices list on the left side of the Devices Window
- Highlight the Identifier string and copy it to the clipboard
- Login to your Apple developer account
- Click the Certificates, Identifiers & Profiles link (on the right)
- Click on the Devices link
- Click the + button (top right)
- Provide a name for the new device and paste the device Identifier that we copied above into the UUID field
Now you have to pull the freshly created certificates to your Mac/Xcode.
- Stop Visual Studio/Xamarin Studio
- Start Xcode
- Choose Xcode Menu >Preferences...
- Click the Accounts tab
- Click the View Details... button
- Click the Refresh icon button in the lower left hand corner of the screen (the round arrow thingy)
- After the list of available Provisioning Profiles has been updated, click the Done button
- Exit Xcode (or leave it open if you like the sight..)
- Start Visual Studio/Xamarin Studio
Now I think you can start testing on your device. But if you need special iOS services (i.e. access to Game Center, iCloud, etc.) you will have to register your app as well. This is roughly a similar process as the one before this, but I will ahve to ask you to read the documentation on that or Google 'Provisioning for Application Services'. Before the post gets too long ;)
Note; this may change in the future because Apple has announced yesterday that sideloading (your own) apps (the thing you want to do here) will be free.So if you do not have a Apple developer account yet then you may want to wait a little while.
Gerald VersluisGerald VersluisI got its solution.I just edit my.csproj file by hand and remove the 'CodesignEntitlements' key. I found this solution from here and thank you Gerald Versluis for helping me through facing this problem.
Ajay SharmaAjay SharmaThe details from Gerald Versluis were helpful for me. The got me 90% of the way through the task. I was getting the same build error on Visual Studio 2015 with Mac Mini build host. The solution for me was to go back to Certificates, Identifiers & Profiles in https://developer.apple.com/account/ios/profile/createand ENSURE that I configured a profile.
here is an image
It was only after I did that did I see a record available for download in the Accounts modal windows of the XCode preferences, as shown below.
After I clicked 'Download All' THEN the build was successful in VS 2015.
Hope this helps someone who has followed Gerald's detailed steps above, since that got me 90% there. Thank you.
Also, keep this logic in mind: I was unable to build in VS until I was able to build succcessfully in Xamarin Studio Community.