EXC_BAD_ACCESS KERN_INVALID_ADDRESS ios < 9.3 xcode 10

EXC_BAD_ACCESS KERN_INVALID_ADDRESS ios < 9.3 xcode 10

最新 xcode 我只在 ios 9.0>9.2.x

上崩溃
#0. Crashed: com.apple.main-thread
0  libobjc.A.dylib                0x227dbae6 objc_msgSend + 5
1  CoreUI                         0x2700b023 -[CUICatalog _resolvedRenditionKeyFromThemeRef:withBaseKey:scaleFactor:deviceIdiom:deviceSubtype:sizeClassHorizontal:sizeClassVertical:memoryClass:graphicsClass:graphicsFallBackOrder:] + 646
2  CoreUI                         0x2700ad99 -[CUICatalog _resolvedRenditionKeyForName:scaleFactor:deviceIdiom:deviceSubtype:sizeClassHorizontal:sizeClassVertical:memoryClass:graphicsClass:graphicsFallBackOrder:withBaseKeySelector:] + 284
3  CoreUI                         0x2700a52b -[CUICatalog namedLookupWithName:scaleFactor:deviceIdiom:deviceSubtype:sizeClassHorizontal:sizeClassVertical:] + 94
4  UIKit                          0x279aba2d __98-[_UIAssetManager imageNamed:scale:idiom:subtype:cachingOptions:sizeClassPair:attachCatalogImage:]_block_invoke + 496
5  UIKit                          0x279ab77f -[_UIAssetManager imageNamed:scale:idiom:subtype:cachingOptions:sizeClassPair:attachCatalogImage:] + 230
6  UIKit                          0x279abf51 -[_UIAssetManager imageNamed:withTrait:] + 408
7  UIKit                          0x2747694d +[UIImage imageNamed:inBundle:compatibleWithTraitCollection:] + 172    
8  UIKit                          0x272d6537 +[UIImage imageNamed:] + 110
9  SuperGuidaTV                   0x140ffd -[FixedBackgroundNavigationController viewDidLoad] (FixedBackgroundNavigationController.m:375)
10 SuperGuidaTV                   0x126dfd -[ISNavigationController viewDidLoad] (ISNavigationController.m:522)
11 UIKit                          0x274fd075 -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 60
12 UIKit                          0x27199d79 -[UIViewController loadViewIfRequired] + 1028
13 UIKit                          0x27199959 -[UIViewController view] + 24

崩溃发生在这段代码中:(在viewDidLoad内)

[super setDelegate:self];
[super viewDidLoad];
[self backgroundImageView];

if (!_backgroundImage)
    [self setBackgroundImage:[UIImage imageNamed:@"BkImage"]];

[self backgroundImageView] 只是用 self.view 框架初始化一个 UIImageView 并且 setBackgroundImage 只是设置从 XCAsset 文件夹中获取的图像。

-(UIImageView *)backgroundImageView {
    if (!_backgroundImageView)
    {
        _backgroundImageView = [[UIImageView alloc] initWithImage:self.backgroundImage];
        [self.view insertSubview:_backgroundImageView atIndex:0];
        [_backgroundImageView setFrame:self.view.bounds];
        [_backgroundImageView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
    }
    return _backgroundImageView;
}

-(void)setBackgroundImage:(UIImage *)backgroundImage {
    _backgroundImage = backgroundImage;
    if (self.forceNoBackground)
    {
        [self.backgroundImageView setHidden:YES];
        return;
    }
    else if (_backgroundImageView) [self.backgroundImageView setImage:backgroundImage];
}

正如您从日志中看到的那样,崩溃是在设置 uiimage 后立即发生的。

我只在 ios 9 上遇到其他崩溃,总是因为访问错误。

目标设置为部署目标为 9.0,但项目设置为 8.3 Project deployment target

这可能是原因吗? 我应该将图像移出 XCasset 文件夹吗?

非常感谢。

感谢所有回答我的问题的人: 如评论中所述,问题与以下问题相同:

并在 xcode 10.1 beta2

中解决

Resolves an issue that affected app compatibility with iOS 9.0, 9.1 and 9.2. Apps containing asset catalogs built with Xcode 10 whose deployment target was set to iOS 9.0, 9.1 or 9.2 would produce content incompatible with the runtimes of those iOS versions. Rebuilding the application with Xcode 10.1 resolves this issue. (44535967)

这个问题让我的应用程序崩溃了太多...

非常感谢