Skip to content

Commit b81a434

Browse files
committed
iOS18 DEBUG模式下生成的二进制不包含__objc_classlist,需要从debug.dylib里查找
1 parent 6ac7b90 commit b81a434

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

QMUIKit/QMUICore/QMUIRuntime.m

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,26 @@ static BOOL strendswith(const char *str, const char *suffix) {
169169
NSString *executablePath = NSBundle.mainBundle.executablePath;
170170
if (!executablePath) return nil;
171171
const headerType *target_image_header = 0;
172+
173+
#if DEBUG
174+
// iOS 18.0 之后,优先查找debug.dylib
175+
if (@available(iOS 18.0, *)) {
176+
NSString *debugImagePath = [NSString stringWithFormat:@"%@.debug.dylib", executablePath];
177+
for (uint32_t i = 0; i < imageCount; i++) {
178+
const char *image_name = _dyld_get_image_name(i);
179+
NSString *imagePath = [NSString stringWithUTF8String:image_name];
180+
if ([imagePath isEqualToString:debugImagePath]) {
181+
target_image_header = (headerType *)_dyld_get_image_header(i);
182+
break;
183+
}
184+
}
185+
186+
if (target_image_header) {
187+
return target_image_header;
188+
}
189+
}
190+
#endif
191+
172192
for (uint32_t i = 0; i < imageCount; i++) {
173193
const char *image_name = _dyld_get_image_name(i);// name 是一串完整的文件路径,以 image 名结尾
174194
NSString *imagePath = [NSString stringWithUTF8String:image_name];

0 commit comments

Comments
 (0)