Skip to content

Commit

Permalink
Bumped deployment requirements for Apple platforms
Browse files Browse the repository at this point in the history
We require at least Xcode 12.2 and macOS SDK 11 to build. We support deploying to macOS 10.13, iOS 11.0, and tvOS 11.0.

This cleans up the code significantly
  • Loading branch information
slouken committed Jan 14, 2025
1 parent f731741 commit ec55ed6
Show file tree
Hide file tree
Showing 29 changed files with 266 additions and 741 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/create-test-plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,15 +469,15 @@ def spec_to_job(spec: JobSpec, key: str, trackmem_symbol_names: bool) -> JobDeta
job.cmake_arguments.extend([
"-DCMAKE_SYSTEM_NAME=iOS",
"-DCMAKE_OSX_ARCHITECTURES=\"arm64\"",
"-DCMAKE_OSX_DEPLOYMENT_TARGET=9.0",
"-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0",
])
case SdlPlatform.Tvos:
if spec.xcode:
job.xcode_sdk = 'appletvos'
job.cmake_arguments.extend([
"-DCMAKE_SYSTEM_NAME=tvOS",
"-DCMAKE_OSX_ARCHITECTURES=\"arm64\"",
"-DCMAKE_OSX_DEPLOYMENT_TARGET=9.0",
"-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0",
])
case SdlPlatform.MacOS:
if spec.apple_framework:
Expand All @@ -486,15 +486,15 @@ def spec_to_job(spec: JobSpec, key: str, trackmem_symbol_names: bool) -> JobDeta
job.test_pkg_config = False
job.cmake_arguments.extend((
"'-DCMAKE_OSX_ARCHITECTURES=x86_64;arm64'",
"-DCMAKE_OSX_DEPLOYMENT_TARGET=10.11",
"-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13",
"-DSDL_FRAMEWORK=ON",
))
job.shared_lib = SharedLibType.FRAMEWORK
else:
job.clang_tidy = True
job.cmake_arguments.extend((
"-DCMAKE_OSX_ARCHITECTURES=arm64",
"-DCMAKE_OSX_DEPLOYMENT_TARGET=10.11",
"-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13",
"-DCLANG_TIDY_BINARY=$(brew --prefix llvm)/bin/clang-tidy",
))
job.shared_lib = SharedLibType.DYLIB
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ jobs:
-DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount_point }}" \
-DCMAKE_SYSTEM_NAME=Darwin \
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.11 \
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13 \
-Werror=dev \
-B build_darwin
cmake --build build_darwin --config Release --verbose
Expand All @@ -175,7 +175,7 @@ jobs:
-DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount_point }}/SDL3.xcframework/macos-arm64_x86_64" \
-DCMAKE_SYSTEM_NAME=Darwin \
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.11 \
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13 \
-Werror=dev \
-B build_darwin_2
cmake --build build_darwin --config Release --verbose
Expand All @@ -188,7 +188,7 @@ jobs:
-DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount_point }}" \
-DCMAKE_SYSTEM_NAME=iOS \
-DCMAKE_OSX_ARCHITECTURES="arm64" \
-DCMAKE_OSX_DEPLOYMENT_TARGET=9.0 \
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
-Werror=dev \
-B build_ios
cmake --build build_ios --config Release --verbose
Expand All @@ -201,7 +201,7 @@ jobs:
-DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount_point }}" \
-DCMAKE_SYSTEM_NAME=tvOS \
-DCMAKE_OSX_ARCHITECTURES="arm64" \
-DCMAKE_OSX_DEPLOYMENT_TARGET=9.0 \
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
-Werror=dev \
-B build_tvos
cmake --build build_tvos --config Release --verbose
Expand All @@ -217,7 +217,7 @@ jobs:
-DCMAKE_SYSTEM_NAME=iOS \
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
-DCMAKE_OSX_SYSROOT="${sysroot}" \
-DCMAKE_OSX_DEPLOYMENT_TARGET=9.0 \
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
-Werror=dev \
-B build_ios_simulator
cmake --build build_ios_simulator --config Release --verbose
Expand All @@ -233,7 +233,7 @@ jobs:
-DCMAKE_SYSTEM_NAME=tvOS \
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
-DCMAKE_OSX_SYSROOT="${sysroot}" \
-DCMAKE_OSX_DEPLOYMENT_TARGET=9.0 \
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
-Werror=dev \
-B build_tvos_simulator
cmake --build build_tvos_simulator --config Release --verbose
Expand Down
12 changes: 6 additions & 6 deletions Xcode/SDL/SDL.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3073,7 +3073,7 @@
/usr/X11R6/include,
);
INFOPLIST_FILE = "Info-Framework.plist";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand All @@ -3083,15 +3083,15 @@
"@executable_path/../Frameworks",
"@loader_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.11;
MACOSX_DEPLOYMENT_TARGET = 10.13;
MARKETING_VERSION = 3.1.9;
OTHER_LDFLAGS = "$(CONFIG_FRAMEWORK_LDFLAGS)";
PRODUCT_BUNDLE_IDENTIFIER = org.libsdl.SDL3;
PRODUCT_NAME = SDL3;
STRIP_STYLE = "non-global";
SUPPORTED_PLATFORMS = "xrsimulator xros macosx iphonesimulator iphoneos appletvsimulator appletvos";
SUPPORTS_MACCATALYST = YES;
TVOS_DEPLOYMENT_TARGET = 9.0;
TVOS_DEPLOYMENT_TARGET = 11.0;
XROS_DEPLOYMENT_TARGET = 1.0;
};
name = Release;
Expand Down Expand Up @@ -3134,7 +3134,7 @@
/usr/X11R6/include,
);
INFOPLIST_FILE = "Info-Framework.plist";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand All @@ -3144,7 +3144,7 @@
"@executable_path/../Frameworks",
"@loader_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.11;
MACOSX_DEPLOYMENT_TARGET = 10.13;
MARKETING_VERSION = 3.1.9;
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = "$(CONFIG_FRAMEWORK_LDFLAGS)";
Expand All @@ -3153,7 +3153,7 @@
STRIP_INSTALLED_PRODUCT = NO;
SUPPORTED_PLATFORMS = "xrsimulator xros macosx iphonesimulator iphoneos appletvsimulator appletvos";
SUPPORTS_MACCATALYST = YES;
TVOS_DEPLOYMENT_TARGET = 9.0;
TVOS_DEPLOYMENT_TARGET = 11.0;
XROS_DEPLOYMENT_TARGET = 1.0;
};
name = Debug;
Expand Down
9 changes: 3 additions & 6 deletions docs/README-ios.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
iOS
======

