Skip to content

Commit db9c694

Browse files
authored
Merge pull request Tencent#1555 from moshiwu/feature/iOS18_debug_image_support
iOS18 DEBUG模式下生成的二进制不包含__objc_classlist,需要从debug.dylib里查找
2 parents 6ac7b90 + ef0023d commit db9c694

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 __IPHONE_OS_VERSION_MAX_ALLOWED >= 180000
174+
#if DEBUG
175+
// Xcode16之后,优先查找debug.dylib
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+
#endif
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)