Sunday, April 15, 2018

Transitioning from Xamarin Simulator Builds to TestFlight

Xamarin Forms gets you up and running with the Simulator or LivePlayer in no time and that’s great. Transitioning to the next step of doing builds for TestFlight, however, can be a grand and tedious leap.

I won’t try to lead anyone through this process but I will show you the walls I hit and how I got around them. This took pretty much all day today with only a bit of a break to have lunch with my daughters and build a DIY cat litter box.

Null Reference Exception in Properties of iOS Project

The first befuddlement was while going through the tutorial for reconfiguring the iOS project to use the correct profiles. Clicking on the iOS Bundle Signing item in the Project Properties resulted in a Null Reference exception in the IDE. The resolution for this one was to simply exit Visual Studio and [re]connect to the Mac.

Codesign Password

This was probably really a brain fart on my part but I could not figure out what password was being requested here. Apple Developer account? iTunes? Apple ID? A password I didn’t remember specifying when creating the certificate? The answer is simply none of these. It just wanted the password associated with the account used to sign into the Mac. This seemed silly to me because I was already, well, signed in but there you go.

Do yourself a favor and click “Always Allow” or you might find yourself staring at a build that will never complete while this dialog hovers in the background.

image
codesign wants to sign using key “certificate name” in your keychain.

Getting Files onto your Mac

If you’re like me and prefer editing and building on the PC, you’ll need to transfer your bundles (IPA files) to the Mac for uploading. I used iCloud and the process was very smooth. I dragged the files into an iCloud browser window on the PC and they showed up in the iCloud folder in the Application Loader’s file browse dialog. There are obviously plenty of other ways from network shares to e-mail but this seemed easiest to me since I’d only have to do it once or twice (HA!).

Application Uploader Error #1

The Application Uploader does a preliminary check on the bundle and my first problem was this:

image

description length: 236593
ERROR ITMS-90161: “Invalid Provisioning Profile. The provisioning profile included in the bundle name [Payload/filename] is invalid. [Missing code signing certificate]. A Distribution Provisioning profile should be used when submitting apps to the App Store. For more information, visit the iOS Developer Portal."”

Well, this is what I get for following the tutorial without thinking. At first glance, this would seem to have to do with a lack of a certificate but that is really a red herring. The “Test Flight” instructions I was reading linked to "Publishing to the App Store” which said “For detailed instructions, please see the Creating a Distribution Profile” which links to a section titled “Creating a Development Provisioning Profile”. Note the difference here: Distribution vs. Development.

The second sentence of the second error is the crux of the issue: I used a Development profile which was linked with a Development certificate which explains the first part. The solution is go back and create a Distribution certificate and an associated Distribution profile and go through the process selecting it in the various places along the way. Hopefully, you’re reading this before having done any of that.

Success (oh if only it was that easy)

image

Application survived the preliminary tests and uploaded to the Apple Store. Hooray for..oh wait. I just got an e-mail which said:

Missing Info.plist value - A value for the Info.plist key 'CFBundleIconName' is missing in the bundle 'net.digitalmason.time'. Apps built with iOS 11 or later SDK must supply app icons in an asset catalog and must also provide a value for this Info.plist key.

Now this is actually awesome. This is a very descriptive tidbit and was very useful in finding a fix to the problem. If you get this error, you may have to move your Media.xcassets folder to under your Resources folder. Please see the post by DavidSkowronski here.

Application Uploader Error #2

Alright. Rebuild, move to Mac, run the Uploader and…son of a…I thought I had gotten through this part.

image

ERROR ITMS-4238: “Redundant Binary Upload. You’ve already uploaded a build with build number ‘1.0’ for version number ‘1.0’. Make sure you increment the build string before you upload your app to iTunes Connect.

Again, this is a pretty explanatory error.  Edit your Info.plist and update the build number every time you’re ready to upload. Note this seems like a good opportunity to dig into msbuild and autoincrement this number whenever you do a AppStore Configuration build. Perhaps next weekend.

Missing Info.plist key

So…build, move to Mac, run the Uploader, and voila! What’s that? I think I just got an e-mail:

Missing Info.plist key - This app attempts to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSCalendarsUsageDescription key with a string value explaining to the user how the app uses this data.