Building the Simple DirectMedia Layer for iOS 9.0+
Building the Simple DirectMedia Layer for iOS 11.0+
==============================================================================

Requirements: macOS 10.9 or later and the iOS 9.0 or newer SDK.
Please note that building SDL requires at least Xcode 12.2 and the iOS 14.2 SDK.

Instructions:

Expand Down Expand Up @@ -185,9 +185,6 @@ Windows:
Textures:
The optimal texture formats on iOS are SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, and SDL_PIXELFORMAT_RGB24 pixel formats.

Loading Shared Objects:
This is disabled by default since it seems to break the terms of the iOS SDK agreement for iOS versions prior to iOS 8. It can be re-enabled in SDL_config_ios.h.


Notes -- CoreBluetooth.framework
==============================================================================
Expand Down Expand Up @@ -249,7 +246,7 @@ Note that if you are using main callbacks instead of a standard C main() functio
Deploying to older versions of iOS
==============================================================================

SDL supports deploying to older versions of iOS than are supported by the latest version of Xcode, all the way back to iOS 8.0
SDL supports deploying to older versions of iOS than are supported by the latest version of Xcode, all the way back to iOS 11.0

In order to do that you need to download an older version of Xcode:
https://developer.apple.com/download/more/?name=Xcode
Expand Down
9 changes: 3 additions & 6 deletions docs/README-macos.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ To build SDL using the command line, use the CMake build script:
```bash
mkdir build
cd build
cmake .. -DCMAKE_OSX_DEPLOYMENT_TARGET=10.11
cmake .. -DCMAKE_OSX_DEPLOYMENT_TARGET=10.13
cmake --build .
sudo cmake --install .
```
Expand All @@ -25,15 +25,12 @@ You can also build SDL as a Universal library (a single binary for both
```bash
mkdir build
cd build
cmake .. "-DCMAKE_OSX_ARCHITECTURES=arm64;x86_64" -DCMAKE_OSX_DEPLOYMENT_TARGET=10.11
cmake .. "-DCMAKE_OSX_ARCHITECTURES=arm64;x86_64" -DCMAKE_OSX_DEPLOYMENT_TARGET=10.13
cmake --build .
sudo cmake --install .
```

Please note that building SDL requires at least Xcode 12.2 and the 11.0 SDK.
PowerPC support for macOS has been officially dropped as of SDL 2.0.2.
32-bit Intel and macOS 10.8 runtime support has been officially dropped as
of SDL 2.24.0.
Please note that building SDL requires at least Xcode 12.2 and the macOS 11.0 SDK.

To use the library once it's built, you essential have two possibilities:
use the traditional autoconf/automake/make method, or use Xcode.
Expand Down
11 changes: 11 additions & 0 deletions src/SDL_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,18 @@
#ifndef _DARWIN_C_SOURCE
#define _DARWIN_C_SOURCE 1 // for memset_pattern4()
#endif
#include <Availability.h>

#ifndef __IPHONE_OS_VERSION_MAX_ALLOWED
#define __IPHONE_OS_VERSION_MAX_ALLOWED 0
#endif
#ifndef __APPLETV_OS_VERSION_MAX_ALLOWED
#define __APPLETV_OS_VERSION_MAX_ALLOWED 0
#endif
#ifndef __MAC_OS_X_VERSION_MAX_ALLOWED
#define __MAC_OS_X_VERSION_MAX_ALLOWED 0
#endif
#endif // SDL_PLATFORM_APPLE

#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
Expand Down
35 changes: 10 additions & 25 deletions src/audio/coreaudio/SDL_coreaudio.m
Original file line number Diff line number Diff line change
Expand Up @@ -467,31 +467,16 @@ static bool UpdateAudioSession(SDL_AudioDevice *device, bool open, bool allow_pl
options |= AVAudioSessionCategoryOptionDuckOthers;
}

if ([session respondsToSelector:@selector(setCategory:mode:options:error:)]) {
if (![session.category isEqualToString:category] || session.categoryOptions != options) {
// Stop the current session so we don't interrupt other application audio
PauseAudioDevices();
[session setActive:NO error:nil];
session_active = false;

if (![session setCategory:category mode:mode options:options error:&err]) {
NSString *desc = err.description;
SDL_SetError("Could not set Audio Session category: %s", desc.UTF8String);
return false;
}
}
} else {
if (![session.category isEqualToString:category]) {
// Stop the current session so we don't interrupt other application audio
PauseAudioDevices();
[session setActive:NO error:nil];
session_active = false;

if (![session setCategory:category error:&err]) {
NSString *desc = err.description;
SDL_SetError("Could not set Audio Session category: %s", desc.UTF8String);
return false;
}
if (![session.category isEqualToString:category] || session.categoryOptions != options) {
// Stop the current session so we don't interrupt other application audio
PauseAudioDevices();
[session setActive:NO error:nil];
session_active = false;

if (![session setCategory:category mode:mode options:options error:&err]) {
NSString *desc = err.description;
SDL_SetError("Could not set Audio Session category: %s", desc.UTF8String);
return false;
}
}

Expand Down
6 changes: 2 additions & 4 deletions src/dialog/cocoa/SDL_cocoadialog.m
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,7 @@ void SDL_SYS_ShowFileDialogWithProperties(SDL_FileDialogType type, SDL_DialogFil
if (w) {
// [dialog beginWithCompletionHandler:^(NSInteger result) {
[dialog beginSheetModalForWindow:w completionHandler:^(NSInteger result) {
// NSModalResponseOK for >= 10.13
if (result == NSFileHandlingPanelOKButton) {
if (result == NSModalResponseOK) {
if (dialog_as_open) {
NSArray* urls = [dialog_as_open URLs];
const char *files[[urls count] + 1];
Expand All @@ -166,8 +165,7 @@ void SDL_SYS_ShowFileDialogWithProperties(SDL_FileDialogType type, SDL_DialogFil
}
}];
} else {
// NSModalResponseOK for >= 10.10
if ([dialog runModal] == NSOKButton) {
if ([dialog runModal] == NSModalResponseOK) {
if (dialog_as_open) {
NSArray* urls = [dialog_as_open URLs];
const char *files[[urls count] + 1];
Expand Down
24 changes: 6 additions & 18 deletions src/gpu/metal/SDL_gpu_metal.m
Original file line number Diff line number Diff line change
Expand Up @@ -386,11 +386,7 @@ static MTLTextureType SDLToMetal_TextureType(SDL_GPUTextureType textureType, boo
case SDL_GPU_TEXTURETYPE_CUBE:
return MTLTextureTypeCube;
case SDL_GPU_TEXTURETYPE_CUBE_ARRAY:
if (@available(iOS 11.0, tvOS 11.0, *)) {
return MTLTextureTypeCubeArray;
} else {
return MTLTextureType2D; // FIXME: I guess...?
}
return MTLTextureTypeCubeArray;
default:
return MTLTextureType2D;
}
Expand Down Expand Up @@ -1284,10 +1280,8 @@ static void METAL_InsertDebugLabel(
[metalCommandBuffer->computeEncoder insertDebugSignpost:label];
} else {
// Metal doesn't have insertDebugSignpost for command buffers...
if (@available(macOS 10.13, iOS 11.0, tvOS 11.0, *)) {
[metalCommandBuffer->handle pushDebugGroup:label];
[metalCommandBuffer->handle popDebugGroup];
}
[metalCommandBuffer->handle pushDebugGroup:label];
[metalCommandBuffer->handle popDebugGroup];
}
}
}
Expand All @@ -1307,9 +1301,7 @@ static void METAL_PushDebugGroup(
} else if (metalCommandBuffer->computeEncoder) {
[metalCommandBuffer->computeEncoder pushDebugGroup:label];
} else {
if (@available(macOS 10.13, iOS 11.0, tvOS 11.0, *)) {
[metalCommandBuffer->handle pushDebugGroup:label];
}
[metalCommandBuffer->handle pushDebugGroup:label];
}
}
}
Expand All @@ -1327,9 +1319,7 @@ static void METAL_PopDebugGroup(
} else if (metalCommandBuffer->computeEncoder) {
[metalCommandBuffer->computeEncoder popDebugGroup];
} else {
if (@available(macOS 10.13, iOS 11.0, tvOS 11.0, *)) {
[metalCommandBuffer->handle popDebugGroup];
}
[metalCommandBuffer->handle popDebugGroup];
}
}
}
Expand Down Expand Up @@ -2386,9 +2376,7 @@ static void METAL_BindGraphicsPipeline(
[metalCommandBuffer->renderEncoder setTriangleFillMode:SDLToMetal_PolygonMode[metalGraphicsPipeline->rasterizerState.fill_mode]];
[metalCommandBuffer->renderEncoder setCullMode:SDLToMetal_CullMode[metalGraphicsPipeline->rasterizerState.cull_mode]];
[metalCommandBuffer->renderEncoder setFrontFacingWinding:SDLToMetal_FrontFace[metalGraphicsPipeline->rasterizerState.front_face]];
if (@available(iOS 11.0, tvOS 11.0, *)) {
[metalCommandBuffer->renderEncoder setDepthClipMode:SDLToMetal_DepthClipMode(metalGraphicsPipeline->rasterizerState.enable_depth_clip)];
}
[metalCommandBuffer->renderEncoder setDepthClipMode:SDLToMetal_DepthClipMode(metalGraphicsPipeline->rasterizerState.enable_depth_clip)];
[metalCommandBuffer->renderEncoder
setDepthBias:((rast->enable_depth_bias) ? rast->depth_bias_constant_factor : 0)
slopeScale:((rast->enable_depth_bias) ? rast->depth_bias_slope_factor : 0)
Expand Down
12 changes: 6 additions & 6 deletions src/hidapi/ios/hid.m
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ - (void)centralManagerDidUpdateState:(CBCentralManager *)central
{
switch ( central.state )
{
case CBCentralManagerStatePoweredOn:
case CBManagerStatePoweredOn:
{
NSLog( @"CoreBluetooth BLE hardware is powered on and ready" );

Expand All @@ -418,23 +418,23 @@ - (void)centralManagerDidUpdateState:(CBCentralManager *)central
break;
}

case CBCentralManagerStatePoweredOff:
case CBManagerStatePoweredOff:
NSLog( @"CoreBluetooth BLE hardware is powered off" );
break;

case CBCentralManagerStateUnauthorized:
case CBManagerStateUnauthorized:
NSLog( @"CoreBluetooth BLE state is unauthorized" );
break;

case CBCentralManagerStateUnknown:
case CBManagerStateUnknown:
NSLog( @"CoreBluetooth BLE state is unknown" );
break;

case CBCentralManagerStateUnsupported:
case CBManagerStateUnsupported:
NSLog( @"CoreBluetooth BLE hardware is unsupported on this platform" );
break;

case CBCentralManagerStateResetting:
case CBManagerStateResetting:
NSLog( @"CoreBluetooth BLE manager is resetting" );
break;
}
Expand Down
Loading

0 comments on commit ec55ed6

Please sign in to comment.