Title: _ios_support fails to import on iOS 13, where find_library() cannot query the dyld shared cache · Issue #156112 · python/cpython · GitHub
Open Graph Title: _ios_support fails to import on iOS 13, where find_library() cannot query the dyld shared cache · Issue #156112 · python/cpython
X Title: _ios_support fails to import on iOS 13, where find_library() cannot query the dyld shared cache · Issue #156112 · python/cpython
Description: Bug report Bug description: Lib/_ios_support.py raises ImportError at module import if ctypes.util.find_library("objc") returns None: lib = util.find_library("objc") if lib is None: # Failed to load the objc library raise ImportError("Ob...
Open Graph Description: Bug report Bug description: Lib/_ios_support.py raises ImportError at module import if ctypes.util.find_library("objc") returns None: lib = util.find_library("objc") if lib is None: # Failed to loa...
X Description: Bug report Bug description: Lib/_ios_support.py raises ImportError at module import if ctypes.util.find_library("objc") returns None: lib = util.find_library("objc") if lib is N...
Opengraph URL: https://github.com/python/cpython/issues/156112
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"_ios_support fails to import on iOS 13, where find_library() cannot query the dyld shared cache","articleBody":"# Bug report\n\n### Bug description:\n\n`Lib/_ios_support.py` raises `ImportError` at module import if `ctypes.util.find_library(\"objc\")` returns `None`:\n\n```python\nlib = util.find_library(\"objc\")\nif lib is None:\n # Failed to load the objc library\n raise ImportError(\"ObjC runtime library couldn't be loaded\")\n```\n\nOn Apple platforms the ObjC runtime exists only in the dyld shared cache, not as a file on disk, so `find_library()` cannot resolve it by a filesystem check. `ctypes.macholib.dyld.dyld_find()` handles that by falling back to `_dyld_shared_cache_contains_path()`:\n\n```python\nif os.path.isfile(path):\n return path\ntry:\n if _dyld_shared_cache_contains_path(path):\n return path\nexcept NotImplementedError:\n pass\n```\n\nThat symbol is availability-guarded at *runtime* in `Modules/_ctypes/callproc.c`:\n\n```c\n#define HAVE_DYLD_SHARED_CACHE_CONTAINS_PATH_RUNTIME \\\n __builtin_available(macOS 11.0, iOS 14.0, tvOS 14.0, watchOS 7.0, *)\n```\n\nso on iOS 13 the probe raises `NotImplementedError`, `dyld_find()` gives up, `find_library(\"objc\")` returns `None`, and importing `_ios_support` fails outright. `IPHONEOS_DEPLOYMENT_TARGET` defaults to `13.0` in `configure.ac`, so this is inside the range iOS support targets, and it takes `platform.platform()`, `platform.ios_ver()` and anything else built on `_ios_support` down with it.\n\ndyld resolves a bare library name against the shared cache by itself, so the runtime is loadable even when `find_library()` cannot name a path for it. On macOS, where the same cache mechanism applies:\n\n```\n>>> from ctypes import cdll, util; import os\n>>> util.find_library(\"objc\")\n'/usr/lib/libobjc.dylib'\n>>> os.path.isfile(\"/usr/lib/libobjc.dylib\")\nFalse\n>>> cdll.LoadLibrary(\"libobjc.dylib\")\n\u003cCDLL 'libobjc.dylib', handle ... at ...>\n```\n\nThe suggested fix is to fall back to the bare name when `find_library()` comes up empty, and to keep reporting a genuine load failure as `ImportError`. With `find_library` patched to return `None`, the module then loads the runtime and `objc_getClass(b\"NSProcessInfo\")` works.\n\nA caveat on the evidence: I do not have an iOS 13 device or simulator runtime, so I have not reproduced the import failure on-device — the chain above is read from the source. The fallback itself is verified, as shown.\n\n### CPython versions tested on:\n\nCPython main\n\n### Operating systems tested on:\n\nmacOS\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-156113\n* gh-156215\n* gh-156216\n* gh-156217\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/clementperon","@type":"Person","name":"clementperon"},"datePublished":"2026-08-20T13:50:35Z","url":"https://github.com/python/cpython/issues/156112"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:7510ae64-c88e-33d4-412a-4406386b4ef8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E8C8:2C4BED:39B5B76:494D1F7:6B01F9AC |
| html-safe-nonce | 7e66fdba725fd49587a44e54d15cfb7a0b7480b8828e8f40de21450eba732c7e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOEM4OjJDNEJFRDozOUI1Qjc2OjQ5NEQxRjc6NkIwMUY5QUMiLCJ2aXNpdG9yX2lkIjoiNTk1ODk3MzI4MDUxMjc2ODQyOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 4f4694b592a47279b5d7ea4f550a6ea16ff4381933050adddc3f497f400468c7 |
| hovercard-subject-tag | issue:5204132756 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/156112/issue_layout |
| twitter:image | https://opengraph.githubassets.com/00c9c5cd6e064af763e8661d579233473dde4109c7e6da980ebbbaacf9ba43f3/python/cpython/issues/156112 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/00c9c5cd6e064af763e8661d579233473dde4109c7e6da980ebbbaacf9ba43f3/python/cpython/issues/156112 |
| og:image:alt | Bug report Bug description: Lib/_ios_support.py raises ImportError at module import if ctypes.util.find_library("objc") returns None: lib = util.find_library("objc") if lib is None: # Failed to loa... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | clementperon |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width