Add explicit device logic to the iOS build script - #1889
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the CMake configuration script for iOS and tvOS to set the -DCMAKE_OSX_SYSROOT parameter when the platform variant is 'device'. The reviewer suggested simplifying the nested conditional blocks by using a dictionary mapping for the platform variants to their respective SDK sysroots to improve readability and maintainability.
| cmd.append('-DCMAKE_SYSTEM_NAME=iOS') | ||
| if platform_variant == 'simulator': | ||
| cmd.append('-DCMAKE_OSX_SYSROOT=iphonesimulator') | ||
| elif platform_variant == 'device': | ||
| cmd.append('-DCMAKE_OSX_SYSROOT=iphoneos') | ||
| elif apple_os == 'tvos': | ||
| cmd.append('-DCMAKE_SYSTEM_NAME=tvOS') | ||
| if platform_variant == 'simulator': | ||
| cmd.append('-DCMAKE_OSX_SYSROOT=appletvsimulator') | ||
| elif platform_variant == 'device': | ||
| cmd.append('-DCMAKE_OSX_SYSROOT=appletvos') |
There was a problem hiding this comment.
To improve readability and maintainability, we can simplify the nested conditional blocks by using a dictionary mapping for the platform variants to their respective SDK sysroots. This avoids repetitive if/elif checks and makes the configuration logic cleaner and more idiomatic.
| cmd.append('-DCMAKE_SYSTEM_NAME=iOS') | |
| if platform_variant == 'simulator': | |
| cmd.append('-DCMAKE_OSX_SYSROOT=iphonesimulator') | |
| elif platform_variant == 'device': | |
| cmd.append('-DCMAKE_OSX_SYSROOT=iphoneos') | |
| elif apple_os == 'tvos': | |
| cmd.append('-DCMAKE_SYSTEM_NAME=tvOS') | |
| if platform_variant == 'simulator': | |
| cmd.append('-DCMAKE_OSX_SYSROOT=appletvsimulator') | |
| elif platform_variant == 'device': | |
| cmd.append('-DCMAKE_OSX_SYSROOT=appletvos') | |
| cmd.append('-DCMAKE_SYSTEM_NAME=iOS') | |
| sysroot = {'simulator': 'iphonesimulator', 'device': 'iphoneos'}.get(platform_variant) | |
| if sysroot: | |
| cmd.append('-DCMAKE_OSX_SYSROOT={0}'.format(sysroot)) | |
| elif apple_os == 'tvos': | |
| cmd.append('-DCMAKE_SYSTEM_NAME=tvOS') | |
| sysroot = {'simulator': 'appletvsimulator', 'device': 'appletvos'}.get(platform_variant) | |
| if sysroot: | |
| cmd.append('-DCMAKE_OSX_SYSROOT={0}'.format(sysroot)) |
❌ Integration test FAILEDRequested by @a-maurice on commit f6cbc4b
Add flaky tests to go/fpl-cpp-flake-tracker |
Description
When building for iOS and tvOS device, set the appropriate CMAKE_OSX_SYSROOT value. Seems to be necessary based on Xcode and Cmake versions.
Testing
Building locally.
Type of Change
Place an
xthe applicable box:Notes
Release Notessection ofrelease_build_files/readme.md.