Xamarin-macios: [Meta] Xcode 12.0 Support

Created on 22 Jun 2020  路  49Comments  路  Source: xamarin/xamarin-macios

This is a meta issue tracking the status of our Xcode 12.0 support.

Status

Xcode 12.0 GM has been released. We have a candidate build for macOS:

https://bosstoragemirror.blob.core.windows.net/wrench/jenkins/xcode12/7ec3751a1077e5d77d7375ef61182538d9d11f8d/234/package/notarized/xamarin.ios-14.0.0.0.pkg

We hope to have support in the stable channels soon, but it may be a few days.

Public Previews

To install, make sure you have latest Stable builds, and then select the Xcode 12 Previews channel in the Visual Studio for Mac updater. Note that you have to log in in Visual Studio for Mac for the Xcode 12 Preview channel to show up.

Xcode 12 Previews Release Notes

Please see our Xcode Summer Expectations wiki page for more information on our plan for Xcode 12.

Discussions continue on the specific feature work noted below.

Potential Features

| Title | Status | Has IDE Dependencies? |
| --- | --- | --- |
| App Clip | Cut | Possibly |
| macOS on Apple Silicon | In Consideration (does not align with Xcode12 directly) | Yes (Settings) |
| WidgetKit | Direct support cut, but msbuild support for Swift extensions available |https://github.com/xamarin/xamarin-macios/issues/8931#issuecomment-656317280) | Yes |

In Consideration - researching and considering this feature
Accepted - planned to be implemented
In Progress - actively being worked on
Cut - not planned to be supported for initial release. Possible in the future based upon demand.

Contributing

Open PR and issues on the xcode12 milestone

Follow our work

The current status of our bindings can be found on the wiki

You can see the latest commits in our branch and follow our discussions in our public development channel.

Known Issues

documentation iOS macOS

Most helpful comment

Hey everyone - I know there was a _lot_ of interest in WidgetKit.

We are still continuing research on if and how it makes sense to support it in Xamarin.iOS - but we want to enable you to build apps with Widget support as soon as possible.

The fastest way we can do that is make it easier to create "hybrid" applications with a SwiftUI extension embedded in a Xamarin.iOS application.

This work (in review) makes it a few line of msbuild:

<AdditionalAppExtensions Include="$(MSBuildProjectDirectory)/../../native">
        <Name>NativeTodayExtension</Name>
        <BuildOutput Condition="'$(Platform)' == 'iPhone'">build/Debug-iphoneos</BuildOutput>
        <BuildOutput Condition="'$(Platform)' == 'iPhoneSimulator'">build/Debug-iphonesimulator</BuildOutput>
</AdditionalAppExtensions>

And I wrote a small sample application which uses json serialization to transfer data from your XI main app to your Widget for display.

As soon as that work lands in our main branch, we'll cherry pick it to xcode12 and you'll be able to try this out. I'll post here again when that happens.

Those interested feel free to track details on the feature and any work in the associated issue.

All 49 comments

WidgetKit "in consideration"? Please just give up on iOS altogether if you will not support widgets (and therefore SwiftUI). Or shoot me and put me out of my misery.

I understand that you need time to investigate. It would be nice to know how much time this will take. Because this will help me to choose xamarin or not for future projects.

+1 for WidgetKit

I'm ready to start working with it right now if I could 馃槄

Hope it is added soon 馃

WidgetKit "in consideration"? Please just give up on iOS altogether if you will not support widgets (and therefore SwiftUI). Or shoot me and put me out of my misery.

Does WidgetKit require SwiftUI?

WidgetKit "in consideration"? Please just give up on iOS altogether if you will not support widgets (and therefore SwiftUI). Or shoot me and put me out of my misery.

Does WidgetKit require SwiftUI?

Yes it does. From the the documentation:

You configure the widget with a timeline provider, and use SwiftUI views to display the widget鈥檚 content.

WidgetKit "in consideration"? Please just give up on iOS altogether if you will not support widgets (and therefore SwiftUI). Or shoot me and put me out of my misery.

Does WidgetKit require SwiftUI?

Yes it does. From the the documentation:

You configure the widget with a timeline provider, and use SwiftUI views to display the widget鈥檚 content.

I thought briefly that "old" widgets would be backwards compatible with new iOS14 and could be used in the same manner. Installed iOS Beta and figured out that it unfortunately does not work this way :-/

