Skip to content

Commit 0fd0922

Browse files
authored
chore: make iOS app build work with Xcode 16.4+ (#1065)
* Add zlib and libpng dependencies with BUILD files - Add minimal BUILD file for zlib and libpng under `third_party`. - Override zlib and libpng as http_archive dependencies in WORKSPACE. - Update zlib and libpng versions for Xcode 16.4 compatibility. * Enable ARM NEON optimizations for libpng on arm64 platforms * Format WORKSPACE file * Update iOS CI to use macOS 15 runner * Update zlib and libpng dependencies with SHA256 checksums * Refactor libpng BUILD file to add iOS-specific ARM64 configs and consolidate ARM NEON optimizations * Update iOS CI to use iPhone 16 Pro with runtime `iphonesimulator18.5` * Pin pip to version 25.1 in iOS CI post-clone script to ensure compatibility. * Add Python 3.14 installation in iOS CI post-clone script * Add `brew link` step for Python 3.14 in iOS CI post-clone script * Update iOS CI post-clone script to explicitly use Python 3.14
1 parent 344ca12 commit 0fd0922

File tree

6 files changed

+131
-5
lines changed

6 files changed

+131
-5
lines changed

.github/workflows/ios-build-test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ on:
99
jobs:
1010
build:
1111
name: Build and test iOS app
12-
# https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md
13-
runs-on: macos-14
12+
# https://github.com/actions/runner-images/blob/main/images/macos/macos-15-arm64-Readme.md
13+
runs-on: macos-15
1414
timeout-minutes: 180
1515
env:
1616
PERF_TEST: true
@@ -65,7 +65,7 @@ jobs:
6565
- name: Setup iOS simulator
6666
env:
6767
DEVICE_NAME: "iPhone 16 Pro"
68-
RUNTIME_SDK: "iphonesimulator18.2"
68+
RUNTIME_SDK: "iphonesimulator18.5"
6969
run: |
7070
cd flutter/ios/ci_scripts/ && bash setup_simulator.sh
7171
open -a Simulator

WORKSPACE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,26 @@ tf_patch_finder(
2626
workspace_dir = __workspace_dir__,
2727
)
2828

29+
# Override zlib and png version to make it compatible with Xcode 16.4
30+
http_archive(
31+
name = "zlib",
32+
build_file = "//third_party:zlib.BUILD",
33+
sha256 = "17e88863f3600672ab49182f217281b6fc4d3c762bde361935e436a95214d05c",
34+
strip_prefix = "zlib-1.3.1",
35+
urls = [
36+
"https://github.com/madler/zlib/releases/download/v1.3.1/zlib-1.3.1.tar.gz",
37+
"https://github.com/madler/zlib/archive/refs/tags/v1.3.1.tar.gz",
38+
],
39+
)
40+
41+
http_archive(
42+
name = "png",
43+
build_file = "//third_party:libpng.BUILD",
44+
sha256 = "71158e53cfdf2877bc99bcab33641d78df3f48e6e0daad030afe9cb8c031aa46",
45+
strip_prefix = "libpng-1.6.50",
46+
urls = ["https://github.com/glennrp/libpng/archive/refs/tags/v1.6.50.tar.gz"],
47+
)
48+
2949
load("@tf_patch_finder//:patch_win_arm64.bzl", "PATCH_FILE")
3050

3151
http_archive(

flutter/ios/ci_scripts/ci_post_clone.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,11 @@ echo "$MC_LOG_PREFIX protobuf version:" && protoc --version
6464
brew install cocoapods || brew install cocoapods || brew install cocoapods
6565
echo "$MC_LOG_PREFIX cocoapods version:" && pod --version
6666

67-
echo "$MC_LOG_PREFIX python version:" && python3 --version
68-
python3 -m pip install --break-system-packages \
67+
brew install [email protected] || brew install [email protected] || brew install [email protected]
68+
brew link --overwrite [email protected]
69+
echo "$MC_LOG_PREFIX python version:" && python3.14 --version
70+
71+
python3.14 -m pip install --break-system-packages \
6972
"numpy>=1.23,<2.0" \
7073
"absl-py>=1.3,<2.0"
7174

third_party/BUILD

Whitespace-only changes.

third_party/libpng.BUILD

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Description:
2+
# libpng is the official PNG reference library.
3+
4+
licenses(["notice"]) # BSD/MIT-like license
5+
6+
genrule(
7+
name = "pnglibconf",
8+
srcs = ["scripts/pnglibconf.h.prebuilt"],
9+
outs = ["pnglibconf.h"],
10+
cmd = "cp $(location scripts/pnglibconf.h.prebuilt) $(location pnglibconf.h)",
11+
)
12+
13+
config_setting(
14+
name = "target_arm64",
15+
constraint_values = ["@platforms//cpu:arm64"],
16+
)
17+
18+
# Apple iOS CPU-based config_settings to avoid host/target mix-ups under split transitions.
19+
config_setting(
20+
name = "cpu_ios_arm64",
21+
values = {"cpu": "ios_arm64"},
22+
)
23+
24+
cc_library(
25+
name = "png",
26+
srcs = [
27+
"png.c",
28+
"pngdebug.h",
29+
"pngerror.c",
30+
"pngget.c",
31+
"pnginfo.h",
32+
":pnglibconf",
33+
"pngmem.c",
34+
"pngpread.c",
35+
"pngpriv.h",
36+
"pngread.c",
37+
"pngrio.c",
38+
"pngrtran.c",
39+
"pngrutil.c",
40+
"pngset.c",
41+
"pngstruct.h",
42+
"pngtrans.c",
43+
"pngwio.c",
44+
"pngwrite.c",
45+
"pngwtran.c",
46+
"pngwutil.c",
47+
] + select({
48+
":cpu_ios_arm64": [
49+
"arm/arm_init.c",
50+
"arm/filter_neon_intrinsics.c",
51+
"arm/palette_neon_intrinsics.c",
52+
],
53+
"//conditions:default": [],
54+
}),
55+
hdrs = [
56+
"png.h",
57+
"pngconf.h",
58+
],
59+
includes = ["."],
60+
linkopts = select({
61+
"@bazel_tools//src/conditions:windows": [],
62+
"//conditions:default": ["-lm"],
63+
}),
64+
copts = select({
65+
":cpu_ios_arm64": ["-DPNG_ARM_NEON_OPT=2"],
66+
"//conditions:default": ["-DPNG_ARM_NEON_OPT=0"],
67+
}),
68+
visibility = ["//visibility:public"],
69+
deps = ["@zlib//:zlib"],
70+
)

third_party/zlib.BUILD

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Minimal BUILD for zlib used by TensorFlow and this project.
2+
3+
cc_library(
4+
name = "zlib",
5+
srcs = [
6+
"adler32.c",
7+
"compress.c",
8+
"crc32.c",
9+
"deflate.c",
10+
"gzclose.c",
11+
"gzlib.c",
12+
"gzread.c",
13+
"gzwrite.c",
14+
"infback.c",
15+
"inflate.c",
16+
"inffast.c",
17+
"inftrees.c",
18+
"trees.c",
19+
"uncompr.c",
20+
"zutil.c",
21+
],
22+
hdrs = [
23+
"zconf.h",
24+
"zlib.h",
25+
],
26+
includes = ["."],
27+
# On POSIX (darwin, linux, android) unistd.h exists; on Windows it doesn't.
28+
copts = select({
29+
"@bazel_tools//src/conditions:windows": [],
30+
"//conditions:default": ["-DZ_HAVE_UNISTD_H"],
31+
}),
32+
visibility = ["//visibility:public"],
33+
)

0 commit comments

Comments
 (0)