XCode14 & iOS16 適配問題匯總

1、不升級電腦系統與 Xcode,調試iOS 16

  • 1、下載iOS16 Support文件
  • 2、放置到Xcode DeviceSupport目錄重啟Xcode即可/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport

2、iOS16手機開啟開發者模式

iOS16手機未打開開發者模式時:
1、Xcode 無法選中 iOS16的設備,報錯:developer mode disable
2、無法打開升級前編譯的App

解決辦法:打開調試手機-設置-隱私與安全-開發者模式-開啟開發者模式(需要重啟手機)

3、Pod工程中的Bundle target簽名報錯

  • 方法一:手動選擇Pod工程中的Bundle target 簽名中的Team,與主工程一致
  • 方法二:在Podfile腳本中設置你的開發者的Team ID
post_install do |installer|
  installer.generated_projects.each do |project|
    project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings["DEVELOPMENT_TEAM"] = "Your Team ID"
         end
    end
  end
end
  • 方法三:在Podfile腳本中設置CODE_SIGN_IDENTITY為空來避免報錯,這是目前在用的,也是最簡單的方法

    post_install do |installer|
      installer.generated_projects.each do |project|
        project.targets.each do |target|
            target.build_configurations.each do |config|
                config.build_settings['CODE_SIGN_IDENTITY'] = ''
             end
        end
      end
    end
    

4、iOS16 橫豎屏切換適配

5、Xcode14運行項目在模擬器上報如下錯誤:

Thread 1: "[<_UINavigationBarContentViewLayout 0x7fd1a090d730> valueForUndefinedKey:]: this class is not key value coding-compliant for the key inlineTitleView."

打開全局斷點就會出現這個報錯,雖然不會閃退,但是很影響調試,是Xcode的bug,但是還沒有修復,找到兩個比較好的辦法:

  • 方法一:在全局斷點上添加下面的條件
!(BOOL)[(id)[$arg1 reason] containsString:@"_UINavigationBarContentViewLayout"]
  • 方法二:添加下面代碼到工程,并在啟動之后馬上調用
#import <objc/runtime.h>

@interface Xcode14Fixer : NSObject
@end

@implementation Xcode14Fixer

+ (void)load
{
    Class cls = NSClassFromString(@"_UINavigationBarContentViewLayout");
    SEL selector = @selector(valueForUndefinedKey:);
    Method impMethod = class_getInstanceMethod([self class], selector);

    if (impMethod) {
        class_addMethod(cls, selector, method_getImplementation(impMethod), method_getTypeEncoding(impMethod));
    }
}

- (id)valueForUndefinedKey:(NSString *)key
{
    return nil;
}

@end

參考: Xcode 14 Beta 5 throws an exception

6、Xcode14真機運行很慢,報如下錯誤:

warning: libobjc.A.dylib is being read from process memory. This indicates that LLDB could not find the on-disk shared cache for this device. This will likely reduce debugging performance.

解決辦法:應該是Xcode的bug,識別不了正確路徑,需要刪除等Xcode重新建立路徑
rm -r ~/Library/Developer/Xcode/iOS\ DeviceSupport

7、Xcode14打包 iOS12以下系統運行崩潰問題libswiftCoreGraphics

問題:
更新到xcode14以后,在iOS12以下運行報錯dyld: Library not loaded: /usr/lib/swift/libswiftCoreGraphics.dylib
工程報錯的話在工程添加:
target -> Build Phases -> Link Binary With Libraries中添加:libswiftCoreGraphics.tbd

xcode14:Library not loaded: /usr/lib/swift/libswiftCoreGraphics.dylib

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容