Skip to content

Commit

Permalink
Add very early support for Mac Catalyst. (#10199)
Browse files Browse the repository at this point in the history
* Install the Mac Catalyst versions of the mono libraries and BCL.
   * The BCL is the same as the one for Xamarin.iOS, which means it has to be post-processed a bit to work with a Xamarin.MacCatalyst.dll
* Build our runtime for Mac Catalyst.
* Build a Xamarin.MacCatalyst.dll with the Mac Catalyst API (it compiles, but I haven't looked at the API surface at all). This PR assumes we're going to have a new TargetFrameworkIdentifier for Mac Catalyst, but a final decision has not been made (see dotnet/runtime#44882), so this may change.
* Build a Xamarin.iOS.dll that contains type forwarders to Mac Catalyst for all the types that exist in both Mac Catalyst and Xamarin.iOS.
* Add support to xharness for running introspection on Mac Catalyst (there are a lot of failures because the API surface is wrong)
* Add support to our msbuild tasks and mtouch for building Mac Catalyst apps. This basically comes down to adding a new case in numerous places to either do things the iOS way or the macOS way, depending on each case.
* Add a __MACCATALYST__ define (which is in addition to the __IOS__ define).
  • Loading branch information
rolfbjarne authored Dec 4, 2020
2 parents cf5a229 + 2784675 commit daa7e12
Show file tree
Hide file tree
Showing 165 changed files with 3,208 additions and 166 deletions.
33 changes: 33 additions & 0 deletions Make.config
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ $(TOP)/Make.config.inc: $(TOP)/Make.config $(TOP)/mk/mono.mk
@printf "TVOS_NUGET_COMMIT_DISTANCE:=$(shell LANG=C; export LANG; git --git-dir $(TOP)/.git log `git --git-dir $(TOP)/.git blame -- ./Make.versions HEAD | grep TVOS_NUGET_VERSION= | sed 's/ .*//' `..HEAD --oneline | wc -l | sed 's/ //g')\n" >> $@
@printf "WATCHOS_NUGET_COMMIT_DISTANCE:=$(shell LANG=C; export LANG; git --git-dir $(TOP)/.git log `git --git-dir $(TOP)/.git blame -- ./Make.versions HEAD | grep WATCHOS_NUGET_VERSION= | sed 's/ .*//' `..HEAD --oneline | wc -l | sed 's/ //g')\n" >> $@
@printf "MACOS_NUGET_COMMIT_DISTANCE:=$(shell LANG=C; export LANG; git --git-dir $(TOP)/.git log `git --git-dir $(TOP)/.git blame -- ./Make.versions HEAD | grep MACOS_NUGET_VERSION= | sed 's/ .*//' `..HEAD --oneline | wc -l | sed 's/ //g')\n" >> $@
@printf "MACCATALYST_NUGET_COMMIT_DISTANCE:=$(shell LANG=C; export LANG; git --git-dir $(TOP)/.git log `git --git-dir $(TOP)/.git blame -- ./Make.versions HEAD | grep MACCATALYST_NUGET_VERSION= | sed 's/ .*//' `..HEAD --oneline | wc -l | sed 's/ //g')\n" >> $@
@if which ccache > /dev/null 2>&1; then printf "ENABLE_CCACHE=1\nexport CCACHE_BASEDIR=$(abspath $(TOP)/..)\n" >> $@; echo "Found ccache on the system, enabling it"; fi
@if test -d $(TOP)/../maccore; then printf "ENABLE_XAMARIN=1\n" >> $@; echo "Detected the maccore repository, automatically enabled the Xamarin build"; fi
@# Build from source if we're on CI and packages aren't available.
Expand Down Expand Up @@ -110,6 +111,13 @@ WATCHOS_NUGET_VERSION_PATCH=$(word 3, $(subst ., ,$(WATCHOS_NUGET_VERSION)))
WATCHOS_NUGET_VERSION_NO_METADATA=$(WATCHOS_NUGET_VERSION)-$(NUGET_PRERELEASE_IDENTIFIER)$(WATCHOS_NUGET_COMMIT_DISTANCE)
WATCHOS_NUGET_VERSION_FULL=$(WATCHOS_NUGET_VERSION_NO_METADATA)+$(NUGET_BUILD_METADATA)

MACCATALYST_NUGET=Microsoft.MacCatalyst
MACCATALYST_NUGET_VERSION_MAJOR=$(word 1, $(subst ., ,$(MACCATALYST_NUGET_VERSION)))
MACCATALYST_NUGET_VERSION_MINOR=$(word 2, $(subst ., ,$(MACCATALYST_NUGET_VERSION)))
MACCATALYST_NUGET_VERSION_PATCH=$(word 3, $(subst ., ,$(MACCATALYST_NUGET_VERSION)))
MACCATALYST_NUGET_VERSION_NO_METADATA=$(MACCATALYST_NUGET_VERSION)-$(NUGET_PRERELEASE_IDENTIFIER)$(MACCATALYST_NUGET_COMMIT_DISTANCE)
MACCATALYST_NUGET_VERSION_FULL=$(MACCATALYST_NUGET_VERSION_NO_METADATA)+$(NUGET_BUILD_METADATA)

# Xcode version should have both a major and a minor version (even if the minor version is 0)
XCODE_VERSION=12.2
XCODE_URL=http://xamarin-storage/bot-provisioning/xcodes/Xcode_12.2.xip
Expand Down Expand Up @@ -154,6 +162,8 @@ IOS_SDK_VERSION=$(word 1, $(subst ., ,$(IOS_NUGET_VERSION))).$(word 2, $(subst .
OSX_SDK_VERSION=$(word 1, $(subst ., ,$(MACOS_NUGET_VERSION))).$(word 2, $(subst ., ,$(MACOS_NUGET_VERSION)))
WATCH_SDK_VERSION=$(word 1, $(subst ., ,$(WATCHOS_NUGET_VERSION))).$(word 2, $(subst ., ,$(WATCHOS_NUGET_VERSION)))
TVOS_SDK_VERSION=$(word 1, $(subst ., ,$(TVOS_NUGET_VERSION))).$(word 2, $(subst ., ,$(TVOS_NUGET_VERSION)))
MACCATALYST_SDK_VERSION=$(IOS_SDK_VERSION)
MACCATALYST_MAC_SDK_VERSION=$(OSX_SDK_VERSION)

MAX_IOS_DEPLOYMENT_TARGET=$(IOS_SDK_VERSION)
MAX_WATCH_DEPLOYMENT_TARGET=$(WATCH_SDK_VERSION)
Expand All @@ -170,6 +180,7 @@ MIN_WATCHOS_SDK_VERSION=2.0
MIN_WATCHOS64_32_SDK_VERSION=5.1
MIN_WATCH_OS_VERSION=2.0
MIN_TVOS_SDK_VERSION=9.0
MIN_MACCATALYST_SDK_VERSION=13.1

# The min simulator version available in the Xcode we're using
MIN_IOS_SIMULATOR_VERSION=10.3
Expand All @@ -184,6 +195,7 @@ INCLUDE_IOS=1
INCLUDE_MAC=1
INCLUDE_WATCH=1
INCLUDE_TVOS=1
INCLUDE_MACCATALYST=1
INCLUDE_DEVICE=1

# disable source code install by default (it's enabled for CI builds)
Expand Down Expand Up @@ -228,6 +240,7 @@ MONOTOUCH_PREFIX := $(abspath $(MONOTOUCH_PREFIX))
MONOTOUCH_MONO_PATH?=$(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.iOS
MONOTOUCH_TV_MONO_PATH?=$(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.TVOS
MONOTOUCH_WATCH_MONO_PATH?=$(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.WatchOS
MONOTOUCH_MACCATALYST_MONO_PATH?=$(IOS_DESTDIR)$(MONOTOUCH_PREFIX)/lib/mono/Xamarin.MacCatalyst

IOS_PACKAGE_FILENAME=$(IOS_PACKAGE_NAME_LOWER)-$(IOS_PACKAGE_VERSION).pkg
IOS_PACKAGE_UTI=com.xamarin.$(IOS_PACKAGE_NAME_LOWER).pkg
Expand Down Expand Up @@ -258,6 +271,13 @@ COMMON_SIMULATOR_OBJC_CFLAGS=-fobjc-abi-version=2 -fobjc-legacy-dispatch $(CFLAG
SIMULATOR86_OBJC_CFLAGS=$(COMMON_SIMULATOR_OBJC_CFLAGS) $(SIMULATOR86_CFLAGS)
SIMULATOR64_OBJC_CFLAGS=$(COMMON_SIMULATOR_OBJC_CFLAGS) $(SIMULATOR64_CFLAGS)

MACCATALYST_COMMON_CFLAGS=-target x86_64-apple-ios$(MIN_MACCATALYST_SDK_VERSION)-macabi -arch x86_64 -g $(IOS_COMMON_DEFINES) \
-isysroot $(XCODE_DEVELOPER_ROOT)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(OSX_SDK_VERSION).sdk \
-isystem $(XCODE_DEVELOPER_ROOT)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(OSX_SDK_VERSION).sdk/System/iOSSupport/usr/include \
-iframework $(XCODE_DEVELOPER_ROOT)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(OSX_SDK_VERSION).sdk/System/iOSSupport/System/Library/Frameworks
MACCATALYST_OBJC_CFLAGS=$(MACCATALYST_COMMON_CFLAGS) -fobjc-abi-version=2 -fobjc-legacy-dispatch $(OBJC_CFLAGS)
MACCATALYST_CFLAGS=$(MACCATALYST_COMMON_CFLAGS)

MONOTOUCH_SIMULATOR_SDK=$(MONOTOUCH_PREFIX)/SDKs/MonoTouch.iphonesimulator.sdk

DEVICE_BIN_PATH=$(XCODE_DEVELOPER_ROOT)/Toolchains/XcodeDefault.xctoolchain/usr/bin
Expand All @@ -267,6 +287,7 @@ DEVICE_CXX=$(IOS_CXX)
IOS_CSC=$(SYSTEM_CSC) -features:strict -nostdlib -noconfig -r:$(MONOTOUCH_MONO_PATH)/System.dll -r:$(MONOTOUCH_MONO_PATH)/System.Core.dll -r:$(MONOTOUCH_MONO_PATH)/System.Xml.dll -r:$(MONOTOUCH_MONO_PATH)/mscorlib.dll -r:$(MONOTOUCH_MONO_PATH)/System.Net.Http.dll -r:$(MONOTOUCH_MONO_PATH)/Facades/System.Drawing.Common.dll -deterministic
TV_CSC=$(SYSTEM_CSC) -features:strict -nostdlib -noconfig -r:$(MONOTOUCH_TV_MONO_PATH)/System.dll -r:$(MONOTOUCH_TV_MONO_PATH)/System.Core.dll -r:$(MONOTOUCH_TV_MONO_PATH)/System.Xml.dll -r:$(MONOTOUCH_TV_MONO_PATH)/mscorlib.dll -r:$(MONOTOUCH_TV_MONO_PATH)/System.Net.Http.dll -r:$(MONOTOUCH_TV_MONO_PATH)/Facades/System.Drawing.Common.dll -deterministic
WATCH_CSC=$(SYSTEM_CSC) -features:strict -nostdlib -noconfig -r:$(MONOTOUCH_WATCH_MONO_PATH)/System.dll -r:$(MONOTOUCH_WATCH_MONO_PATH)/System.Core.dll -r:$(MONOTOUCH_WATCH_MONO_PATH)/System.Xml.dll -r:$(MONOTOUCH_WATCH_MONO_PATH)/mscorlib.dll -r:$(MONOTOUCH_WATCH_MONO_PATH)/System.Net.Http.dll -r:$(MONOTOUCH_WATCH_MONO_PATH)/Facades/System.Drawing.Common.dll -deterministic
MACCATALYST_CSC=$(SYSTEM_CSC) -features:strict -nostdlib -noconfig -r:$(MONOTOUCH_MACCATALYST_MONO_PATH)/System.dll -r:$(MONOTOUCH_MACCATALYST_MONO_PATH)/System.Core.dll -r:$(MONOTOUCH_MACCATALYST_MONO_PATH)/System.Xml.dll -r:$(MONOTOUCH_MACCATALYST_MONO_PATH)/mscorlib.dll -r:$(MONOTOUCH_MACCATALYST_MONO_PATH)/System.Net.Http.dll -r:$(MONOTOUCH_MACCATALYST_MONO_PATH)/Facades/System.Drawing.Common.dll -deterministic

DEVICE_OBJC_CFLAGS=$(OBJC_CFLAGS) $(BITCODE_CFLAGS)

Expand All @@ -284,6 +305,10 @@ MONOTOUCH_DEVICE_SDK=$(MONOTOUCH_PREFIX)/SDKs/MonoTouch.iphoneos.sdk
XAMARIN_IOSSIMULATOR_SDK = $(MONOTOUCH_SIMULATOR_SDK)
XAMARIN_IPHONEOS_SDK = $(MONOTOUCH_DEVICE_SDK)

# MacCatalyst

XAMARIN_MACCATALYST_SDK = $(MONOTOUCH_PREFIX)/SDKs/Xamarin.MacCatalyst.sdk

# WatchOS

XAMARIN_WATCHSIMULATOR_SDK = $(MONOTOUCH_PREFIX)/SDKs/Xamarin.WatchSimulator.sdk
Expand Down Expand Up @@ -421,15 +446,19 @@ MONO_IOS_FILENAME:=ios-release-Darwin-$(MONO_HASH).7z
MONO_IOS_URL:=https://xamjenkinsartifact.azureedge.net/mono-sdks/$(XCODE_ARCHIVE_VERSION)/$(MONO_IOS_FILENAME)
MONO_MAC_FILENAME:=mac-release-Darwin-$(MONO_HASH).7z
MONO_MAC_URL:=https://xamjenkinsartifact.azureedge.net/mono-sdks/$(XCODE_ARCHIVE_VERSION)/$(MONO_MAC_FILENAME)
MONO_MACCATALYST_FILENAME:=maccat-release-Darwin-$(MONO_HASH).7z
MONO_MACCATALYST_URL:=https://xamjenkinsartifact.azureedge.net/mono-sdks/$(XCODE_ARCHIVE_VERSION)/$(MONO_MACCATALYST_FILENAME)

# Setup various variables depending on whether mono is downloaded or built from source
ifeq ($(MONO_BUILD_FROM_SOURCE),)
MONO_IOS_SDK_DESTDIR:=$(abspath $(TOP)/builds/downloads/$(basename $(MONO_IOS_FILENAME)))
MONO_MAC_SDK_DESTDIR:=$(abspath $(TOP)/builds/downloads/$(basename $(MONO_MAC_FILENAME)))
MONO_MACCATALYST_SDK_DESTDIR:=$(abspath $(TOP)/builds/downloads/$(basename $(MONO_MACCATALYST_FILENAME)))
MONO_BUILD_MODE=download-mono
else
MONO_IOS_SDK_DESTDIR:=$(abspath $(MONO_PATH)/sdks/out)
MONO_MAC_SDK_DESTDIR:=$(abspath $(MONO_PATH)/sdks/out)
MONO_MACCATALYST_SDK_DESTDIR:=$(abspath $(MONO_PATH)/sdks/out)
MONO_BUILD_MODE=compile-mono
endif

Expand Down Expand Up @@ -492,6 +521,10 @@ DOTNET_WATCHOS_RUNTIME_IDENTIFIERS_64=watchos-x64
endif
endif

ifdef INCLUDE_MACCATALYST
DOTNET_MACCATALYST_RUNTIME_IDENTIFIERS=maccatalyst-x64
endif

DOTNET_PLATFORMS+=macOS
DOTNET_MACOS_RUNTIME_IDENTIFIERS=osx-x64

Expand Down
1 change: 1 addition & 0 deletions Make.versions
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,4 @@ IOS_NUGET_VERSION=14.2.100
TVOS_NUGET_VERSION=14.2.100
WATCHOS_NUGET_VERSION=7.1.100
MACOS_NUGET_VERSION=11.0.100
MACCATALYST_NUGET_VERSION=14.2.100
25 changes: 25 additions & 0 deletions Versions-ios.plist.in
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,30 @@
<string>7.0</string>
<string>7.1</string>
</array>
<key>MacCatalyst</key>
<array>
<string>13.1</string>
<string>13.2</string>
<string>13.3</string>
<string>13.4</string>
<string>13.5</string>
<string>14.2</string>
</array>
</dict>
<key>MacCatalystVersionMap</key>
<dict>
<key>13.1</key>
<string>10.15</string>
<key>13.2</key>
<string>10.15.1</string>
<key>13.3</key>
<string>10.15.2</string>
<key>13.4</key>
<string>10.15.4</string>
<key>13.5</key>
<string>10.15.5</string>
<key>14.2</key>
<string>11.0</string>
</dict>
<key>RecommendedXcodeVersion</key>
<string>@XCODE_VERSION@</string>
Expand Down Expand Up @@ -172,6 +196,7 @@
<string>sgen-concurrent</string> <!-- this means stable support for the concurrent GC -->
<string>arm64_32</string>
<string>altool</string>
<string>maccatalyst</string>
</array>
<key>Optimizations</key>
<dict>
Expand Down
Loading

8 comments on commit daa7e12

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 Tests failed catastrophically on VSTS: device tests iOS (Cambridge) 🔥

Failed provisioning profiles.

Pipeline on Agent

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 Tests failed catastrophically on VSTS: device tests iOS (Cambridge) 🔥

Failed installing dependencies.

Pipeline on Agent

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 Tests failed catastrophically on VSTS: device tests iOS (DDFun) 🔥

Failed provisioning profiles.

Pipeline on Agent

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 Tests failed catastrophically on VSTS: device tests iOS (DDFun) 🔥

Failed installing dependencies.

Pipeline on Agent

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 Tests failed catastrophically on VSTS: device tests tvOS (DDFun) 🔥

Failed provisioning profiles.

Pipeline on Agent

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 Tests failed catastrophically on VSTS: device tests tvOS (DDFun) 🔥

Failed installing dependencies.

Pipeline on Agent

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build was (probably) aborted

🔥 Jenkins job (on internal Jenkins) failed in stage(s) 'Test run' 🔥

Provisioning succeeded
Build succeeded
✅ Packages built successfully

View packages

API Diff (from stable)
ℹ️ API Diff (from PR only) (please review changes)
ℹ️ Generator Diff (please review changes)
🔥 Test run failed 🔥

Test results

6 tests failed, 171 tests passed.

Failed tests

  • [NUnit] Mono SystemNumericsTests/watchOS 32-bits - simulator/Debug: Failed
  • [NUnit] Mono MonoRuntimeTests/watchOS 32-bits - simulator/Debug: Failed
  • [xUnit] Mono SystemNumericsXunit/watchOS 32-bits - simulator/Debug: Failed
  • [xUnit] Mono MicrosoftCSharpXunit/watchOS 32-bits - simulator/Debug: Failed
  • [xUnit] Mono SystemCoreXunit Part 1/watchOS 32-bits - simulator/Debug: Failed
  • introspection/watchOS 32-bits - simulator/Debug (watchOS 3.2): Failed

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Status for 'xamarin-macios - sample testing (build)': failure.

  • ❌ Debug_iPhone_AF: Failed
  • ❌ Debug_iPhone_GR: Failed
  • ❌ Debug_iPhone_SZ: Failed
  • ❌ Debug_iPhoneSimulator: Failed
  • ❌ Release_iPhone_AF: Failed
  • ❌ Release_iPhone_GR: Failed
  • ❌ Release_iPhone_SZ:
  • ❌ Release_iPhoneSimulator: Failed
  • ❌ Debug_Mac: Failed
  • ❌ Release_Mac: Failed
  • ✅ PublishPerformanceData: Succeeded

Please sign in to comment.