EXC_BAD_ACCESS KERN_INVALID_ADDRESS iOS <9.3 xcode 10

时间:2018-10-04 09:10:44

标签: ios iphone ios9 xcode10

使用最新的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]只是初始化一个UIImageView,框架为self.view,而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文件夹吗?

非常感谢您。

1 个答案:

答案 0 :(得分:0)

感谢所有回答我的问题的人: 如评论中所述,问题与our app crashed in iOS 9 which upload by Xcode 10

相同

,并已在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)

此问题使我的应用崩溃太多...

非常感谢您