From cfbfd01f3843a4175177d854f82ae7f1442f89f3 Mon Sep 17 00:00:00 2001 From: Eric Warmenhoven Date: Tue, 10 Sep 2024 00:27:29 -0400 Subject: [PATCH] iOS: Last bits of iOS 12 support, including loading an older MoltenVK library (#16982) --- gfx/common/vulkan_common.c | 5 ++++- input/drivers/cocoa_input.m | 2 +- pkg/apple/RetroArch_iOS13.xcodeproj/project.pbxproj | 4 ++-- pkg/apple/iOS/AppStore.xcconfig | 2 +- pkg/apple/make-frameworks.sh | 12 ++++++++++++ 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/gfx/common/vulkan_common.c b/gfx/common/vulkan_common.c index 20840190f9..93fd92c48d 100644 --- a/gfx/common/vulkan_common.c +++ b/gfx/common/vulkan_common.c @@ -2329,7 +2329,10 @@ bool vulkan_context_init(gfx_ctx_vulkan_data_t *vk, #ifdef _WIN32 vulkan_library = dylib_load("vulkan-1.dll"); #elif __APPLE__ - vulkan_library = dylib_load("MoltenVK"); + if (__builtin_available(macOS 10.15, iOS 13, tvOS 12, *)) + vulkan_library = dylib_load("MoltenVK"); + if (!vulkan_library) + vulkan_library = dylib_load("MoltenVK-v1.2.7.framework"); #else vulkan_library = dylib_load("libvulkan.so.1"); if (!vulkan_library) diff --git a/input/drivers/cocoa_input.m b/input/drivers/cocoa_input.m index 5a76ea85d0..b9d694a39b 100644 --- a/input/drivers/cocoa_input.m +++ b/input/drivers/cocoa_input.m @@ -637,7 +637,7 @@ static bool cocoa_input_set_sensor_state(void *data, unsigned port, return false; #ifdef HAVE_MFI - if (@available(iOS 14.0, macOS 11.0, *)) + if (@available(iOS 14.0, macOS 11.0, tvOS 14.0, *)) { for (GCController *controller in [GCController controllers]) { diff --git a/pkg/apple/RetroArch_iOS13.xcodeproj/project.pbxproj b/pkg/apple/RetroArch_iOS13.xcodeproj/project.pbxproj index 75fcb7fe13..4fd367dba2 100644 --- a/pkg/apple/RetroArch_iOS13.xcodeproj/project.pbxproj +++ b/pkg/apple/RetroArch_iOS13.xcodeproj/project.pbxproj @@ -1943,7 +1943,7 @@ INFOPLIST_KEY_CFBundleDisplayName = RetroArch; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.entertainment"; IOS_BUNDLE_IDENTIFIER = com.libretro.RetroArchiOS11; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LIBRARY_SEARCH_PATHS = ( "$(PROJECT_DIR)/iOS/modules", "@executable_path/Frameworks", @@ -2005,7 +2005,7 @@ INFOPLIST_KEY_CFBundleDisplayName = RetroArch; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.entertainment"; IOS_BUNDLE_IDENTIFIER = com.libretro.RetroArchiOS11; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LIBRARY_SEARCH_PATHS = ( "$(PROJECT_DIR)/iOS/modules", "@executable_path/Frameworks", diff --git a/pkg/apple/iOS/AppStore.xcconfig b/pkg/apple/iOS/AppStore.xcconfig index ef8f713f46..8ef4228cd6 100644 --- a/pkg/apple/iOS/AppStore.xcconfig +++ b/pkg/apple/iOS/AppStore.xcconfig @@ -17,5 +17,5 @@ IOS_CODE_SIGN_ENTITLEMENTS = iOS/RetroArchiOS.entitlements TVOS_CODE_SIGN_ENTITLEMENTS = tvOS/RetroArchTV.entitlements TVOS_TOPSHELF_CODE_SIGN_ENTITLEMENTS = tvOS/RetroArchTopShelf.entitlements -RA_IPHONEOS_DEPLOYMENT_TARGET = 14.2 +RA_IPHONEOS_DEPLOYMENT_TARGET = 12.0 TVOS_DEPLOYMENT_TARGET = 14.2 diff --git a/pkg/apple/make-frameworks.sh b/pkg/apple/make-frameworks.sh index e4a25f83b2..3e1680e8ba 100755 --- a/pkg/apple/make-frameworks.sh +++ b/pkg/apple/make-frameworks.sh @@ -41,6 +41,10 @@ for dylib in $(find "$BASE_DIR"/modules -maxdepth 1 -type f -regex '.*libretro.* fwDir="${OUTDIR}/${fwName}.framework" mkdir -p "$fwDir" lipo -create "$dylib" -output "$fwDir/$fwName" + if [ "$PLATFORM_FAMILY_NAME" = "iOS" ] ; then + build_sdk=$(vtool -show-build "$dylib" | grep sdk | awk '{print $2}') + vtool -set-version-min ios "${IPHONEOS_DEPLOYMENT_TARGET}" "${build_sdk}" -replace -output "$fwDir/$fwName" "$fwDir/$fwName" + fi sed -e "s,%CORE%,$fwName," -e "s,%BUNDLE%,$fwName," -e "s,%IDENTIFIER%,$fwName," iOS/fw.tmpl > "$fwDir/Info.plist" echo "signing $fwName" codesign --force --verbose --sign "${CODE_SIGN_IDENTITY_FOR_ITEMS}" "$fwDir" @@ -60,3 +64,11 @@ if [ -d "${MOLTENVK_XCFRAMEWORK}/${MVK_PLATFORM_SUBDIR}/MoltenVK.framework" ] ; cp -r "${MOLTENVK_XCFRAMEWORK}/${MVK_PLATFORM_SUBDIR}/MoltenVK.framework" "${OUTDIR}" codesign --force --verbose --sign "${CODE_SIGN_IDENTITY_FOR_ITEMS}" "${OUTDIR}/MoltenVK.framework" fi + +# iOS 12 needs an older version of MoltenVK +if [ -n "$MOLTENVK_LEGACY_XCFRAMEWORK_PATH" -a -d "${MOLTENVK_LEGACY_XCFRAMEWORK_PATH}/${MVK_PLATFORM_SUBDIR}/MoltenVK-${MOLTENVK_LEGACY_VERSION}.framework" ] ; then + echo copying legacy moltenvk from "${MOLTENVK_LEGACY_XCFRAMEWORK_PATH}/${MVK_PLATFORM_SUBDIR}/MoltenVK-${MOLTENVK_LEGACY_VERSION}.framework" + cp -r "${MOLTENVK_LEGACY_XCFRAMEWORK_PATH}/${MVK_PLATFORM_SUBDIR}/MoltenVK-${MOLTENVK_LEGACY_VERSION}.framework" "${OUTDIR}" + codesign --force --verbose --sign "${CODE_SIGN_IDENTITY_FOR_ITEMS}" "${OUTDIR}/MoltenVK-${MOLTENVK_LEGACY_VERSION}.framework/MoltenVK-${MOLTENVK_LEGACY_VERSION}" + codesign --force --verbose --sign "${CODE_SIGN_IDENTITY_FOR_ITEMS}" "${OUTDIR}/MoltenVK-${MOLTENVK_LEGACY_VERSION}.framework" +fi