Skip to content

Commit

Permalink
[StoreKit] Bind AppStore.requestReview. Fixes #21410. (#21441)
Browse files Browse the repository at this point in the history
The existing Objective-C class to request an App Store review (SKStoreReviewController) is deprecated in Xcode 16+, and it doesn't even work on the corresponding OS versions.

The replacement API is Swift-only, but luckily it's a very simple API (just a static method), so it's possible to bind it manually.

This required a few other changes/improvements:

* Add support for Swift code in our runtime.

* Just to keep the changes to a minimum, bump the min OS version for legacy code to match the .NET min OS versions. This is because our build logic uses the legacy min versions when compiling native code (a more involved fix would be to update all the build logic to build native code to use the .NET min OS versions, but that's not the point of this PR, so I took the easy route). Fixes #10659.

I've tested the method locally, and it seems to work fine, but I've still marked
it as experimental for now. There are no unit tests because calling the method will
put up a dialog, which won't work correctly in unit tests.

Fixes #21410.
Fixes #10659.
  • Loading branch information
rolfbjarne authored and haritha-mohan committed Oct 19, 2024
1 parent 071a98a commit a198a87
Show file tree
Hide file tree
Showing 13 changed files with 192 additions and 23 deletions.
51 changes: 38 additions & 13 deletions Make.config
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,12 @@ MAX_TVOS_SIMULATOR_VERSION=$(TVOS_SDK_VERSION)
MAX_WATCH_SIMULATOR_VERSION=$(WATCH_SDK_VERSION)

# Minimum OS versions for running XI/XM apps.
MIN_IOS_SDK_VERSION=11.0
MIN_IOS_SDK_VERSION=12.2
MIN_MACOS_SDK_VERSION=12.0
MIN_WATCHOS_SDK_VERSION=4.0
MIN_WATCHOS64_32_SDK_VERSION=5.1
MIN_WATCH_OS_VERSION=4.0
MIN_TVOS_SDK_VERSION=11.0
MIN_TVOS_SDK_VERSION=12.2
MIN_MACCATALYST_SDK_VERSION=15.0

# Minimum OS versions for .NET 9 support
Expand Down Expand Up @@ -408,7 +408,10 @@ SIMULATOR_SDK=$(XCODE_DEVELOPER_ROOT)/Platforms/iPhoneSimulator.platform/Develop
# Ref: https://github.com/xamarin/xamarin-macios/issues/16223
OBJC_CFLAGS=-ObjC++ -std=c++14 -fno-exceptions -fno-objc-msgsend-selector-stubs

COMMON_SIMULATOR_CFLAGS=-mios-simulator-version-min=$(MIN_IOS_SDK_VERSION) -isysroot $(SIMULATOR_SDK) $(CFLAGS) -g $(IOS_COMMON_DEFINES)
COMMON_SIMULATOR_CFLAGS=-mios-simulator-version-min=$(MIN_IOS_SDK_VERSION) -isysroot $(SIMULATOR_SDK) $(CFLAGS) -g $(IOS_COMMON_DEFINES) \
-L$(SIMULATOR_SDK)/usr/lib/swift \
-L$(XCODE_DEVELOPER_ROOT)/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator \
-Wno-unused-command-line-argument
SIMULATOR86_CFLAGS=$(COMMON_SIMULATOR_CFLAGS) -arch i386
SIMULATOR64_CFLAGS=$(COMMON_SIMULATOR_CFLAGS) -arch x86_64
SIMULATOR_ARM64_CFLAGS=$(COMMON_SIMULATOR_CFLAGS) -arch arm64
Expand All @@ -420,14 +423,20 @@ SIMULATOR_ARM64_OBJC_CFLAGS=$(COMMON_SIMULATOR_OBJC_CFLAGS) $(SIMULATOR_ARM64_CF
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$(MACOS_SDK_VERSION).sdk \
-isystem $(XCODE_DEVELOPER_ROOT)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(MACOS_SDK_VERSION).sdk/System/iOSSupport/usr/include \
-iframework $(XCODE_DEVELOPER_ROOT)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(MACOS_SDK_VERSION).sdk/System/iOSSupport/System/Library/Frameworks
-iframework $(XCODE_DEVELOPER_ROOT)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(MACOS_SDK_VERSION).sdk/System/iOSSupport/System/Library/Frameworks \
-L$(SIMULATOR_SDK)/usr/lib/swift \
-L$(XCODE_DEVELOPER_ROOT)/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator \
-Wno-unused-command-line-argument
MACCATALYST_OBJC_CFLAGS=$(MACCATALYST_COMMON_CFLAGS) -fobjc-abi-version=2 -fobjc-legacy-dispatch $(OBJC_CFLAGS)
MACCATALYST_CFLAGS=$(MACCATALYST_COMMON_CFLAGS)

MACCATALYST_COMMON_CFLAGS=$(CFLAGS) -g $(IOS_COMMON_DEFINES) \
-isysroot $(XCODE_DEVELOPER_ROOT)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(MACOS_SDK_VERSION).sdk \
-isystem $(XCODE_DEVELOPER_ROOT)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(MACOS_SDK_VERSION).sdk/System/iOSSupport/usr/include \
-iframework $(XCODE_DEVELOPER_ROOT)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(MACOS_SDK_VERSION).sdk/System/iOSSupport/System/Library/Frameworks
-iframework $(XCODE_DEVELOPER_ROOT)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(MACOS_SDK_VERSION).sdk/System/iOSSupport/System/Library/Frameworks \
-L$(XCODE_DEVELOPER_ROOT)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(MACOS_SDK_VERSION).sdk/usr/lib/swift \
-L$(XCODE_DEVELOPER_ROOT)/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx \
-Wno-unused-command-line-argument
MACCATALYST_COMMON_OBJC_CFLAGS=$(MACCATALYST_COMMON_CFLAGS) -fobjc-abi-version=2 -fobjc-legacy-dispatch $(OBJC_CFLAGS)
MACCATALYST_X86_64_OBJC_CFLAGS=$(MACCATALYST_COMMON_OBJC_CFLAGS) -target x86_64-apple-ios$(MIN_MACCATALYST_SDK_VERSION)-macabi -arch x86_64
MACCATALYST_X86_64_CFLAGS=$(MACCATALYST_COMMON_CFLAGS) -target x86_64-apple-ios$(MIN_MACCATALYST_SDK_VERSION)-macabi -arch x86_64
Expand All @@ -448,9 +457,13 @@ MACCATALYST_CSC=$(SYSTEM_CSC) -features:strict -nostdlib -noconfig -r:$(MONOTOUC
DEVICE_OBJC_CFLAGS=$(OBJC_CFLAGS)

DEVICE_SDK=$(XCODE_DEVELOPER_ROOT)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS$(IOS_SDK_VERSION).sdk
DEVICE7_CFLAGS= -arch armv7 -mno-thumb -miphoneos-version-min=$(MIN_IOS_SDK_VERSION) -isysroot $(DEVICE_SDK) $(CFLAGS) $(IOS_COMMON_DEFINES)
DEVICE7S_CFLAGS=-arch armv7s -mno-thumb -miphoneos-version-min=$(MIN_IOS_SDK_VERSION) -isysroot $(DEVICE_SDK) $(CFLAGS) $(IOS_COMMON_DEFINES)
DEVICE64_CFLAGS=-arch arm64 -miphoneos-version-min=$(MIN_IOS_SDK_VERSION) -isysroot $(DEVICE_SDK) $(CFLAGS) $(IOS_COMMON_DEFINES)
DEVICE_SWIFT_CFLAGS=\
-L$(DEVICE_SDK)/usr/lib/swift \
-L$(XCODE_DEVELOPER_ROOT)/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos \
-Wno-unused-command-line-argument
DEVICE7_CFLAGS= -arch armv7 -mno-thumb -miphoneos-version-min=$(MIN_IOS_SDK_VERSION) -isysroot $(DEVICE_SDK) $(CFLAGS) $(IOS_COMMON_DEFINES) $(DEVICE_SWIFT_CFLAGS)
DEVICE7S_CFLAGS=-arch armv7s -mno-thumb -miphoneos-version-min=$(MIN_IOS_SDK_VERSION) -isysroot $(DEVICE_SDK) $(CFLAGS) $(IOS_COMMON_DEFINES) $(DEVICE_SWIFT_CFLAGS)
DEVICE64_CFLAGS=-arch arm64 -miphoneos-version-min=$(MIN_IOS_SDK_VERSION) -isysroot $(DEVICE_SDK) $(CFLAGS) $(IOS_COMMON_DEFINES) $(DEVICE_SWIFT_CFLAGS)
DEVICE7_OBJC_CFLAGS =$(DEVICE7_CFLAGS) $(DEVICE_OBJC_CFLAGS)
DEVICE7S_OBJC_CFLAGS=$(DEVICE7S_CFLAGS) $(DEVICE_OBJC_CFLAGS)
DEVICE64_OBJC_CFLAGS=$(DEVICE64_CFLAGS) $(DEVICE_OBJC_CFLAGS)
Expand Down Expand Up @@ -488,21 +501,33 @@ XAMARIN_TVSIMULATOR_SDK = $(MONOTOUCH_PREFIX)/SDKs/Xamarin.AppleTVSimulator.s
XAMARIN_TVOS_SDK = $(MONOTOUCH_PREFIX)/SDKs/Xamarin.AppleTVOS.sdk

SIMULATORTV_SDK = $(XCODE_DEVELOPER_ROOT)/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator$(TVOS_SDK_VERSION).sdk
SIMULATORTV_CFLAGS = -arch x86_64 -mtvos-simulator-version-min=$(MIN_TVOS_SDK_VERSION) -isysroot $(SIMULATORTV_SDK) $(CFLAGS) -g $(IOS_COMMON_DEFINES)
SIMULATORTV_ARM64_CFLAGS = -arch arm64 -mtvos-simulator-version-min=$(MIN_TVOS_SDK_VERSION) -isysroot $(SIMULATORTV_SDK) $(CFLAGS) -g $(IOS_COMMON_DEFINES)
SIMULATORTV_CFLAGS = -arch x86_64 -mtvos-simulator-version-min=$(MIN_TVOS_SDK_VERSION) -isysroot $(SIMULATORTV_SDK) $(CFLAGS) -g $(IOS_COMMON_DEFINES) \
-L$(SIMULATORTV_SDK)/usr/lib/swift \
-L$(XCODE_DEVELOPER_ROOT)/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/appletvsimulator \
-Wno-unused-command-line-argument
SIMULATORTV_ARM64_CFLAGS = -arch arm64 -mtvos-simulator-version-min=$(MIN_TVOS_SDK_VERSION) -isysroot $(SIMULATORTV_SDK) $(CFLAGS) -g $(IOS_COMMON_DEFINES) \
-L$(SIMULATORTV_SDK)/usr/lib/swift \
-L$(XCODE_DEVELOPER_ROOT)/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/appletvsimulator \
-Wno-unused-command-line-argument
SIMULATORTV_OBJC_CFLAGS = $(SIMULATORTV_CFLAGS) $(COMMON_SIMULATOR_OBJC_CFLAGS)
SIMULATORTV_ARM64_OBJC_CFLAGS = $(SIMULATORTV_ARM64_CFLAGS) $(COMMON_SIMULATOR_OBJC_CFLAGS)

DEVICETV_SDK = $(XCODE_DEVELOPER_ROOT)/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS$(TVOS_SDK_VERSION).sdk
DEVICETV_CFLAGS = -arch arm64 -mtvos-version-min=$(MIN_TVOS_SDK_VERSION) -isysroot $(DEVICETV_SDK) $(CFLAGS) $(IOS_COMMON_DEFINES)
DEVICETV_CFLAGS = -arch arm64 -mtvos-version-min=$(MIN_TVOS_SDK_VERSION) -isysroot $(DEVICETV_SDK) $(CFLAGS) $(IOS_COMMON_DEFINES)\
-L$(DEVICETV_SDK)/usr/lib/swift \
-L$(XCODE_DEVELOPER_ROOT)/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/appletvos \
-Wno-unused-command-line-argument
DEVICETV_OBJC_CFLAGS = $(DEVICETV_CFLAGS) $(DEVICE_OBJC_CFLAGS)

# macOS

XAMARIN_MACOS_SDK = $(MAC_FRAMEWORK_CURRENT_DIR)/SDKs/Xamarin.macOS.sdk

MAC_OBJC_CFLAGS= -mmacosx-version-min=$(MIN_MACOS_SDK_VERSION) -DMONOMAC -DMIN_XM_MONO_VERSION=\"$(MIN_XM_MONO_VERSION)\" $(CFLAGS) $(OBJC_CFLAGS)
MAC_CFLAGS = -mmacosx-version-min=$(MIN_MACOS_SDK_VERSION) -DMONOMAC -g -DMIN_XM_MONO_VERSION=\"$(MIN_XM_MONO_VERSION)\" $(CFLAGS)
MAC_CFLAGS = -mmacosx-version-min=$(MIN_MACOS_SDK_VERSION) -DMONOMAC -g -DMIN_XM_MONO_VERSION=\"$(MIN_XM_MONO_VERSION)\" $(CFLAGS) \
-L$(XCODE_DEVELOPER_ROOT)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(MACOS_SDK_VERSION).sdk/usr/lib/swift \
-L$(XCODE_DEVELOPER_ROOT)/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx \
-Wno-unused-command-line-argument
MAC_LDFLAGS = -mmacosx-version-min=$(MIN_MACOS_SDK_VERSION) -framework AppKit

# Swift compiler flags
Expand All @@ -529,7 +554,7 @@ WATCHOS_DEVICE_COMMON_SWIFTFLAGS=$(COMMON_SWIFTFLAGS) -sdk $(DEVICEWATCH_SDK)
WATCHOS_DEVICE_ARM64_32_SWIFTFLAGS=$(WATCHOS_DEVICE_COMMON_SWIFTFLAGS) -target arm64_32-apple-watchos$(MIN_WATCHOS_SDK_VERSION)
WATCHOS_DEVICE_ARMV7K_SWIFTFLAGS=$(WATCHOS_DEVICE_COMMON_SWIFTFLAGS) -target armv7k-apple-watchos$(MIN_WATCHOS_SDK_VERSION)

MACCATALYST_COMMON_SWIFTFLAGS=$(COMMON_SWIFTFLAGS) -sdk $(XCODE_MAC_SDKROOT)
MACCATALYST_COMMON_SWIFTFLAGS=$(COMMON_SWIFTFLAGS) -sdk $(XCODE_MAC_SDKROOT) -Fsystem $(XCODE_MAC_SDKROOT)/System/iOSSupport/System/Library/Frameworks
MACCATALYST_ARM64_SWIFTFLAGS=$(MACCATALYST_COMMON_SWIFTFLAGS) -target arm64-apple-ios$(MIN_MACCATALYST_SDK_VERSION)-macabi
MACCATALYST_X64_SWIFTFLAGS=$(MACCATALYST_COMMON_SWIFTFLAGS) -target x86_64-apple-ios$(MIN_MACCATALYST_SDK_VERSION)-macabi

Expand Down
6 changes: 6 additions & 0 deletions docs/preview-apis.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ We've tentatively set .NET 11 as the release when we'll stop marking FSKit as pr

The diagnostic id for FSKit is APL0002.

## StoreKit.AppStore.RequestReview (APL0004)

The
[AppStore.RequestReview](https://developer.apple.com/documentation/storekit/appstore/3954432-requestreview/)
method is Swift API we've bound manually, and as such it's marked as experimental until .NET 10.

[1]: https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.codeanalysis.experimentalattribute?view=net-8.0

## Rgen (APL0003)
Expand Down
39 changes: 39 additions & 0 deletions mk/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ define NativeCompilationTemplate
.libs/iphonesimulator/%$(1).x86_64.dylib: %.swift | .libs/iphonesimulator
$$(call Q_2,SWIFT, [iphonesimulator]) $(SWIFTC) $(IOS_SIMULATOR_X64_SWIFTFLAGS) $$< -o $$@

.libs/iphonesimulator/%$(1).x86_64.o: %.swift | .libs/iphonesimulator
$$(call Q_2,SWIFT, [iphonesimulator]) $(SWIFTC) $(IOS_SIMULATOR_X64_SWIFTFLAGS) $$< -o $$@ -emit-object

.libs/iphonesimulator/%$(1).x86_64.dylib: | .libs/iphonesimulator
$$(call Q_2,LD, [iphonesimulator]) $(SIMULATOR_CC) $(SIMULATOR64_CFLAGS) $$(EXTRA_FLAGS) -dynamiclib -o $$@ $$^ -L$(IOS_DESTDIR)$(XAMARIN_IOSSIMULATOR_SDK)/lib -fapplication-extension

Expand All @@ -72,6 +75,9 @@ define NativeCompilationTemplate
.libs/iphonesimulator/%$(1).arm64.dylib: %.swift | .libs/iphonesimulator
$$(call Q_2,SWIFT, [iphonesimulator]) $(SWIFTC) $(IOS_SIMULATOR_ARM64_SWIFTFLAGS) $$< -o $$@

.libs/iphonesimulator/%$(1).arm64.o: %.swift | .libs/iphonesimulator
$$(call Q_2,SWIFT, [iphonesimulator]) $(SWIFTC) $(IOS_SIMULATOR_ARM64_SWIFTFLAGS) $$< -o $$@ -emit-object

.libs/iphonesimulator/%$(1).arm64.dylib: | .libs/iphonesimulator
$$(call Q_2,LD, [iphonesimulator]) $(SIMULATOR_CC) $(SIMULATOR_ARM64_CFLAGS) $$(EXTRA_FLAGS) -dynamiclib -o $$@ $$^ -L$(IOS_DESTDIR)$(XAMARIN_IOSSIMULATOR_SDK)/lib -fapplication-extension

Expand Down Expand Up @@ -117,6 +123,9 @@ define NativeCompilationTemplate
.libs/iphoneos/%$(1).arm64.dylib: %.swift | .libs/iphoneos
$$(call Q_2,SWIFT, [iphoneos]) $(SWIFTC) $(IOS_DEVICE_ARM64_SWIFTFLAGS) $$< -o $$@

.libs/iphoneos/%$(1).arm64.o: %.swift | .libs/iphoneos
$$(call Q_2,SWIFT, [iphoneos]) $(SWIFTC) $(IOS_DEVICE_ARM64_SWIFTFLAGS) $$< -o $$@ -emit-object

.libs/iphoneos/%$(1).arm64.dylib: | .libs/iphoneos
$$(call Q_2,LD, [iphoneos]) $(DEVICE_CC) $(DEVICE64_CFLAGS) $$(EXTRA_FLAGS) -dynamiclib -o $$@ $$^ -L$(IOS_DESTDIR)$(XAMARIN_IPHONEOS_SDK)/lib -fapplication-extension

Expand All @@ -137,6 +146,9 @@ define NativeCompilationTemplate
.libs/maccatalyst/%$(1).x86_64.dylib: %.swift | .libs/maccatalyst
$$(call Q_2,SWIFT, [maccatalyst]) $(SWIFTC) $(MACCATALYST_X64_SWIFTFLAGS) $$< -o $$@

.libs/maccatalyst/%$(1).x86_64.o: %.swift | .libs/maccatalyst
$$(call Q_2,SWIFT, [maccatalyst]) $(SWIFTC) $(MACCATALYST_X64_SWIFTFLAGS) $$< -o $$@ -emit-object

.libs/maccatalyst/%$(1).x86_64.dylib: | .libs/maccatalyst
$$(call Q_2,LD, [maccatalyst]) $(XCODE_CC) $(MACCATALYST_X86_64_CFLAGS) $$(EXTRA_FLAGS) -dynamiclib -o $$@ $$^ -L$(IOS_DESTDIR)$(XAMARIN_MACCATALYST_SDK)/lib -fapplication-extension

Expand All @@ -155,6 +167,9 @@ define NativeCompilationTemplate
.libs/maccatalyst/%$(1).arm64.dylib: %.swift | .libs/maccatalyst
$$(call Q_2,SWIFT, [maccatalyst]) $(SWIFTC) $(MACCATALYST_ARM64_SWIFTFLAGS) $$< -o $$@

.libs/maccatalyst/%$(1).arm64.o: %.swift | .libs/maccatalyst
$$(call Q_2,SWIFT, [maccatalyst]) $(SWIFTC) $(MACCATALYST_ARM64_SWIFTFLAGS) $$< -o $$@ -emit-object

.libs/maccatalyst/%$(1).arm64.dylib: | .libs/maccatalyst
$$(call Q_2,LD, [maccatalyst]) $(XCODE_CC) $(MACCATALYST_ARM64_CFLAGS) $$(EXTRA_FLAGS) -dynamiclib -o $$@ $$^ -L$(IOS_DESTDIR)$(XAMARIN_MACCATALYST_SDK)/lib -fapplication-extension

Expand Down Expand Up @@ -247,6 +262,9 @@ define NativeCompilationTemplate
.libs/tvsimulator/%$(1).x86_64.dylib: %.swift | .libs/tvsimulator
$$(call Q_2,SWIFT, [tvsimulator]) $(SWIFTC) $(TVOS_SIMULATOR_X64_SWIFTFLAGS) $$< -o $$@

.libs/tvsimulator/%$(1).x86_64.o: %.swift | .libs/tvsimulator
$$(call Q_2,SWIFT, [tvsimulator]) $(SWIFTC) $(TVOS_SIMULATOR_X64_SWIFTFLAGS) $$< -o $$@ -emit-object

.libs/tvsimulator/%$(1).x86_64.dylib: | .libs/tvsimulator
$$(call Q_2,LD, [tvsimulator]) $(SIMULATOR_CC) $(SIMULATORTV_CFLAGS) $$(EXTRA_FLAGS) -dynamiclib -o $$@ $$^ -L$(IOS_DESTDIR)$(XAMARIN_TVSIMULATOR_SDK)/lib -fapplication-extension

Expand All @@ -267,6 +285,9 @@ define NativeCompilationTemplate
.libs/tvsimulator/%$(1).arm64.dylib: %.swift | .libs/tvsimulator
$$(call Q_2,SWIFT, [tvsimulator]) $(SWIFTC) $(TVOS_SIMULATOR_ARM64_SWIFTFLAGS) $$< -o $$@

.libs/tvsimulator/%$(1).arm64.o: %.swift | .libs/tvsimulator
$$(call Q_2,SWIFT, [tvsimulator]) $(SWIFTC) $(TVOS_SIMULATOR_ARM64_SWIFTFLAGS) $$< -o $$@ -emit-object

.libs/tvsimulator/%$(1).arm64.dylib: | .libs/tvsimulator
$$(call Q_2,LD, [tvsimulator]) $(SIMULATOR_CC) $(SIMULATORTV_ARM64_CFLAGS) $$(EXTRA_FLAGS) -dynamiclib -o $$@ $$^ -L$(IOS_DESTDIR)$(XAMARIN_TVSIMULATOR_SDK)/lib -fapplication-extension

Expand All @@ -287,6 +308,9 @@ define NativeCompilationTemplate
.libs/tvos/%$(1).arm64.dylib: %.swift | .libs/tvos
$$(call Q_2,SWIFT, [tvos]) $(SWIFTC) $(TVOS_DEVICE_ARM64_SWIFTFLAGS) $$< -o $$@

.libs/tvos/%$(1).arm64.o: %.swift | .libs/tvos
$$(call Q_2,SWIFT, [tvos]) $(SWIFTC) $(TVOS_DEVICE_ARM64_SWIFTFLAGS) $$< -o $$@ -emit-object

.libs/tvos/%$(1).arm64.dylib: | .libs/tvos
$$(call Q_2,LD, [tvos]) $(DEVICE_CC) $(DEVICETV_CFLAGS) $$(EXTRA_FLAGS) -dynamiclib -o $$@ $$^ -L$(IOS_DESTDIR)$(XAMARIN_TVOS_SDK)/lib -fapplication-extension

Expand All @@ -307,6 +331,15 @@ define NativeCompilationTemplate
.libs/mac/%$(1).x86_64.dylib: %.swift | .libs/mac
$$(call Q_2,SWIFT, [mac]) $(SWIFTC) $(MACOS_X64_SWIFTFLAGS) $$< -o $$@

.libs/mac/%$(1).x86_64.o: %.swift | .libs/mac
$$(call Q_2,SWIFT, [mac]) $(SWIFTC) $(MACOS_X64_SWIFTFLAGS) $$< -o $$@ -emit-object

.libs/macos/%$(1).x86_64.dylib: %.swift | .libs/mac
$$(call Q_2,SWIFT, [macos]) $(SWIFTC) $(MACOS_X64_SWIFTFLAGS) $$< -o $$@

.libs/macos/%$(1).x86_64.o: %.swift | .libs/mac
$$(call Q_2,SWIFT, [mac]) $(SWIFTC) $(MACOS_X64_SWIFTFLAGS) $$< -o $$@ -emit-object

.libs/macos/%$(1).x86_64.dylib: %.swift | .libs/mac
$$(call Q_2,SWIFT, [macos]) $(SWIFTC) $(MACOS_X64_SWIFTFLAGS) $$< -o $$@

Expand All @@ -328,9 +361,15 @@ define NativeCompilationTemplate
.libs/mac/%$(1).arm64.dylib: %.swift | .libs/mac
$$(call Q_2,SWIFT, [mac]) $(SWIFTC) $(MACOS_ARM64_SWIFTFLAGS) $$< -o $$@

.libs/mac/%$(1).arm64.o: %.swift | .libs/mac
$$(call Q_2,SWIFT, [mac]) $(SWIFTC) $(MACOS_ARM64_SWIFTFLAGS) $$< -o $$@ -emit-object

.libs/macos/%$(1).arm64.dylib: %.swift | .libs/mac
$$(call Q_2,SWIFT, [macos]) $(SWIFTC) $(MACOS_ARM64_SWIFTFLAGS) $$< -o $$@

.libs/macos/%$(1).arm64.o: %.swift | .libs/mac
$$(call Q_2,SWIFT, [macos]) $(SWIFTC) $(MACOS_ARM64_SWIFTFLAGS) $$< -o $$@ -emit-object

.libs/mac/%$(1).arm64.dylib: | .libs/mac
$$(call Q_2,LD, [mac]) $(MAC_CC) $(MAC_CFLAGS) $$(EXTRA_FLAGS) -arch arm64 -dynamiclib -o $$@ $$^ -L$(MAC_DESTDIR)$(XAMARIN_MACOS_SDK)/lib -fapplication-extension

Expand Down
4 changes: 2 additions & 2 deletions runtime/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ SHIPPED_HEADERS += \
xamarin/monovm-bridge.h \
xamarin/coreclr-bridge.h \

SHARED_SOURCES += mono-runtime.m bindings.m bindings-generated.m shared.m runtime.m trampolines.m trampolines-invoke.m xamarin-support.m nsstring-localization.m trampolines-varargs.m monovm-bridge.m coreclr-bridge.m nativeaot-bridge.m
SHARED_SOURCES += mono-runtime.m bindings.m bindings-generated.m shared.m runtime.m trampolines.m trampolines-invoke.m xamarin-support.m nsstring-localization.m trampolines-varargs.m monovm-bridge.m coreclr-bridge.m nativeaot-bridge.m swift-functions.swift
SHARED_I386_SOURCES += trampolines-i386.m trampolines-i386-asm.s trampolines-i386-objc_msgSend.s trampolines-i386-objc_msgSendSuper.s trampolines-i386-objc_msgSend_stret.s trampolines-i386-objc_msgSendSuper_stret.s
SHARED_X86_64_SOURCES += trampolines-x86_64.m trampolines-x86_64-asm.s trampolines-x86_64-objc_msgSend.s trampolines-x86_64-objc_msgSendSuper.s trampolines-x86_64-objc_msgSend_stret.s trampolines-x86_64-objc_msgSendSuper_stret.s
SHARED_ARM64_SOURCES += trampolines-arm64.m trampolines-arm64-asm.s trampolines-arm64-objc_msgSend.s trampolines-arm64-objc_msgSendSuper.s
Expand Down Expand Up @@ -99,7 +99,7 @@ MONOTOUCH_FRAMEWORKS = \
Xamarin \
Xamarin-debug \

MONOTOUCH_SOURCE_STEMS = $(patsubst %.s,%,$(patsubst %.m,%,$(SHARED_SOURCES) $(MONOTOUCH_SOURCES)))
MONOTOUCH_SOURCE_STEMS = $(patsubst %.swift,%,$(patsubst %.s,%,$(patsubst %.m,%,$(SHARED_SOURCES) $(MONOTOUCH_SOURCES))))
MONOTOUCH_I386_SOURCE_STEMS = $(patsubst %.s,%,$(patsubst %.m,%,$(SHARED_I386_SOURCES)))
MONOTOUCH_X86_64_SOURCE_STEMS = $(patsubst %.s,%,$(patsubst %.m,%,$(SHARED_X86_64_SOURCES)))
MONOTOUCH_ARM64_SOURCE_STEMS = $(patsubst %.s,%,$(patsubst %.m,%,$(SHARED_ARM64_SOURCES)))
Expand Down
29 changes: 29 additions & 0 deletions runtime/swift-functions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#if os(macOS)
import AppKit
#endif
import Foundation
import StoreKit
#if !os(macOS)
import UIKit
#endif

@objc(XamarinSwiftFunctions)
public class XamarinSwiftFunctions : NSObject {
#if os(macOS)
@MainActor
@objc(requestReview:)
@available(macOS 13, *)
public static func StoreKit_RequestReview(scene: NSViewController)
{
AppStore.requestReview(in: scene)
}
#elseif !os(tvOS)
@MainActor
@objc(requestReview:)
@available(iOS 16, macCatalyst 16, *)
public static func StoreKit_RequestReview(scene: UIWindowScene)
{
AppStore.requestReview(in: scene)
}
#endif
}
Loading

0 comments on commit a198a87

Please sign in to comment.