ios - EXC_BAD_ACCESS 仅适用于运行 iOS 8 的 xcode 8

标签 ios objective-c xcode xcode8

当从 xcode 7 为 iOS 8 到 10 编译时,该应用程序运行良好,但当从 xcode 8 编译时,该应用程序仅在 iOS 9 和 10 上正常运行,在 iOS 8 上,应用程序不一致地崩溃。有时它会停在一个随机的 UI 元素处,例如:

enter image description here

但更多时候它只会在 main 处崩溃:

enter image description here

* thread #1: tid = 0x11d655, 0x35deaf56 libobjc.A.dylib`objc_msgSend + 22, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xf632d5c1)
frame #0: 0x35deaf56 libobjc.A.dylib`objc_msgSend + 22
frame #1: 0x2db167ea CoreUI`-[CUINamedImage initWithName:usingRenditionKey:fromTheme:] + 98
frame #2: 0x2db21d48 CoreUI`-[CUICatalog imageWithName:scaleFactor:deviceIdiom:deviceSubtype:sizeClassHorizontal:sizeClassVertical:] + 128
frame #3: 0x2b8aee98 UIKit`__98-[_UIAssetManager imageNamed:scale:idiom:subtype:cachingOptions:sizeClassPair:attachCatalogImage:]_block_invoke + 240
frame #4: 0x2b8aecea UIKit`-[_UIAssetManager imageNamed:scale:idiom:subtype:cachingOptions:sizeClassPair:attachCatalogImage:] + 230
frame #5: 0x2b95df86 UIKit`-[UIImageAsset imageWithTraitCollection:] + 474
frame #6: 0x2b58d9d2 UIKit`-[UIImageView _resolveImageForTrait:] + 286
frame #7: 0x2b58d690 UIKit`-[UIImageView _didMoveFromWindow:toWindow:] + 156
frame #8: 0x2b28aef4 UIKit`-[UIView(Internal) _didMoveFromWindow:toWindow:] + 656
frame #9: 0x2b300d50 UIKit`-[UIControl _didMoveFromWindow:toWindow:] + 44
frame #10: 0x2b28aef4 UIKit`-[UIView(Internal) _didMoveFromWindow:toWindow:] + 656
frame #11: 0x2b28aef4 UIKit`-[UIView(Internal) _didMoveFromWindow:toWindow:] + 656
frame #12: 0x2b28aef4 UIKit`-[UIView(Internal) _didMoveFromWindow:toWindow:] + 656
frame #13: 0x2b28a804 UIKit`__45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 112
frame #14: 0x2b28a720 UIKit`-[UIView(Hierarchy) _postMovedFromSuperview:] + 428
frame #15: 0x2b294bce UIKit`-[UIView(Internal) _addSubview:positioned:relativeTo:] + 1462
frame #16: 0x2b29460e UIKit`-[UIView(Hierarchy) addSubview:] + 30
frame #17: 0x2b459eae UIKit`__53-[_UINavigationParallaxTransition animateTransition:]_block_invoke + 1262
frame #18: 0x2b29ada4 UIKit`+[UIView(Animation) performWithoutAnimation:] + 72
frame #19: 0x2b45977c UIKit`-[_UINavigationParallaxTransition animateTransition:] + 812
frame #20: 0x2b417cfc UIKit`-[UINavigationController _startCustomTransition:] + 2860
frame #21: 0x2b337026 UIKit`-[UINavigationController _startDeferredTransitionIfNeeded:] + 422
frame #22: 0x2b336e2c UIKit`-[UINavigationController __viewWillLayoutSubviews] + 44
frame #23: 0x2b336dc0 UIKit`-[UILayoutContainerView layoutSubviews] + 184
frame #24: 0x2b28b7fe UIKit`-[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 514
frame #25: 0x2acb1834 QuartzCore`-[CALayer layoutSublayers] + 136
frame #26: 0x2acad20c QuartzCore`CA::Layer::layout_if_needed(CA::Transaction*) + 360
frame #27: 0x2acad094 QuartzCore`CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 16
frame #28: 0x2acaca70 QuartzCore`CA::Context::commit_transaction(CA::Transaction*) + 224
frame #29: 0x2acac874 QuartzCore`CA::Transaction::commit() + 324
frame #30: 0x2aca674c QuartzCore`CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 56
frame #31: 0x27d37ffc CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 20
frame #32: 0x27d356ba CoreFoundation`__CFRunLoopDoObservers + 278
frame #33: 0x27d35ac2 CoreFoundation`__CFRunLoopRun + 914
frame #34: 0x27c833b0 CoreFoundation`CFRunLoopRunSpecific + 476
frame #35: 0x27c831c2 CoreFoundation`CFRunLoopRunInMode + 106
frame #36: 0x2f1f2200 GraphicsServices`GSEventRunModal + 136
frame #37: 0x2b2ed43c UIKit`UIApplicationMain + 1440
* frame #38: 0x0017bf62 Dev`main(argc=1, argv=0x01549a28) + 106 at main.m:14
frame #39: 0x3636aaae libdyld.dylib`start + 2

