Built the way Xcode builds them - the App Store floors (macOS 12,
iOS/tvOS 15), the projects' warnings, every translation unit - the
tree still warned:
- Delegate methods the SDK deprecates that an older OS still calls
are no longer implemented in source. apple_rt_add_method() gives
the class each one at run time, from +initialize and only on the
releases that call it: -locationManager:didChangeAuthorizationStatus:
before macOS 11 / iOS 14 (-locationManagerDidChangeAuthorization:
from there), -documentPicker:didPickDocumentAtURL: before iOS 11
(the URL-array method from there), -shouldAutorotateTo-
InterfaceOrientation: before iOS 6, and NSView's
-layer:shouldInheritContentsScale:fromWindow: from 10.7.
class_addMethod is looked up by name, as the 10.4 binary may not
import it. CocoaView no longer declares UIDocumentPickerDelegate,
whose pre-11 SDKs require the method it now adds at run time, and
-prefersPointerLocked is not built for tvOS, where it is
unavailable.
- The open panel's file types, the companion's folder icon and the
cores folder's open are -setAllowedContentTypes:, -iconForContent-
Type: and -openURL: from macOS 11, the 10.x methods before it, by
selector where they are not on every release.
- The alert's end selector is looked up by name, and on SDKs older
than the selectors ui_cocoa.m names (10.6, 10.7, 10.9) they are
declared in an unimplemented NSObject category, so @selector()
stays a constant.
- size_t and 64-bit values narrowed without a cast in configuration.c,
gl3.c, cdrom.c, media_detect_cd.c and vfs_implementation_cdrom.c;
rchd_read_extent() rejects an extent past the last 32-bit frame
instead of wrapping into the wrong track.
App Store uploads: one iOS or tvOS core without an unencrypted
LC_ENCRYPTION_INFO_64 - written by Apple's ld, not by other linkers -
fails the whole upload (ITMS-90125). make-frameworks.sh leaves such a
core out of an App Store build with a warning naming it. The
Fastfile's check for a build already in TestFlight review passed
Build.all a filter it does not take, so it always failed and the
upload went on to external distribution and stopped there; it asks
App Store Connect for the newest five builds of the platform with
their review submissions instead.
The iOS and tvOS paths take the same treatment as macOS, down to an iOS
12 floor and with deprecations reported: the UIKit, GameController,
MetricKit, AVFoundation and CoreLocation calls above the floor go
through the apple_runtime.h sends behind their OS checks, enum values
newer than the floor are compared by value, and the display link's
frame-rate range is set and read by selector on every platform without
an SDK gate. apple_runtime.h gains a 9-16 byte struct getter and
-init sends whose casts carry the init family's ownership.
Code that uses a framework throughout - the keypress and device
haptics, camera authorization, speech - moves into classes carrying
its availability, so it calls the framework directly, and is reached
by selector through a class looked up once. Deprecated calls with a
successor on every floor take it; the rest are sent by selector. The
iOS display link and GCDWebServer's lastModifiedDate declare their
ownership, and the iOS display link's rate read is guarded for systems
before iOS 10.3.
Everything the macOS build calls above its deployment floor goes
through the apple_runtime.h sends behind its existing OS check: the
GameController physical input profile and gesture state, GCMotion's
activation and acceleration, the haptics rumbler's own macOS 11
methods, the CocoaView display link and its frame-rate range, the
location authorisation status, the PQ colour space name, BC texture
support and the screen's maximum frame rate. Element names and
exported constants are looked up by symbol once, selectors on the poll
paths are cached, and a struct the ABI returns in memory goes through
objc_msgSend_stret everywhere but arm64. memmap resolves
pthread_jit_write_protect_np at load.
Deprecated spellings with a same-valued successor take the successor,
mapped back in cocoa_defines.h for older SDKs; deprecated calls with
no successor on the floor are sent by selector, and the companion
converts window and screen coordinates by the frame origin.
@available has two problems for RetroArch's range of targets:
1. It needs a clang new enough to know the syntax, so the ancient
toolchains building the legacy iOS/macOS targets cannot compile
any file that uses it.
2. It lowers to a call to __isPlatformVersionAtLeast() every time
it is evaluated, including in per-frame and per-input paths.
Introduce apple_runtime.h with apple_runtime_available(mac, ios,
tvos), a drop-in replacement that resolves the running OS version
exactly once per process and caches it in a static int; after
warm-up every check is a single load and integer compare, cheaper
than @available. Platforms the original check did not list are
passed as 0, preserving @available's semantics of returning true
on unlisted platforms.
The version is read from UIDevice systemVersion on iOS/tvOS (never
shimmed, works on any version), and on macOS from the
kern.osproductversion sysctl - which reports the real OS version
even for binaries linked against pre-11.0 SDKs, where the
NSProcessInfo APIs (and @available's own plist source) are subject
to the 10.16 compatibility shim - with an
operatingSystemVersionString fallback for pre-10.13.4 systems.
This also fixes the broken iOS 9 / iOS 6 CI builds: cocoa_common.m
used UIWindowScene.effectiveGeometry, an iOS 16 API that older SDKs
(e.g. iPhoneOS 14.2) do not declare at all, so @available could not
save compilation. That call chain is now resolved entirely at
runtime via objc_msgSend (identical cost to a compiled property
access), with the capability probe cached in a static.
All 84 live @available sites across 13 files are converted.
Behavior on every OS version is unchanged: the same paths are taken
at the same version thresholds. Swift #available sites are
untouched; Swift enforces availability at compile time and those
files only build on modern toolchains.
Existing compile-time SDK gates (e.g. around NSWorkspace
isVoiceOverEnabled and the Metal HDR blocks) are kept, since they
guard symbol declarations, not runtime dispatch; comments updated
accordingly.
The companion to the OSX change. The Xcode config passed -DIOS and 126
sites across 40 files tested it.
What -DIOS meant is the important part: OTHER_CFLAGS_IOS_TVOS_SHARE
carries it to iphoneos, iphonesimulator, appletvos and appletvsimulator
alike, so IOS meant "the iPhone family", not iOS as against tvOS.
Apple's name for that is TARGET_OS_IPHONE, which is 1 on iOS, tvOS,
watchOS and their simulators - TARGET_OS_IOS is 0 on tvOS and would
have turned every one of those 126 sites off there. So IOS becomes
TARGET_OS_IPHONE, one for one, and nothing changes which branch it
takes on any target. menu_displaylist.c's "#if !defined(IOS) || !IOS",
which said the same thing twice, becomes one test.
The macro now comes from Apple's header rather than a -D, so
<TargetConditionals.h> is included, under __MACH__ as config.def.h
already did it, by the 42 files that test TARGET_OS_IPHONE or
TARGET_OS_OSX and did not include it. The four settings_def fragments
are not translation units - they are included into configuration.c,
menu_setting.c and msg_hash_us.c, all three of which have it, the last
through msg_hash.h. -DIOS is gone from the Xcode config.
And the simulator, which is the reason to be careful here rather than
after a bug report: iOS SDKs before 9 set TARGET_OS_IPHONE to 0 for a
simulator build and marked it with TARGET_IPHONE_SIMULATOR instead, so
the TARGET_OS_OSX fallback added in the previous commit would have
called an old simulator build a Mac. Both simulator spellings are
checked now, the modern TARGET_OS_SIMULATOR and that one.
The preprocessor matrix from the previous commit grew two rows - an
old iOS-simulator SDK and a modern one - and all thirteen are correct.
Linux builds and runs clean under ASan; the Apple side is not compiled
here.
-[CLLocationManager requestWhenInUseAuthorization] is macOS 10.15+ (iOS 8+,
tvOS 9+). Building against the macOS 10.13 deployment target emitted:
'requestWhenInUseAuthorization' is only available on macOS 10.15 or newer
Wrap the call in if (@available(macOS 10.15, *)), matching the @available
idiom already used in this file. Pre-10.15 macOS has no explicit when-in-use
request API, so the legacy branch starts location updates instead, which
raises the authorization prompt implicitly and preserves behaviour on older
systems.