| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 5f6487a commit fe4c50b
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,12 +10,15 @@ | |||
| 10 | 10 | else: | |
| 11 | 11 | # ctypes is available. Load the ObjC library, and wrap the objc_getClass, | |
| 12 | 12 | # sel_registerName methods | |
| 13 | - lib = util.find_library("objc") | ||
| 14 | - if lib is None: | ||
| 15 | - # Failed to load the objc library | ||
| 16 | - raise ImportError("ObjC runtime library couldn't be loaded") | ||
| 13 | + # find_library() resolves a system library through the dyld shared cache, | ||
| 14 | + # which needs _dyld_shared_cache_contains_path(); that is unavailable before | ||
| 15 | + # iOS 14, so fall back to the bare name, which dyld resolves by itself. | ||
| 16 | + lib = util.find_library("objc") or "libobjc.dylib" | ||
| 17 | 17 | ||
| 18 | - objc = cdll.LoadLibrary(lib) | ||
| 18 | + try: | ||
| 19 | + objc = cdll.LoadLibrary(lib) | ||
| 20 | + except OSError: | ||
| 21 | + raise ImportError("ObjC runtime library couldn't be loaded") | ||
| 19 | 22 | objc.objc_getClass.restype = c_void_p | |
| 20 | 23 | objc.objc_getClass.argtypes = [c_char_p] | |
| 21 | 24 | objc.sel_registerName.restype = c_void_p | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,4 @@ | |||
| 1 | + :mod:`!_ios_support` no longer fails to import when | ||
| 2 | + :func:`ctypes.util.find_library` cannot resolve the ObjC runtime through the | ||
| 3 | + dyld shared cache, as is the case on iOS 13. The runtime is now loaded by name, | ||
| 4 | + which dyld resolves against the cache directly. | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments