1、 error “_OBJC_CLASS_$_XXXXXXX”, referenced from: objc-class-ref in
解决方案:根据_OBJC_CLASS_$_的XXXXXXX找到对应的类库,添加即可

 

2、崩溃:Trapped uncaught exception 'NSInternalInconsistencyException', reason: 'Client error attempting to change layout margins of a private view'

原因:iOS13中导航栏 KVC私有属性布局导致的崩溃

修改方案:定义一个 UINavigationBar 子类,重写 layoutSubviews 方法,在此方法里遍历 subviews 获取 _UINavigationBarContentView,使用设置 frame 的方式,让 _UINavigationBarContentView 向两边伸展,从而抵消两边的边距

- (void)layoutSubviews {
    [super layoutSubviews];
 
    for (UIView *subview in self.subviews) {
        if ([NSStringFromClass([subview class]) containsString:@"_UINavigationBarContentView"]) {
            if ([UIDevice currentDevice].systemVersion.floatValue >= 13.0) {
                UIEdgeInsets margins = subview.layoutMargins;
                subview.frame = CGRectMake(-margins.left, -margins.top, margins.left + margins.right + subview.frame.size.width, margins.top + margins.bottom + subview.frame.size.height);
            } else {
                subview.layoutMargins = UIEdgeInsetsZero;
            }
            break;
        }
    }
}

 

4、ios13版本中,使用Contacts 框架中的unifiedContact方法更新通讯录报错:

store.unifiedContact(withIdentifier: contactID, keysToFetch: keys)

错误提示如下:

Error Domain=CNErrorDomain Code=102 "(null)" UserInfo={CNKeyPaths=(
    note
), CNInvalidRecords=(
    "<CNContactFetchRequest: 0x28115bb10: predicate=<CNiOSABContactIdentifiersPredicate: 0x280a741c0: kind=-[CNContact predicateForContactsWithIdentifiers:], identifiers=(\n    \"78DD9DCD-9BEF-460E-872D-C2EA742A6877\"\n)>, keysToFetch=(\n    identifier,\n    namePrefix,\n    givenName,\n    middleName,\n    familyName,\n    previousFamilyName,\n    nameSuffix,\n    nickname,\n    phoneticGivenName,\n    phoneticMiddleName,\n    phoneticFamilyName,\n    phoneNumbers,\n    emailAddresses,\n    postalAddresses,\n    jobTitle,\n    departmentName,\n    organizationName,\n    note,\n    contactType,\n    birthday,\n    nonGregorianBirthday,\n    instantMessageAddresses,\n    contactRelations,\n    socialProfiles,\n    dates,\n    \"<CNAggregateKeyDescriptor: 0x281feb500: kind=+[CNContactContentViewController descriptorForRequiredKeys]>\"\n), unifyResults=1, sortOrder=0>"
)}

错误原因:unifiedContact方法中使用的keys中包含了CNContactNoteKey 这个key,苹果官方描述说明包含这个key,在ios13版本中需要去申请授权才可以使用

解决方案:去掉keys中的CNContactNoteKey,项目即可正常工作