I thought briefly that "old" widgets would be backwards compatible with new iOS14 and could be used in the same manner. Installed iOS Beta and figured out that it unfortunately does not work this way :-/

Today Extensions will continue to work with iOS14.

I thought briefly that "old" widgets would be backwards compatible with new iOS14 and could be used in the same manner. Installed iOS Beta and figured out that it unfortunately does not work this way :-/

Today Extensions will continue to work with iOS14.

Yes, they will continue to work, but one won't be able to pin it as a widget on a start screen.

Hi @chamons

The more I watch reviews of iOS the more I realize the importance of Widgets.

If not natively supported, I'd love guidance on any work around. Even if it requires us defining the screen in Xcode and somehow importing it into our app.

Thanks 馃檹

Hey everyone - I know there was a _lot_ of interest in WidgetKit.

We are still continuing research on if and how it makes sense to support it in Xamarin.iOS - but we want to enable you to build apps with Widget support as soon as possible.

The fastest way we can do that is make it easier to create "hybrid" applications with a SwiftUI extension embedded in a Xamarin.iOS application.

This work (in review) makes it a few line of msbuild:

<AdditionalAppExtensions Include="$(MSBuildProjectDirectory)/../../native">
        <Name>NativeTodayExtension</Name>
        <BuildOutput Condition="'$(Platform)' == 'iPhone'">build/Debug-iphoneos</BuildOutput>
        <BuildOutput Condition="'$(Platform)' == 'iPhoneSimulator'">build/Debug-iphonesimulator</BuildOutput>
</AdditionalAppExtensions>

And I wrote a small sample application which uses json serialization to transfer data from your XI main app to your Widget for display.

As soon as that work lands in our main branch, we'll cherry pick it to xcode12 and you'll be able to try this out. I'll post here again when that happens.

Those interested feel free to track details on the feature and any work in the associated issue.

This sounds promising @chamons. Does this actually mean that we can potentially create hybrid applications in general? That is, use Swift/SwiftUI for any screen in a Xamarin.iOS app?

So this specific build work only allows for _an entire extension_ (say a WidgetKit one) written in say Swift to be embedded in Xamarin.iOS Container app.

It would be another thing, and may I say is a _much_ harder problem, to embed arbitrary Swift/SwiftUI inside the same application itself. That would be some form of https://github.com/xamarin/xamarin-macios/issues/6235 for sure.

Good morning folks - landing the changes took longer than I expected due to some complications with test projects but they are in.

The lastest build off our branch (in a few hours) or our first preview (once we catch up with Xcode 12 Beta 3) will have AdditionalAppExtensions for use.

If you take it for a spin, please post feedback here or in a new issue if you run into trouble.

Thanks a lot @chamons . There is currently an issue with VS 2019 crash on Mac https://developercommunity.visualstudio.com/content/problem/1089299/cant-open-visual-studio-2019-with-macos-11-big-sur.html. How did you work around that?

I assume with AdditionalAppExtensions, calls such as WidgetCenter.shared.reloadTimelines(ofKind: "com.mygame.character-detail") from host app won't be possible until Xamarin supports iOS 14?

So the entire WidgetKit API is Swift only, as you can see by the header file Apple ships:

https://github.com/xamarin/xamarin-macios/wiki/WidgetKit-macOS-xcode12-beta1

It did not occur to me that we won't be able to bind reloadTimelines in C# easily because of this.

I've filed https://github.com/xamarin/xamarin-macios/issues/9215 for research.

Hi @chamons , I added AdditionalAppExtensions into my iOS project .csproj and when I build using VS for Mac using latest build from Stable branch, I don't see any output relating to the extension. How can I tell if it's built?

Hello everyone the first preview of Xcode 12 is out! See Public Previews section at the top of this issue for more information. Please give it a try and let us know your feedback!

@motoko89 You will need either a build from our main branch or be using the Xcode 12 Previews VSMac channel in order to use AdditionalAppExtensions.

Thanks @dalexsoto I'm on Xcode 12 Preview branch and I can build now.

You need to make sure the Swift host app and extension use the same signing certificate and info.plist value as the Xamarin app else it won't work on real device. Took me a while to figure that out

Hi @chamons , can you please take a look at how entitlement path is resolved?