我已经启用了 NSZombies,但我没有得到任何新信息。我也试过打开地址清理器,它也会偶尔崩溃,但通常也会在 main 方法中崩溃:

enter image description here

thread #1: tid = 0x11d992, 0x020fce9e libclang_rt.asan_ios_dynamic.dylib`__asan::AsanDie(), queue = 'com.apple.main-thread', stop reason = Attempt to free a non-allocated address
{
"access_size" : 0,
  "access_type" : 0,
  "address" : 103442256,
  "description" : "Attempt to free a non-allocated address",
  "instrumentation_class" : "AddressSanitizer",
  "pc" : 0,
  "stop_type" : "fatal_error"
}

当从 Xcode 7 或 Xcode 8 为 iOS 9 或 10 构建时,该应用程序再次正常工作。只有从 Xcode 8 为 iOS 8 构建时才会发生这种情况。有什么想法吗?

最佳答案

团队中的其他人找到了答案。假的。

https://forums.developer.apple.com/thread/60919

With Xcode 8 GM, this error will occur if you include 16-bit or P3 assets in an app submission targeting iOS releases earlier then iOS 9.3. If your app requires wide color functionality you must change your Deployment Target to iOS 9.3 or later. If your app does not require wide color functionality and you wish to deploy it to older iOS versions then you should replace all 16-bit or P3 assets with 8-bit sRGB assets. You can find 16-bit or P3 assets by running “assetutil” on the asset catalog named in the error message from iTunes Connect. The following steps outline the process:

  1. Create an Inspectable .ipa file. In the Xcode Organizer (Xcode->Window->Organizer), select an archive to inspect, click “Export...", and choose "Export for Enterprise or Ad-Hoc Deployment". This will create a local copy of the .ipa file for your app.
  2. Locate that .ipa file and change its the extension to .zip.
  3. Expand the .zip file. This will produce a Payload folder containing your .app bundle.
  4. Open a terminal and change the working directory to the top level of your .app bundle cd path/to/Payload/your.app

  5. Use the find tool to locate Assets.car files in your .app bundle as shown below: find . -name 'Assets.car'

  6. Use the assetutil tool to find any 16-bit or P3 assets, in each Assets.car your application has as shown below. : sudo xcrun --sdk iphoneos assetutil --info /path/to/a/Assets.car > /tmp/Assets.json

  7. Examine the resulting /tmp/Assets.json and look for any contents containing “DisplayGamut": “P3” and its associated “Name". This will be the name of your imageset containing one or more 16-bit or P3 assets.

  8. Replace those assets with 8-bit / sRGB assets, then rebuild your app. Update: If your Deployment Target is set to either 8.3 or 8.4 and you have an asset catalog then you will receive this same error message, even if you do not actually have 16-bit or P3 assets. In this case you will either need to lower your Deployment Target to 8.2, or move it up to 9.x.

Update: If your Deployment Target is set to either 8.3 or 8.4 and you have an asset catalog then you will receive this same error message, even if you do not actually have 16-bit or P3 assets. In this case you will either need to lower your Deployment Target to 8.2, or move it up to 9.x.

关于ios - EXC_BAD_ACCESS 仅适用于运行 iOS 8 的 xcode 8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39735353/

相关文章:

ios - 在Apple App Store上的应用更新之间更改国家/地区可用性

objective-c - RubyMotion 是否支持 objective-c 代码的集成?

ios - 无法将NSDictionary添加到NSArray

ios - 核心数据 : disable undo for specific attributes. 推荐的方法不起作用

ios - Swift UIViewController子类实例变量初始化策略

iphone - 我怎么知道 nsoperation queue 何时完成所有请求以便我可以重新加载我的 tableview?

ios - 在 iOS 5.1.1/6.0 和 Xcode 4.5 上开发无许可证的应用程序

ios - 如何集成AdMob作为iAds的备份?

ios - EXC_BAD_ACCESS 仅当从 UITableView 中一直向下滚动返回时

ios - UITableView 阴影不正确(未对齐)