Don't try to use the lwip library on Darwin. (#36258)

Don't try to build against the library, and don't check out the submodule for
the darwin platform.
diff --git a/.gitmodules b/.gitmodules
index 824bd99..4eca51b 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -332,6 +332,7 @@
 [submodule "third_party/lwip/repo"]
 	path = third_party/lwip/repo
 	url = https://github.com/lwip-tcpip/lwip.git
+	excluded-platforms = darwin
 [submodule "third_party/abseil-cpp/src"]
 	path = third_party/abseil-cpp/src
 	url = https://github.com/abseil/abseil-cpp.git
diff --git a/scripts/checkout_submodules.py b/scripts/checkout_submodules.py
index 0290182..4d52714 100755
--- a/scripts/checkout_submodules.py
+++ b/scripts/checkout_submodules.py
@@ -66,6 +66,18 @@
             platforms = set(filter(None, platforms))
             assert not (
                 platforms - ALL_PLATFORMS), "Submodule's platform not contained in ALL_PLATFORMS"
+
+            # Check for explicitly excluded platforms
+            excluded_platforms = module.get('excluded-platforms', '').split(',')
+            excluded_platforms = set(filter(None, excluded_platforms))
+            assert not (
+                excluded_platforms - ALL_PLATFORMS), "Submodule excluded on platforms not contained in ALL_PLATFORMS"
+
+            if len(excluded_platforms) != 0:
+                if len(platforms) == 0:
+                    platforms = ALL_PLATFORMS
+                platforms = platforms - excluded_platforms
+
             recursive = module.getboolean('recursive', False)
             name = name.replace('submodule "', '').replace('"', '')
             yield Module(name=name, path=module['path'], platforms=platforms, recursive=recursive)
diff --git a/src/lwip/lwip.gni b/src/lwip/lwip.gni
index 89b4808..cbbf0a4 100644
--- a/src/lwip/lwip.gni
+++ b/src/lwip/lwip.gni
@@ -14,7 +14,8 @@
 
 declare_args() {
   # Have the lwIP library available.
-  chip_with_lwip = current_os != "zephyr" && current_os != "mbed"
+  chip_with_lwip = current_os != "zephyr" && current_os != "mbed" &&
+                   current_os != "mac" && current_os != "ios"
 
   # lwIP platform: standalone, freertos.
   lwip_platform = ""