And, again, thank you, Apple. This error gets you the basic info you need. If you get this error, depending on which key is referenced, you’re going to be adding a key/value something like this to your Info.plist:

<key>NSCalendarsUsageDescription</key>
<string>$(PRODUCT_NAME) uses your calendar.</string>

See here for details.

So, again, build, move to Mac, run the Uploader, and…dammit..I forgot to increment the Build Number again!

Success? Just About…

Finally, build, move to Mac, run the Uploader, success, and..waiting for e-mail..ah..(roll eyes)..there it is:

Dear Digitalmason.net, LLC,

The following build has completed processing:

Platform: iOS
App Name: Jack of Time
Build Number: 3
Version Number: 0.5
App SKU: XXXXX
App Apple ID: XXXXXX

You can now use this build for TestFlight testing or submit it to the App Store.

Hooray! Seriously, though, there was one more thing…

Missing Compliance

I’m configuring my TestFlight and seeing this daunting status that I know is going to get me:

image

Well, it turns out, this one, in particular, is rather nicely done. You can add the following key/value pair to your Info.plist but wait—don’t start a new build just yet!

<key>ITSAppUsesNonExemptEncryption</key>
<string>NO</string>

Now this is assuming you don’t actually use any non-exempt encryption. For more details, please see here.

As I said, you do not have to go through the whole process again.

image

You can choose the “Provide Export Compliance Information” and answer the questions to have your Info.plist updated in your current upload.

image

Success. Really.

At this point, TestFlight went smoothly and I got my early version app on some devices and, thankfully, other than one (rather serious) framework issue, it’s working nicely.

I hope this rehash of my tedious day helps some of you all get through this much more quickly.

JackOfTime Screenshot

Saturday, April 7, 2018

MacinCloud for Xamarin

Resistance is well… you know… futile.

I used a Mac Mini for my Xamarin builds. It was slow and eventually crashed hard. I had to reinstall the OS, and upgrade, and upgrade, and upgrade, and upgrade. Did I mention how slow it was?

Image may contain: camera

While I was waiting for the pictured reinstall and many other upgrades, I read about MacinCloud. It sounded promising but I hate adding to the monthly burn. I resisted and upgraded and upgraded and built slowly and crashed again and finally decided I’d try MacinCloud’s trial.

The Signup

The signup is quick, easy, and painless with the exception of one thing: I chose the wrong subscription for simply remote building using Xamarin. So here’s my key point: if you want to just build from Visual Studio using Xamarin on Windows, you need the Managed Server ($20/mo) but you also need the “SSH add-on” ($2.50/mo) so make sure you check that box. It is my understanding that, under this plan, you’ll be sharing the Mac with others (they’ll have their own log in of course so it shouldn’t be a problem). This plan includes the latest OS with Xcode and Visual Studio installed.

image

The Signin

You must be signed into the Mac in order to use the remote building capability of Xamarin. You can use Remote Desktop Connection (RDP) to connect to your Mac. They’ll send you an e-mail with a .ZIP containing some .RDP files to simply connect or you can just type in the info they send you in the e-mail. You can configure RDP to remember this info so it’s always just one click away.

image

The connection

Once you’re signed in, from your Visual Studio on the PC, choose Connect from the Xamarin toolbar and enter the fully qualified host name or IP address of your Mac. You’ll also have to enter that user name and password again from the e-mail. Once you’ve done this, though, you can just choose the connection again and don’t have to retype all that info next time.

image

Now you can build and debug using the iPhone simulator or Xamarin’s Live Player which is very cool but might warrant a separate post in its current state (beta).

image

Usage—Sign Out

One last thing about signing in. You need to Sign Out when you’re done building for the day and/or before you take a dinner break. You need to actually Sign Out. Don’t just close the RDP window. That may leave you signed in. The Managed Server plan has a daily time limit of 3 hours.

Exceeding Your Plan’s Usage

According to MacinCloud support:

“We have an algorithm to track user usage pattern, once the user's usage exceeds 3 hours every day, they are automatically upgraded to the tier that better reflecting their usage pattern. If user use more than 3 hours but less than 5 hours daily, they will be in the 5-Hour daily limit tier.”

To me, this seems like a very reasonable way to do things.