How to Select Older iOS Simulator in Visual Studio for Mac

Sometime it is very useful to test on an older device to reproduce bug found by your other iOS users, but launching / select an older iOS simulator is not that straightforward compare with Android simulator which can easily be done in Visual Studio for Mac.

For iOS simulator, first you need to install the older version of iOS simulator from Xcode.

  1. Launch Xcode.
  2. Open Preferences by go to top menu > Xcode > Preferences.
  3. Open Components tab.
  4. Select and install the iOS simulator version you prefer by clicking on the small download button on the left.
  5. The download / installation might take some time.

Just install the older simulator is not enough, you need to manually create a simulator for this version too.

  1. Still inside Xcode.
  2. Open Devices and Simulators by go to the top menu > Window > Devices and Simulators.
  3. Switch to Simulators tab.
  4. Click the small + button on the bottom left.
  5. Enter a name for the simulator (it even suggested a name for you).
  6. Remember to select the correct iOS version you need.
  7. Click OK and you should see the newly created simulator added to the list of simulator on the left.

Once you have installed and created the iOS simulator. Then only Visual Studio for Mac will be able to show the new simulator in the simulator list. You might need to restart Visual Studio for Mac for the simulator list to be refreshed if Visual Studio for Mac already running when you create the simulator.

One thing to keep in mind that older simulator doesn’t get removed automatically when you update your Xcode.

Change Navigation Bar Color in iOS 15

If your app changed the color of navigation bar (background / foreground / text color / tint color), it is probably broken in the new iOS 15. Here is how I fix them in Xamarin:

if (UIDevice.CurrentDevice.CheckSystemVersion(15, 0))
{
    // change the background and text color of title bar
    var appearance = new UINavigationBarAppearance();
    appearance.ConfigureWithOpaqueBackground();
    appearance.BackgroundColor = CustomColor.AccentColor;
    appearance.TitleTextAttributes = new UIStringAttributes() { ForegroundColor = CustomColor.ForegroundColor };
    appearance.LargeTitleTextAttributes = new UIStringAttributes() { ForegroundColor = CustomColor.ForegroundColor };

    UINavigationBar.Appearance.StandardAppearance = appearance;
    UINavigationBar.Appearance.ScrollEdgeAppearance = appearance;
}
else
{
    // change the background color of title bar
    UINavigationBar.Appearance.BarTintColor = CustomColor.AccentColor;
    UINavigationBar.Appearance.Translucent = false;

    // change the title text color
    UINavigationBar.Appearance.TitleTextAttributes = new UIStringAttributes() { ForegroundColor = CustomColor.ForegroundColor };
}

// change the button color on navigation bar
UINavigationBar.Appearance.TintColor = CustomColor.ForegroundColor;

iOS WkWebview Return A Blank Screen / White Screen

Try to code your first example of WkWebview / UIWebView in your iOS app always return a blank screen or white screen? You are not alone. Apparently since iOS 9, all HTTP / non-secure web connection is block by default. It is something call App Transport Security (ATS).

You can add the following configuration into Info.plist to allow WkWebview / UIWebView to load HTTP / non-secure web page:

<key>NSAppTransportSecurity</key>
<dict>
    <key> NSAllowsArbitraryLoadsInWebContent</key>
    <true/>
</dict>

Or you can completely disable App Transport Security by

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

Source: https://developer.xamarin.com/guides/ios/application_fundamentals/ats/

Xamarin Test Recorder Installation: VSIXInstaller.NoApplicableSKUsException

I came across Xamarin Test Recorder a few days ago, and feel that it really can solve the pain I have with Appium which need a lot of work to write a single test. Give it a try to install but it fail with the following message below and no body in the marketplace review seem to know why and leave a one star review. Because no body care to read the description!

Continue reading Xamarin Test Recorder Installation: VSIXInstaller.NoApplicableSKUsException