Files
vanilla/cmake/ios-toolchain.cmake
Joshua Brest (杰成)andMattKC 78b923719c Add iOS support with build scripts, toolchain, and assets (#302)
* feat: add iOS support

* ios: clean up icon

* ci: add ios build

* fix(gui): revert asset lookups to use "%s/assets/%s/%s" for macOS

* refactor(gui): remove extra `iconv` linkage for iOS

* chore(gitignore): remove unused `xcuserdata` and `DerivedData` entries

* fix(gui): use provided `LibXML2` in non-vendored builds

* fix(ci): add Xcode setup step for iOS build

* fix(pipe): prevent relay threads from using freed stack memory

* fix(input): replace bitfields with explicit wire packing for touch and gyro data

* fix merge issues

* fix cmake merge bug

* cmake: attempt iOS SDL fix

* older ios

* feat: add iOS support

* ios: clean up icon

* ci: add ios build

* refactor(gui): remove extra `iconv` linkage for iOS

* chore(gitignore): remove unused `xcuserdata` and `DerivedData` entries

* fix(ci): add Xcode setup step for iOS build

* cmake: attempt iOS SDL fix

* older ios

* cleanup

* build signed macOS app alongside iOS app

* cmake: detect ios version and include liquid glass icon if available

* ci: upload continuous release

* cmake: move more ios code to toolchain

* remove ios simulator target

* improvements

* remove CMakePresets.json

* Update ios-toolchain.cmake

* move ios folder to gui folder

* converge Info.plist templates

* update comments and readme

* cmake: remove redundant code

* remove redundant ios folder

* cmake: add comments to cache strings

* cmake/ci: maybe fix new apple builds

* cmake: fix new ios build

* cmake: fix macOS build?

---------

Co-authored-by: MattKC <34096995+itsmattkc@users.noreply.github.com>
2026-09-09 02:25:50 -07:00

51 lines
2.0 KiB
CMake

set(CMAKE_SYSTEM_NAME iOS)
if(NOT CMAKE_GENERATOR STREQUAL "Xcode")
message(FATAL_ERROR "iOS build requires Xcode generator")
endif()
set(CMAKE_OSX_SYSROOT iphoneos CACHE STRING "iOS SDK")
set(CMAKE_OSX_ARCHITECTURES arm64 CACHE STRING "iOS architectures")
set(CMAKE_XCODE_GENERATE_SCHEME ON CACHE BOOL "Generate an Xcode scheme")
# Determine Xcode version to determine iOS deployment target
if(NOT DEFINED CMAKE_OSX_DEPLOYMENT_TARGET)
execute_process(
COMMAND xcodebuild -version
RESULT_VARIABLE _vanilla_xcode_version_result
OUTPUT_VARIABLE _vanilla_xcode_version_output
ERROR_VARIABLE _vanilla_xcode_version_error
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT _vanilla_xcode_version_result EQUAL 0)
message(FATAL_ERROR "Could not determine the selected Xcode version: ${_vanilla_xcode_version_error}")
endif()
string(REGEX MATCH "Xcode ([0-9]+(\\.[0-9]+)*)" _vanilla_xcode_version_match "${_vanilla_xcode_version_output}")
if(NOT CMAKE_MATCH_1)
message(FATAL_ERROR "Could not parse the selected Xcode version from: ${_vanilla_xcode_version_output}")
endif()
if(CMAKE_MATCH_1 VERSION_GREATER_EQUAL 26.0)
set(_vanilla_ios_deployment_target 15.0)
else()
set(_vanilla_ios_deployment_target 12.0)
endif()
set(CMAKE_OSX_DEPLOYMENT_TARGET "${_vanilla_ios_deployment_target}" CACHE STRING "Minimum iOS deployment version")
endif()
if(IS_DIRECTORY "${CMAKE_OSX_SYSROOT}")
set(VANILLA_IOS_SDK_PATH "${CMAKE_OSX_SYSROOT}")
else()
execute_process(
COMMAND xcrun --sdk "${CMAKE_OSX_SYSROOT}" --show-sdk-path
RESULT_VARIABLE _vanilla_ios_sdk_result
OUTPUT_VARIABLE VANILLA_IOS_SDK_PATH
ERROR_VARIABLE _vanilla_ios_sdk_error
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT _vanilla_ios_sdk_result EQUAL 0 OR NOT IS_DIRECTORY "${VANILLA_IOS_SDK_PATH}")
message(FATAL_ERROR "Could not resolve iOS SDK '${CMAKE_OSX_SYSROOT}': ${_vanilla_ios_sdk_error}")
endif()
endif()