在较早的 osx 版本中,使用来自 xcassets 的 imageNamed 加载 NSImage 会崩溃
Loading NSImage with imageNamed from xcassets crash in older osx versions
所以,我有一个 xcassets,在很多应用程序之间共享。我正在 Mac Mini 中使用 Xcode8 进行开发,其中安装了 MacOs Sierra。如果我在开发机器上编译 运行 ,那完全没有问题。但是,当我尝试在具有 OSX Mavericks 的设备中 运行 它时,我遇到了崩溃。这是报告中的痕迹
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff887dc866 __pthread_kill + 10
1 libsystem_pthread.dylib 0x00007fff87a3935c pthread_kill + 92
2 libsystem_c.dylib 0x00007fff88614bba abort + 125
3 libsystem_c.dylib 0x00007fff885dea5f __assert_rtn + 321
4 com.apple.coreui 0x00007fff875aa1a7 CUIRenditionKeySetValueForAttribute + 307
5 com.apple.coreui 0x00007fff875a9004 -[CUIStructuredThemeStore _canGetRenditionWithKey:isFPO:lookForSubstitutions:] + 200
6 com.apple.coreui 0x00007fff875a8f1b -[CUIStructuredThemeStore canGetRenditionWithKey:] + 22
7 com.apple.coreui 0x00007fff875c4eab -[CUICatalog _resolvedRenditionKeyForName:scaleFactor:deviceIdiom:deviceSubtype:] + 291
8 com.apple.coreui 0x00007fff875c4c53 -[CUICatalog imageWithName:scaleFactor:deviceIdiom:deviceSubtype:] + 29
9 com.apple.AppKit 0x00007fff88820b1b +[NSImage _catalogImageWithName:bundle:] + 132
10 com.apple.AppKit 0x00007fff8881aefd +[NSImage imageNamed:] + 261
如果我从 xcassets 中删除图像并将其 "individually" 包含在应用程序的捆绑包中 - 通过将其拖放到应用程序的项目导航器中 - 它加载得很好。但我想尽可能避免这种情况,因为在一个 xcassets 中共享图像更干净。
有什么想法或想法吗?提前致谢。
我可以通过遵循 Apple 为 iOS 7 台设备提供的解决方法来绕过此错误:
To work around this issue, update the deployment target to iOS 8.0 or
higher, or add a single image to the asset catalog that has at least
five attributes specified across the image set, such as: scale (1x,
2x, 3x) idiom (add iPad,iPhone, and a universal asset) direction (left
to right, right to left) width/height class (any & compact, and so
forth) memory (add a 1 GB asset) graphics (add a Metal 1v2 asset) It
is not necessary to use the image in your code or to add all of these
attributes. (27852391)
这是这个虚拟图像集的样子:
所以,我有一个 xcassets,在很多应用程序之间共享。我正在 Mac Mini 中使用 Xcode8 进行开发,其中安装了 MacOs Sierra。如果我在开发机器上编译 运行 ,那完全没有问题。但是,当我尝试在具有 OSX Mavericks 的设备中 运行 它时,我遇到了崩溃。这是报告中的痕迹
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff887dc866 __pthread_kill + 10
1 libsystem_pthread.dylib 0x00007fff87a3935c pthread_kill + 92
2 libsystem_c.dylib 0x00007fff88614bba abort + 125
3 libsystem_c.dylib 0x00007fff885dea5f __assert_rtn + 321
4 com.apple.coreui 0x00007fff875aa1a7 CUIRenditionKeySetValueForAttribute + 307
5 com.apple.coreui 0x00007fff875a9004 -[CUIStructuredThemeStore _canGetRenditionWithKey:isFPO:lookForSubstitutions:] + 200
6 com.apple.coreui 0x00007fff875a8f1b -[CUIStructuredThemeStore canGetRenditionWithKey:] + 22
7 com.apple.coreui 0x00007fff875c4eab -[CUICatalog _resolvedRenditionKeyForName:scaleFactor:deviceIdiom:deviceSubtype:] + 291
8 com.apple.coreui 0x00007fff875c4c53 -[CUICatalog imageWithName:scaleFactor:deviceIdiom:deviceSubtype:] + 29
9 com.apple.AppKit 0x00007fff88820b1b +[NSImage _catalogImageWithName:bundle:] + 132
10 com.apple.AppKit 0x00007fff8881aefd +[NSImage imageNamed:] + 261
如果我从 xcassets 中删除图像并将其 "individually" 包含在应用程序的捆绑包中 - 通过将其拖放到应用程序的项目导航器中 - 它加载得很好。但我想尽可能避免这种情况,因为在一个 xcassets 中共享图像更干净。
有什么想法或想法吗?提前致谢。
我可以通过遵循 Apple 为 iOS 7 台设备提供的解决方法来绕过此错误:
To work around this issue, update the deployment target to iOS 8.0 or higher, or add a single image to the asset catalog that has at least five attributes specified across the image set, such as: scale (1x, 2x, 3x) idiom (add iPad,iPhone, and a universal asset) direction (left to right, right to left) width/height class (any & compact, and so forth) memory (add a 1 GB asset) graphics (add a Metal 1v2 asset) It is not necessary to use the image in your code or to add all of these attributes. (27852391)
这是这个虚拟图像集的样子: