From c66740c941156db716599625cf6c28371b17fe17 Mon Sep 17 00:00:00 2001
From: Ted Mielczarek <ted@mielczarek.org>
Date: Fri, 27 Jan 2023 09:14:53 -0500
Subject: [PATCH 1/4] add an iOS cross-compile test to CI

---
 .github/workflows/main.yml | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index bbacbc2..f07db4d 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -83,3 +83,22 @@ jobs:
       run: cross build -vv --target ${{ matrix.platform.target }}
       working-directory: test-crate
       if: ${{ !matrix.platform.test }}
+
+  ios_cross_compile_test:
+    name: Test Cross Compile - ${{ matrix.platform.target }}
+    needs: [ test ]
+    runs-on: macos-latest
+    strategy:
+      fail-fast: false
+      matrix:
+        platform:
+          - target: aarch64-apple-ios
+    steps:
+    - uses: actions/checkout@master
+    - uses: actions-rs/toolchain@v1
+      with:
+        toolchain: stable
+        target: ${{ matrix.platform.target }}
+    - name: build
+      run: cargo build -vv --target ${{ matrix.platform.target }}
+      working-directory: test-crate

From d1ba3ce8fdf5720b5625bc46612beac802845db6 Mon Sep 17 00:00:00 2001
From: Ted Mielczarek <ted@mielczarek.org>
Date: Fri, 27 Jan 2023 10:05:15 -0500
Subject: [PATCH 2/4] Fix zlib-ng compilation for iOS

---
 .github/workflows/main.yml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index f07db4d..554d963 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -102,3 +102,6 @@ jobs:
     - name: build
       run: cargo build -vv --target ${{ matrix.platform.target }}
       working-directory: test-crate
+      env:
+        # If this isn't specified the default is iOS 7, for which zlib-ng will not compile due to the lack of thread-local storage.
+        IPHONEOS_DEPLOYMENT_TARGET: 16

From f658691c9430e1a48628d46f41cc14843caad746 Mon Sep 17 00:00:00 2001
From: Ted Mielczarek <ted@mielczarek.org>
Date: Fri, 27 Jan 2023 10:05:24 -0500
Subject: [PATCH 3/4] Revert #110 to fix iOS cross-compilation after #158.
 Fixes #173

In #158, better support for using CMake's cross-compilation facilities was
added. This made the workaround added in #110 for iOS not only unnecessary,
but actively harmful, in that it runs afoul of SDK validation checks in the
CMake iOS codepath.
---
 src/lib.rs | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/src/lib.rs b/src/lib.rs
index 736aeec..65dcef6 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -660,12 +660,6 @@ impl Config {
                     panic!("unsupported msvc target: {}", target);
                 }
             }
-        } else if target.contains("apple-ios") || target.contains("apple-tvos") {
-            // These two flags prevent CMake from adding an OSX sysroot, which messes up compilation.
-            if !self.defined("CMAKE_OSX_SYSROOT") && !self.defined("CMAKE_OSX_DEPLOYMENT_TARGET") {
-                cmd.arg("-DCMAKE_OSX_SYSROOT=/");
-                cmd.arg("-DCMAKE_OSX_DEPLOYMENT_TARGET=");
-            }
         } else if target.contains("darwin") {
             if !self.defined("CMAKE_OSX_ARCHITECTURES") {
                 if target.contains("x86_64") {

From e43b273e6aec30a8d9f845bc8826028eae0e1ccb Mon Sep 17 00:00:00 2001
From: Thom Chiovoloni <thom@shift.click>
Date: Thu, 23 Mar 2023 14:49:41 -0700
Subject: [PATCH 4/4] Use checkout@v3

Co-authored-by: Yuki Okushi <jtitor@2k36.org>
---
 .github/workflows/main.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 554d963..63c5b83 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -94,7 +94,7 @@ jobs:
         platform:
           - target: aarch64-apple-ios
     steps:
-    - uses: actions/checkout@master
+    - uses: actions/checkout@v3
     - uses: actions-rs/toolchain@v1
       with:
         toolchain: stable