skip to Main Content

I have been tasked with making modifications and assisting with the distribution of an Xamarin .NET project. I have the source code repository, but I am a Windows Developer and have always been uncomfortable trying to understand Apple technologies. The person who developed the application has moved on and has no interest in providing support or assistance. It is for a small non-profit organization, so they have a limited budget for consultants.

The project seems to build fine, but when we get to the Pair to Mac portion of the puzzle, my Windows Development machine connects, but then frequently disconnects. The MacBook has Xcode and Visual Studio installed on it, but not much else has been done on it other than hook in the Apple accounts and build some keychain access stuff that may, or may not, have been done correctly. I have no idea how the Apple software was configured or what needs to be present there, most of the Xamarin documentation indicates that the Windows .NET environment will communicate it’s needs to the paired Apple machine and it’s all done auto-magically.

Well, that seems to not be the case. There seems to be a lot of gaps that I need to fill. For exammple, its an app that targets iPads for mobile data entry and then merging data back into the client/server application upon return to the secured network. When I build the project, there is no simulator for iPad, only iPhone, even though Xcode shows its got simulators for iPad.

When I am in Visual Studio 2022 the following can be observed:

  1. The Pair to Mac behavior is inconsistent. Sometimes it connects just fine, other times it may take 2 or 3 times to connect. Then once you connect successfully, trying to run in debug produces a late stage build error. Sometimes this is due to a disconnect of the Mac, other times its an obscure error about code signing.

  2. I have tried all sorts of variations on the iOS Bundle Signing entries within the project’s properties. Automatic Provisioning fails, Manual Provisioning fails. I have followed instructions to set up a certificate on the Mac, but it is all a bit of a mystery to me what is needed here.

  3. It always fails at the latest stage which is when I choose to Debug or run without debugging. It only shows options for iPhone and iPhone Simulator. I did manage to get my iPad to show up as a device for output by registering it in Xcode first, but this communication with the MacBook seems to be failing for whatever reason.

Is there any way to put these pieces together? I had thought that with the source code, it would not be difficult to recreate a development environment and reach a point where we had an IPA file for distribution. Now I’m not so sure because there are so many variables to address. Also, this is code that was developed and largely untouched for almost 3 years, so the OS and SDK versions have advanced greatly in that period of time.

Does any documentation exist or would anyone be able to give me some concise instructions on how to make it right? TIA…

I was expecting that once I had the MacBook paired to the Windows .NET Development environment and had installed Xcode and Visual Studio for Mac, that things would compile then run as expected. There does not seem to be compilation errors, but there are definitely late stage binding errors or something that keeps me from developing a complete and usable executable.

2

Answers


  1. Chosen as BEST ANSWER

    If anybody else runs into this, here's what finally caused me to catch on and get things working for me, YMMV.

    When I looked at the the project that was built in Visual Studio on the Mac, it said that the target was iPad Pro (6th Generation). This was not on my list of simulators available in Visual Studio (Windows), so every time I went to debug it, Visual Studio said "Device not found" and stopped, which makes sense.

    Finally, after hours and hours of searching, I found a recent post on Github:

    https://github.com/xamarin/xamarin-macios/issues/17561

    This post got me over the line. Although I know very little about Mac stuff, I was able to uninstall Xcode 14.3 and downgrade to Xcode 14.2. I had read that xamarin.ios-16.4.0.3 was the proper version, but when I connected to the MacBook, it said I had to use Xamarin.iOS and Xamarin.Mac SDK version 16.2.0.5 , IT FINALLY WORKED! The iPads are now in the device list for iPhoneSimulators!

    The certificates and provisioning profiles are configured manually. That was another exercise in understanding how to upload/download, double click them, copy them to Windows. Here are the notes I've made about this process. More for my own reference since it seemed a little bit laborious:

    Building Certificates & Keychains for Development While logged into the MacBook, start Safari and log into the Apple Developer website using your developer credentials.

    Generate a Certificate Signing Request (CSR): On your Mac, open Keychain Access (located in the Utilities folder within the Applications folder). From the Keychain Access menu, choose "Certificate Assistant" > "Request a Certificate From a Certificate Authority." Fill in your email address and choose "Saved to disk." This will generate a CSR file which I have been saving in Downloads/Certificate Files.

    Request a Development Certificate: Sign in to the Apple Developer Account website (developer.apple.com) using the Apple ID associated with your developer account. Navigate to the Certificates, Identifiers & Profiles section. Under "Certificates," click on the "+" button to create a new certificate. Select the "iOS App Development" option, upload the CSR file generated in the previous step.

    Now you are taken to a screen that displays your Certificate Name, Certificate Type, Expiration Date, etc. Click on Download, which will save the .cer file into the Downloads folder. Open up that folder and double click on the “ios_development.cer” file. This installs the certificate on the MacBook as well as adding it to the Keychain Access.

    Create a Provisioning Profile: I have created a provisioning profile called Dev Provisioning Profile. It can be edited to add more users or devices, but I think a separate distribution provisioning profile is required. There is a Download button here as well, so on the MacBook, I downloaded then double-clicked on the downloaded file.

    Within Xcode, in the Accounts area, there is a lot of information available when you click on the Manage Certificates button. Note that the MacBook is currently hooked to my account and the main account.

    After obtaining a development certificate and installing it on your Mac, you will need to export the corresponding private key (.p12 file) and transfer it to your Windows development machine. This is necessary to set up code signing in Visual Studio on Windows when working with Xamarin.iOS projects. To export the private key (.p12 file) from your Mac, follow these steps:

    Open the Keychain Access application on your Mac. You can find it in the Utilities folder within the Applications folder.
    
    In the Keychain Access app, select the "Certificates" category from the sidebar.
    
    Locate your development certificate in the list and expand it to show the associated private key.
    
    Right-click on the certificate-private key pair and select "Export..." from the context menu.
    
    Choose a location on your Mac to save the exported file and provide a name for the file (e.g., certificate.p12).
    
    In the export options, choose a password for the exported file. This password will be required when importing the private key on your Windows machine.
    
    Click "Save" to export the private key as a .p12 file.
    Once you have the .p12 file exported from your Mac, you can transfer it to your Windows development machine using a USB drive, email, cloud storage, or any other preferred method.
    

    On your Windows machine, you can then import the .p12 file into the certificate store and/or pull it in from the Visual Studio -> Tools -> Xamarin -> Apple Accounts. If you go to this area, select and it pops up a new window where you can Import Certificates. There is also a button there to Download All Profiles, which you should probably do when you create or change a provisioning profile.

    In Visual Studio on the development machine, you will also want to open up the project properties page. In the iOS Bundle Signing section you need to enter the correct certificate and provisioning profile. If the ones you want aren’t on the list, make sure you have completed the previous step(s) successfully. 1


  2. According to ToolmakerSteve:

    Mac-VS pairing is problematic. Use an online source repository, such
    as GitHub. Upload the code from the pc; download it to the mac. Do the
    builds & iOS Simulator launching there, in VS mac. With luck, you can
    move the monitor, mouse, keyboard to the mac, so don’t need new
    equipment.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search