It is looking for %(AdditionalAppExtensions.Identity)/%(AdditionalAppExtensions.Name).entitlements which I don't see in the build output. There is an Entitlements.plist elsewhere in the build output folder

When I copy %(AdditionalAppExtensions.Name).entitlements from the source or Entitlements.plist to the expected location, VS build failed: cannot read entitlement data

Here is my entitlements:

         <?xml version="1.0" encoding="UTF-8"?>
         <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
         <plist version="1.0">
         <dict>
            <key>com.apple.security.application-groups</key>
            <array>
                <string>group.abc.def</string>
            </array>
         </dict>
         </plist>

I also did chmod 777 on the file

Well Apple just announced today that iOS 14, iPadOS 14, tvOS 14, and watchOS 7 will be released to public tomorrow (Sept 16th).

Any projection when Xamarin will support Xcode 12 in a non-beta form? Even if some of the new extensions are missing.

Good question!

We are actively working on completing the last bits of API change brought by the GM (see the wiki) right now.

Once we have those merged, I'll post a link to the macOS pkg off of our build lane here.

It'll be some number of hours to a few days until it makes its way out to Visual Studio and Visual Studio for Mac.

And in addition to that - as of an hour ago - there's GM versions of Xcode. So if waiting for those was the plan I'd say it just hit the fan hard. Developer out here need a Xamarin release that can support at least Xcode 12 properly and isn't running as a beta.

@Shirk - See my earlier comment. Xamarin always needs to wait until the GM before releasing non-preview support because Apple breaks APIs until the last minute.

As a concrete example this time around, all macOS APIs for macOS 10.16 were just ripped out in the final preview. This means we can't ship a new Xamarin.Mac with those APIs, as Apple is free to break them until they go out (likely in Xcode 12.1).

We are working the problem now as in every year, and will post here once we have something for those who have a need for early support.

@Shirk - See my earlier comment. Xamarin always needs to wait until the GM before releasing non-preview support because Apple breaks APIs until the last minute.

You misunderstand the request here, I'm talking about a release the doesn't try to install older XC11 components over XC12 when pairing to a Mac that has it installed and that allows to compile and depoly apps targeting the iOS13 sdk. We can wait for stable iOS14 support but this is about building existing applications against a newer XCode and deploy and debug them.

The simple background being that XC11 won't allow debugging on an iOS14 device and Xamarin won't cooperate with XC12 even if the project is targeting iOS13.

@Shirk - Please consider raising that request via https://developercommunity.visualstudio.com/spaces/8/index.html more specifically.

My team, and this repository primarily deals with SDK itself. The IDE integration from Windows is not an area we work on directly.

Update: As you may have heard, the Xcode 12 Apple served the first few hours yesterday was slightly the wrong version, which causes us to have to reset our work (go download the "real" build, install it on bots, re-run API diffs, etc).

The initial support PR is in and we are waiting on one more PR before we have a "candidate build" for those who need support _now_ and don't want to wait for it to hit stable.

I'll post back later today.

Thank you for the transparency and update @chamons. I have always found it infinitely easier to get issues resolved on the Xamarin.iOS side than VS.NET. Kudos to the team.

Hey folks.

This is our candidate build, which unless something changes is the build we expect to go to stable later this week:

https://bosstoragemirror.blob.core.windows.net/wrench/jenkins/xcode12/7ec3751a1077e5d77d7375ef61182538d9d11f8d/234/package/notarized/xamarin.ios-14.0.0.0.pkg

iOS 14 is available !

Don't install the latest version of iTunes. It breaks hot reload in both vs2019 stable and preview.

Unfortunately, our Mac machine ended up with Xcode 12 and the Preview Channel for VS for Mac has updates to Xamarin.iOS 13.22.1.23 and Xamarin.Mac 6.22.1.23 which I am assuming doesn't support Xcode 12. The current versions are Xamarin.iOS 13.20.2.2 and Xamarin.Mac 6.20.2.2.

Would upgrading just Xamarin.iOS from the link above be enough to build and release and iPhone app?

@AmrAlSayed0

If you want to play it safe you can simply downgrade Xcode - Xcode 11.7 is available from Apple's Download archives for all registered developers:

https://download.developer.apple.com/Developer_Tools/Xcode_11.7/Xcode_11.7.xip

Unfortunately, our Mac machine ended up with Xcode 12 and the Preview Channel for VS for Mac has updates to Xamarin.iOS 13.22.1.23 and Xamarin.Mac 6.22.1.23 which I am assuming doesn't support Xcode 12. The current versions are Xamarin.iOS 13.20.2.2 and Xamarin.Mac 6.20.2.2.

Would upgrading just Xamarin.iOS from the link above be enough to build and release and iPhone app?

Yes, I have tried that: preview channel + xamarin.iOS 14.0 from the link at the top and I was able to build the app successfully.
Not using any of the new APIs though - but even without any modifications my source code wouldn鈥檛 build with the previous version of Xamarin.iOS

@Shirk @nbsoftware Thank You

Hey everyone - I know there was a _lot_ of interest in WidgetKit.

We are still continuing research on if and how it makes sense to support it in Xamarin.iOS - but we want to enable you to build apps with Widget support as soon as possible.

The fastest way we can do that is make it easier to create "hybrid" applications with a SwiftUI extension embedded in a Xamarin.iOS application.

@chamons And how is it supposed to work that we can call WidgetCenter.shared to force a update from our native WidgetKit extensions? Seems like Xamarin.iOS dosn't know about WidgetCenter. https://developer.apple.com/documentation/widgetkit/widgetcenter

@Sebastian1989101 you can bind WidgetKit like a swift library. Here is my approach.

@Csaba8472 good job! However, I see there one serious problem. This library must use iOS 14.0 SDK (because WidgetKit is not available earlier). When I refer it and run on iPhone with iOS 14.0 it works great, however, the application does not start on iOS below 14.0. Is there any way to work around this issue?

Update
Ok, I figured it out. I changed the deployment target to iOS 12.2 (Swift ABI stability) in your Xcode project and also set the same minimum iOS version in my app and it works well. Additionally, I added in your ApiDefinitions.cs:
[Introduced(PlatformName.iOS, 14, 0, PlatformArchitecture.All, null)] and I'm using it like this:

        private static void RefreshWidgets()
        {
            if (UIDevice.CurrentDevice.CheckSystemVersion(14, 0))
            {
#pragma warning disable XI0002 // Notifies you from using newer Apple APIs when targeting an older OS version
                new Binding.WidgetCenterProxy().ReloadAllTimeLines();
#pragma warning restore XI0002 // Notifies you from using newer Apple APIs when targeting an older OS version
            }
        }

@Csaba8472 this pretty looks nice. Do you have any plans to release this as NuGet package? Maybe with the modification from @wojciech-kulik so that the app still runs fine on iOS 12.2 and later? However, I think this should be standard in Xamarin.iOS so that we can at least update our native widget from Xamarin Code..

In case anyone has troubles with sharing data using App Groups. It turns out there is another problem with this approach. It does not codesign extension using its entitlements, that's why sharing data doesn't work.

I posted here some information:
https://github.com/xamarin/xamarin-macios/issues/9458#issuecomment-703891928

@chamons is there any way to force VS to use entitlements for widget extension?

thank you for the suggestions @wojciech-kulik , changed the target and added @available in the WidgetCenterProxy project, which was added to the ApiDefinition class. I'll update the repo soon.

@Sebastian1989101 created the nuget, currently unlisted and just an alpha version. Tested and it works but there could be rough edges.

Now I'm working on WatchOS app in Xcode. The same project as for my iOS 14 widget. Is there any way to import this WatchKit App + Extension into Xamarin project (similarly to WidgetKit project)?

The difference here is that WatchOS project contains not only an extension but also an app. That's why probably AdditionalAppExtensions alone won't work.

@wojciech-kulik suggest creating new, unique issue for native watchOS extension support. I wish you luck as I plan to port my watch app to Swift in a few months but keep main app Xamarin. Starting on widget first.

@t9mike I created a new issue: #10070

@t9mike I managed to publish Xamarin app with native watchOS app on App Store :) Instruction here: https://github.com/xamarin/xamarin-macios/issues/10070#issuecomment-727083181

Thank you so much for sharing Wojciech!! Best of luck. I'm finishing up porting my core engine to Swift and will move on to Widgets via SwiftUI soon.

Was this page helpful?
0 / 5 - 0 ratings