How can I test ios app i coded on Xamarin.Forms on Windows 10 using a real iPhone iOS device? - ios

Currently i don’t have apple developer account. I am developing on Xamarin.Forms in Visual Studio 2019 on Windows 10. I also have a mac device. I installed xcode on this mac. I run simulators on windows by the help of this mac connection. But i want to test my app on real iphone. How can i do this ?

You cannot run your development app on iOS device unless you have an Apple developer account. After you create the account, you need to create provisioning certificates for the device, download them. Only then you can run it

To be able to deploy on a physical iOS Device, you either need to have an Apple Developer Account or you can get a free provisioning profile from XCode (No Apple Developer Account required).
To get a free provisioning profile,
You have to (on your Mac):
Open XCode > Preferences and add your Apple ID in the Accounts section. You can then close the Preferences tab.
Create a new project and select Single View App. In the Team drop-down list, set it to the Apple Id you just added.
After the creation of the project, target your iOS device for building.
Open General > Identity and make sure the Bundle Identifier matches the one found in your info.plist directly from your Xamarin.iOS app.
Under Signing, select Automatically manage signing and select your Team.
You should now be able to see your provisioning profile when clicking the 🛈 symbol under Signing - Provisoning Profile and you can test the deployment by clicking the run button.
To deploy your app from Visual Studio:
Make sure your Visual Studio is paired to the Mac.
Connect your iOS Device to the Mac
Navigate to iOS Bundle Signing in Your iOS Project > Properties.
For Configuration, select Debug.
For Platform, select iPhone.
Select Manual Provisioning.
Select the provisioning profile and the signing identity created by XCode
You should now be able to run the app. (Don't forget to target your IPhone for Deployment)
For more info, visit (https://learn.microsoft.com/en-us/xamarin/ios/get-started/installation/device-provisioning/free-provisioning?tabs=windows)

Plug your phone into your computer using a USB to Lightning connector. Click Trust on your phone. Click on the simulator on XCode and choose your phone name. Click build. You will get an error on your phone saying untrusted developer. Go to settings on your phone, click general then profiles. Click on the only one there and click trust. Now you can open your app.

Related

In Xcode, how can I register a device to test on it, without having a paid Apple Developer account?

I am trying to test an app in a real device, using XCode 9.
In Xcode > General > "Automatically manage signing" I get this error: Failed to create provisioning profile. There are no devices registered in your account on the developer website. Plug in and select a device to have Xcode register it.
I have tried physically plugging in an iPod, an iPad and an iPhone. They all show up in iTunes, and also in XCode under Windows > "Devices and Simulators", but XCode simply doesn't register anything.
I also tried to go to the website to register the devices manually, but it seems I cannot even access this website without having a paid Apple developer account?
I do NOT have a paid Apple developer account, but I do have the Apple ID. I know that I can test in a real device without an account because in this page https://developer.apple.com/support/compare-memberships/ under Benefits and Resources the Sign in with Apple ID column has Test on Device checked.
Please, how can I solve this?
At the top of the Xcode window, from left to right, after the Run and the Stop buttons, there is another button which displays the tooltip "Set the active scheme" when you hover the mouse over it.
This button lets you choose a simulator. But once your device is plugged in it also let you select that device. Once you select your device, the problem disappears.
Note to those using Xcode to run code developed for Google's Flutter: You probably must also select Product > Run in Xcode, before you are able to go the device to trust the certificate, under the device's General > Device Management.
What I normally do when I test on a device is by selecting general device before I archive the build, and then after you follow the prompts after the build, choose install on a device.
If you are really set on just being able to run directly without archiving, make sure that you are signed in with your apple id (the only reason you would need to pay would be if you are submitting to the app store, so you don't have to worry about that) under accounts (XCode -> Preferences -> Accounts), and then replug your device.
And if that doesn't work, try following the instructions on this site: https://help.apple.com/developer-account/#/ under Registera Single Device.

Could not find any available provisioning profiles for iOS

We are developing a iOS shopping cart application in c# and visual studio 2017 for xamarin. I have an iPad Air iOS 10.3, when I try to publish to real device, I am getting the following error message: "Could not find any available provisioning profiles for iOS", I have tried to restart my Mac - without result. Give me any suggestion to resolve this issue?
In Visual Studio for OSX, go to Visual Studio Community > Preferences > Publishing > Apple Developer Account and click to + button to sign in and add your developer account. In theory after that automatic provisioning should work.
In Visual Studio for Windows, go to Tools > Options > Xamarin > Apple Accounts, you will get a prompt to install FastLane before your Apple ID will show up under Automatic Provisioning.
You must create a provisioning profile. Search on Google, how to do it.
But, the secret is: when you create a provisioning profile, you must associate an App ID to this profile, like: "com.companyname.*".
When you create your app in visual studio, you must set in the INFO.PLIST file on IOS PROJECT, the Bundle Identifier to "com.companyname.myapp1" or anything else.
If your Bundle Identifier has a name like "com.myapp.app1", you will get this error: Could not find any available provisioning profiles for iOS, because your profile accept only apps with the names started with com.companyname and you are using a appname different.
For those who just want to deploy/test their app on a real device with "Free provisionning" follow this official guide.
To sum it up :
Create an apple id
Add the previously created apple id to XCode in order to add a provisioning profile.
Create a new empty iOS app with the bundle identifier equals to the one of your Xamarin app (you can find it in Info.plist of your Xamarin.iOS project).
Ensure that your empty iOS app could be deployed, by running it from XCode on your device with your free provisioning profile.
In Visual Studio open Info.plist and click on Bundle Signing Options..., in Signing identity chose Developper automatic and Automatic in Provisioning profile.
Run your Xamarin.iOS app on your device.
You can see what was wrong with your provisioning profile in xCode. Also this procedure will update Provisioning profiles, Certificates, App Ids:
Go to xCode, create blank iOS application, type the same Bundle Identifier, that you had in Visual Studio.
On the same page uncheck "Automatically manage signing".
In Signing (Debug) click on Provisioning profile. You will see Eligible and Ineligible provisioning profiles. You can select each of them and if one is Ineligible, then errors will be shown below. After that you can fix them.
After that you can go to Visual Studio for Mac and create the same project with the same bundle id and check you profile in Project -> Options -> iOS Bundle Signing -> Provisioning profile
After that you will find your Provisioning profile in Visual Studio on Windows
I suggest you read this documentation to learn more about iOS provisioning.
What you want is called automatic provisioning though. It takes care of all the complex things about provisioning for you and just deploys the app.
Visual Studio on Windows has the automatic provisioning feature in preview (called 15.7) right now (preview 3): https://learn.microsoft.com/en-us/visualstudio/releasenotes/vs2017-preview-relnotes#xamarin-provisioning.
I recommend you try that, it should help you automatically add your iPad to the relevant provisioning profile.
Visual Studio for Mac has had automatic provisioning for a couple releases now.
Note: you do need an Apple Developer account to deploy on device (it can be a free developer account).
Unbelievable but true...
To enable the interface, I first had to login with my Apple account under:
https://itunesconnect.apple.com
and
https://appleid.apple.com
and agree the new privacy agreement from Apple. There isn't any error message that points you in this direction ("you first have to agree...").
After doing that, I was able to use the automatic provisioning in VS2017 and connect to the Mac.
All of these answers are right.
There are many reasons the creation of the provisioning profile certs bundle can fail. The one I dont see listed here is referenced in (Apple developer account teams not showing up on VS Mac)
Only XCode can set up the provisioning for you using the free apple dev Id. You need to create a dummy project with the same Bundle Name and Bundle Identifier. Build it in XCode and have XCode create the certs for you.
Only once i did that (on the paired Mac) did it start actually building my iOS target in Windows VS 2017
How did I have to solve this?
First background
I have already provisioning profile for app we are building but every once in a while I have to create a small POC app to prove something. And often I have to use that small app on real provisioned device.
But I was not even able to see my device for that small POC app in the dropdown showing available devices. Only the app I am building with my team will show.
Solution
To resolve this, I had to do
In my POC app > Info.plist, make sure your Bundle Identifier is same as for the app that you can deploy to your device
At the same location, under Signing, select "Automatic Provisioning" and you should see your Apple ID show. In Team dropdown, select your team
After this, my device showed, I was able to build and deploy to it and the error was gone.
I have tried all the above-mentioned approaches but didn't work. I was using Manual provisioning.
To identify why it's not showing in VS, I have:
Opened the Xamarin.ios project in Xcode.
Under Settings > Manual provisioning profile,> Selected the appropriate certificate (Note: It should be installed before it appears in the list).
It showed me an error, which said "Selected provisioning doesn't match with the distribution certificate in the keychain"
When I logged into developer.apple.com - I have found a new distribution certificate.
I had to regenerate the provisioning profile with the new distribution certificate (selected) and installed it.
After installing the error went away.
Also, In the Visual Studio's drop-down list the provisioning profile started to appear.
I agree with Meekohi & Vincent Dondain who have recommended choosing Automatic Provisioning, as it's a better option if one is not facing any issues with certifications or profiles as it takes care of everything. However, using the latest Visual Studio for Mac is preferable.
just hit the same problem. didn't find solution in this thread that i came to.
Xamarin app, visual studio for mac . manual signing
didn't use it for few months.
works good on emulator but can't deploy to device for debugging
after reading this thread went to developer.apple.com and found, that my developer profile expired a month ago.
create new provisioning profile
visual studio for mac-preferences-apple developers account-details-download manual profiles
info.plist-bundle signing options-choose correct identity and profile
Answer ( I have had this issue 2 times by switching MACS & adding new applciations )
Issue: Profile not showing up in dropdown below ( Automatic Distribution or Distribution )
As long as you are sure your info.plist is ok and have matching ( com.companyname.something ) & your CERTS are in Keychain then this is what is what cleared it up for me 2 TIMES !
** This seems to be some sort of refresh issue ( where a old profile is cached OR newer profile/bundle not loading in MAC )
[ I use VS on Windows and connect to MAC ]
Open Visual Studio for MAC ( not windows )
Create a new ( blank form ) iOS project
Click Visual Studio in Menu and Click Preferences
Click Apple Developer Accounts ( ADD YOUR APPLE ACCOUNT )
CLICK VIEW DETAILS & DOWNLOAD ALL PROFILES & Close
Open info.plist in your Folder View in VS
Check Manual Provisioning & Type in bundle Identifier com.companyname.whatever & App name
SAVE
RUN BLANK APP & CLOSE IT
10 ********* Go back to Windows right click on iOS Project Select Distribution AND YOUR BUNDLE IS IN THE DROP DOWN !!
[ If bundle not there re-connect to MAC right click and see if its there in your dropdown - remember the bundle must be in your iOS project ( root ) ]
( Automatic distribution will work as your bundle will be in the dropdown below in Windows Visual Studio & RELEASE TO APP STORE ).
One of the reason could be that there is no Provision profile file
For MAC the path is /Users/apple/Library/MobileDevice/Provisioning Profiles
You need to download the corresponding provision file from apple developer account and then paste it here in the above directory
Then, it will start reflecting in Visual Studio
Make sure you have a valid development certificate, it is added to your Keychain, and that you are signed into Xcode (Settings > Accounts).

Xamarin fails to deploy iOS app to iOS Device

I am trying to deploy my Xamarin iOS app to iPhone. But it fails to deploy into iPhone devices where as it works fine in Simulators. I verified that Bundle Identifier and Provisioning Profiles are matching. Also I deployed another test app into iPhone devices using XCode using the same provisioning profiles. It is getting deployed successfully. Also approved the Developer as trusted in iPhone.
The Exception I see Visual Studio as below
error MT1006: Could not install the application
'/Users/VarunRaja/Library/Caches/Xamarin/mtbs/builds/WK.TAA.Mfa.OTPAuthenticator.iOS/116dd0bfdd565dd44e1837c2280a6d94/bin/iPhoneSimulator/Debug/WK.TAA.Mfa.OTPAuthenticator.iOS.app'
on the device 'Raja’s iPhone': AMDeviceSecureInstallApplicationBundle
returned: 0xe8000067 (kAMDAPIInternalError).
I see this is coming from my Mac Agent. Visual Studio says the App is terminated.
As mentioned here by Tim Wheeler, it is an indication that your device is not in your provisioning profile, or your provisioning profile is invalid.
Why?
Basically, iOS will not let you build the app on to the device for security purposes, unless you have registered the device to THAT particular app in the Apple Developer Portal. They have no issues with you installing it on a simulator, so that you can't distribute apps without using the App Store.
Fix
In order to fix this, you need to have Access to the Apple Developer Portal of the company under which the app is registered and then go to the Certificates, Identifiers and Profiles.
Go to the "Devices" tab and make sure your device is in the list. Then go to "Profiles" tab, and you might see an "Invalid" status under the Expiration column of the Provisioning Profile. Fix it, tap on your app's profile, ensure it includes your iPhone, downloaded the new one to the mac and install it.
Not fixed yet?
If that was not the issue, it could be because you have multiple provisioning profiles installed. Visual Studio is usually set to Automatically determine the appropriate provisioning profile, and it could be using the wrong one if you have a few installed. You could delete the unneeded ones, or you can go to your iOS project settings, set the bundle signing to "Manual", then choose the valid profile.
Try to change Linker Behavior to Link SDK assemblies only
Go to the iOS properties => iOS Build and set "Linker Behavior" to "Link Framework SDKs Only" and "Supported Architectures" to "ARMv7 + ARM64"
Create blank project on your build mac host, or mac, xcode. Set bundle id to xamarin bundle id. Build and deploy from xcode, close and try again with xamarin.

How to run iOS application in real device through terminal without a paid apple developer account?

First this not duplicate of Test iOS app on device without apple developer program or jailbreak
I know it is possible to run app on device using Xcode 7 and free AppleId but i want to achieve this using terminal only Or in other words, Is there any way to generate provisioning profile & certificate using unpaid Apple Id through terminal.
If i will follow mentioned steps then my app installed and run successfully in device but i want to generate IPA using this free certificate and provisioning profile using terminal only.
In Xcode, add your Apple ID to Accounts preferences, described in
Adding Your Apple ID Account in Xcode.
In the project navigator,
select the project and your target to display the project editor.
Click General and choose your name from the Team pop-up menu.
Connect the device to your Mac and choose your device from the
Scheme toolbar menu. Below the Team pop-up menu, click Fix Issue.
Xcode creates a free provisioning profile for you and the warning
text under the Team pop-up menu disappears.
Click the Run button. Xcode installs the app on the device before launching the app.
I am working on some automation task and want to generate and install this signed iPA using unpaid Apple Id through Terminal.
I do not believe this is possible. The challenge is not just extracting the provisioning profile that is created in Xcode. That will not work because Xcode also manages the devices in the profile. So if your devices change, you need Xcode to register the new device and add it to the profile on Apple's servers, before re-downloading it. It also manages the bundle ID.
In theory, if you were to set up the app and all devices in Xcode before grabbing the provisioning profile from ~/Library/MobileDevice/Provisioning Profiles, maybe it would work.
If you can successfully get the profile. maybe you can use these instructions to build and install on the device as long as it was set up ahead of time: install application in iphone device through command line

Offline Ad-Hoc deployment of iOS apps

I have registered about 80 devices to my Apple Developer account. Now I want to be able to deploy my app to them in an environment where both XCode and device have no Internet connection. The problem being that if I deploy the app via XCode, the device must have network connection to verify the developer profile. (installed automatically when deploying the app via XCode)
How can I do this? I can setup XCode and the devices with Internet connection, but after the initial setup, developers will have to be able to make changes to the code and re-deploy the app onto the devices all without a network connection.
It takes a while to compile, but you could build,sign and package the app for Ad Hoc deployment, then install it via iTunes.
Steps:
In Xcode set the scheme's device to Generic iOS Device.
Then in the top menu: Product -> Archive.
...it takes a while to compile...
In the Organizer (pops up after build completes, or found in Window -> Organizer) select the build and click the Export button on the right hand side (under the big Upload to App Store... button).
Select Save for Ad Hoc Deployment and continue.
...You should get a .ipa file...
Open the .ipa file, which should open iTunes.
Plug your device into the computer via a lightning cable.
In iTunes go to the device then apps.
Click on the Install button next to the app in the apps list, so it says Will Install.
Click Apply.
All things going well you should have the app on the device!
If you then can't open the app you may find the device was not included in the provisioning profile, and you'll need to have some fun in the developer portal.

Resources