問題分類:iOS 新特性問題
case現象:
原包app:iOS15.4-正常,iOS14.5-正常
打sdk包:iOS15.4-異常,iOS14.5(越獄/normal)-正常,15.3.1-異常
空sdk-iOS15.4-異常,iOS14.5-正常
Demo-iOS15.4-正常
報錯信息:-canOpenURL: failed for URL: "weixin://" - error: "This app is not allowed to query for scheme weixin"
比較差異點:
原包-rs:iOS15.4-正常
空sdk:iOS15.4-異常
Info.plist有差異
原因:原包LSApplicationQueriesSchemes是50個,sdk化后新加了個url,超過50個(cmd+shift+0可查看官方文檔canOpenURL:),該scheme url在列表里面位置超過50就會報錯。
If your app is linked against an earlier version of iOS but is running in iOS 9.0 or later, you can call this method up to 50 times. After reaching that limit, subsequent calls always return NO. If the user reinstalls or upgrades the app, iOS resets the limit.
分析
1、下斷點
rb canOpenURL
5: regex = 'canOpenURL', locations = 7, resolved = 7, hit count = 0
5.1: where = UIKitCore`-[UIApplication _canOpenURL:publicURLsOnly:], address = 0x0000000183c415f4, resolved, hit count = 0
5.2: where = UIKitCore`-[UIApplication canOpenURL:], address = 0x0000000183c42238, resolved, hit count = 0
5.3: where = UIKitCore`__28-[UIApplication canOpenURL:]_block_invoke, address = 0x0000000183c422dc, resolved, hit count = 0
5.4: where = UIKitCore`-[UISystemShellApplication canOpenURL:], address = 0x0000000183e41a48, resolved, hit count = 0
5.5: where = CoreServices`-[_LSCanOpenURLManager canOpenURL:publicSchemes:privateSchemes:XPCConnection:error:], address = 0x0000000180edf1f4, resolved, hit count = 0
5.6: where = CoreServices`-[_LSDOpenClient canOpenURL:publicSchemes:privateSchemes:completionHandler:], address = 0x0000000180f0c460, resolved, hit count = 0
5.7: where = SearchFoundation`-[SFPunchout(Handwritten) canOpenURL:], address = 0x0000000198029190, resolved, hit count = 0
2、查找?guī)斓奈恢?/p>
image list grep | UIKitCore
[ 0] A84E395E-0B00-3162-B1FD-B861CE41349C 0x0000000182daa000 /Users/xx/Library/Developer/Xcode/iOS DeviceSupport/15.5 (19F77)/Symbols/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore
image list grep | CoreServices
[ 0] 148CBE3D-FB7E-3611-B855-F460D5DE652F 0x0000000180eaf000 /Users/xx/Library/Developer/Xcode/iOS DeviceSupport/15.5 (19F77)/Symbols/System/Library/Frameworks/CoreServices.framework/CoreServices
3、查看源碼
用hopper打開CoreService源碼,搜索_LSCanOpenURLManager查看,有如下方法
int -[_LSCanOpenURLManager schemeQueryLimit]() {
return 0x32;
}
總結
1、有異常先找差異點,逐個對比
2、新特性怎么提前預知,先去看官方文檔(cmd+shift+0)
3、借助hopper分析底層源碼
相關參考
iOSDeviceSupport列表
iOSDeviceSupport路徑:/Applications/Xcode/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
解決Github訪問不了
真機源碼路徑:
~/Library/Developer/Xcode/iOS DeviceSupport/15.5 (19F77)/Symbols/System/Library/Frameworks/CoreServices.framework
LLDB調試利器及高級用法-2個lldb插件