xcode 11 beta 6 or 7 not finding named colors on my color assets when running on iOS 11.4 simulator and device

Hi,

We have been using color assets to access colors like UIColor(named: "colornamehere") and that has been working fine with Xcode 10 but now trying with Xcode 11 beta 6 and 7 using iOS 11.4 Simulator and it can't find the colors anymore. Using the iOS 12 and 13 simulator works but not on 11


Wondering if anyone has seen this too


Thanks

Replies

Yes a few are getting this. I managed to recreate in a sample project and raised a radar with Apple. No response yet. FB7144402

I have this problem as well; retrieving colors by name returns nil in iOS 11.4 but works in iOS 13.


However, if I create a brand new app project, named colors do work.

Exactly the same here.

Xcode 10 + iOS 11.x / 12.x works perfectly.

Xcode 11 + iOS 12.x / 13.x works perfectly.

Xcode 11 + iOS 11.4 == crash when calling UIColor(named:)


However! Xcode 11 + iOS 11.4 + Objective-C [UIColor colorNamed:@"name"] works.

Actually I dig it deeper.

In Xcode 11, iOS 11.x, the problem can be reproduced in a brand new app project if you create more than(>=) 3 .xcassets files. And each of them should have at least one image set or color set.

If you have only 2 .xcassets files, the -[UIColor colorNamed:] method in OC can work.

This is pretty tricky, and definitely should be concerned as a bug.

On a legacy iOS project. I have only 2 .xcassets files and [UIColor colorNamed:] always returns either nil or the wrong color on iOS 11. With images iOS 11 now always returns the dark image instead of the any. So perhaps what you say only applies to newly created projects.


Regardless, we are down to the wire, not much time left to take care of this issue. Apple's silence on this is slightly worrisome. We can't afford to take the risk that it will not address this so we have a temporary solution.


Since our app doesn't use story boards, (Minimal use of .xib files as well). we were able to get around this issue by creating a UIColor category with a new method called XXXcolorNamed:(NSString *)colorName (the *** is our app's prefix). Essentially what we are now doing is calling that method and if on iOS 12 or greater we route to UIColor colorNamed: but if less than iOS 12 then we have a simple NSDictionary where we keep just the Any color accessible with the colorName key. Ditto for images.



Thanks,

Neal

I want to point out that our project has 2 and only 2 .xcasset files.

One is images only, the other is colors only.

We have the problem; so I'm not entirely certain this diagnosis is completely accurate.


However, this project was not created from scratch in Xcode 11.
It is, like probably everyone else here, a pre-existing project that works in Xcode 10 and does not work with Xcode 11.

I have a pre-existing project which has this problem too. But mine has 4 .xcassets files, so I tried to reproduce the nil problem in a brand new demo. And the steps above is how I reproduce the problem.


But it's very suprised to know that 2 .xcassets files could also cause the appearance of the bug. Seemingly I'm wrong. This problem's behaviour is uncertain.

Thank you by the way. Your solution is great. And the temporary solution we are going to adopt is very similar to yours. The difference is we wrote a script in build phases to walk through all color sets and generate a JSON file for XXXcolorNamed:(like yours) to do a second access if the nil situation happened.

The script is a great idea, but the number of managed colors I have is not that many (for now anyway). I cannot believe that this issue has not yet been addressed. Glad to help!

Good news is Apple noticed this issue and they're on fixing it. We may see it work in Xcode 11 GM.

Just tested in Xcode 11 GM. Still fails in the iOS 11.4 simulator. I'm tracking down an 11.4 device from our QA team to see if this issue is deploy-to-simulator-only or an actual device issue.

Sounds like there’ll be a new Xcode 11 GM to fix this. From the developer portal (emphasis added):


Please note that apps built with Xcode 11 using named colors may experience lookup failures (with no value returned) when the app runs on iOS 11 or earlier. This will be fixed in a future Xcode update. To avoid this issue, raise the minimum deployment target to iOS 12 or later to submit to the App Store now, or rebuild with the next Xcode GM candidate seed when it’s available.


https://developer.apple.com/ios/submit/

Good news. This is now fixed in Xcode 11 GM seed 2 (https://developer.apple.com/documentation/xcode_release_notes/xcode_11_release_notes/)

The issue is present in XCode 11 GM seed 2. See below stack trace


Process: Xcode [15452]

Path: /Users/USER/Downloads/Xcode-beta.app/Contents/MacOS/Xcode

Identifier: com.apple.dt.Xcode

Version: 11.2 (15519)

Build Info: IDEFrameworks-15519000000000000~20 (11B44)

Code Type: X86-64 (Native)

Parent Process: ??? [1]

Responsible: Xcode [15452]

User ID: 501



Date/Time: 2019-10-30 14:12:30.728 +0530

OS Version: Mac OS X 10.15 (19A603)

Report Version: 12

Bridge OS Version: 4.0 (17P572)

Anonymous UUID: 51B49748-1EE9-9601-05D7-15D35CBF7B9C



Sleep/Wake UUID: EC7E284A-1F3A-4636-ABB9-76A6CD43BBCF



Time Awake Since Boot: 11000 seconds

Time Since Wake: 960 seconds



System Integrity Protection: enabled



Crashed Thread: 0 Dispatch queue: com.apple.main-thread



Exception Type: EXC_CRASH (SIGABRT)

Exception Codes: 0x0000000000000000, 0x0000000000000000

Exception Note: EXC_CORPSE_NOTIFY



Application Specific Information:

ProductBuildVersion: 11B44

UNCAUGHT EXCEPTION (NSInvalidArgumentException): -[IBUIColor colorUsingColorSpaceName:]: unrecognized selector sent to instance 0x7fc5ee02a440

UserInfo: (null)

Hints:


Backtrace:

0 __exceptionPreprocess (in CoreFoundation)

1 DVTFailureHintExceptionPreprocessor (in DVTFoundation)

2 objc_exception_throw (in libobjc.A.dylib)

3 -[NSObject(NSObject) __retain_OA] (in CoreFoundation)

4 ___forwarding___ (in CoreFoundation)

5 _CF_forwarding_prep_0 (in CoreFoundation)

6 -[NSColorPickerPencilView(NSPencilCore) _pencilWithColor:] (in AppKit)

7 -[NSColorPickerPencilView setColor:] (in AppKit)

8 -[NSColorPanel _withColorSettingDisabled:] (in AppKit)

9 -[NSColorPanel _forceSetColor:] (in AppKit)

10 -[NSColorPanel setColor:] (in AppKit)

11 -[NSTextView updateFontPanel] (in AppKit)

12 -[NSTextView(NSSharing) becomeFirstResponder] (in AppKit)

13 -[IDEAttributedStringControlTextView becomeFirstResponder] (in IDEKit)

14 -[NSWindow _realMakeFirstResponder:] (in AppKit)

15 -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] (in AppKit)

16 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] (in AppKit)

17 -[NSWindow(NSEventRouting) sendEvent:] (in AppKit)

18 -[IDEWorkspaceWindow sendEvent:] (in IDEKit)

19 -[NSApplication(NSEvent) sendEvent:] (in AppKit)

20 -[IDEApplication sendEvent:] (in IDEKit)

21 -[NSApplication run] (in AppKit)

22 NSApplicationMain (in AppKit)

23 main (in Xcode)

24 start (in libdyld.dylib)


abort() called



Application Specific Signatures:

NSInvalidArgumentException



Application Specific Backtrace 1:

0 CoreFoundation 0x00007fff3a8ccd63 __exceptionPreprocess + 250

1 DVTFoundation 0x000000010c7c3a29 DVTFailureHintExceptionPreprocessor + 205

2 libobjc.A.dylib 0x00007fff707bbbd4 objc_exception_throw + 48

3 CoreFoundation 0x00007fff3a957206 -[NSObject(NSObject) __retain_OA] + 0

4 CoreFoundation 0x00007fff3a87351b ___forwarding___ + 1427

5 CoreFoundation 0x00007fff3a872ef8 _CF_forwarding_prep_0 + 120

6 AppKit 0x00007fff37f45038 -[NSColorPickerPencilView(NSPencilCore) _pencilWithColor:] + 297

7 AppKit 0x00007fff37f4419c -[NSColorPickerPencilView setColor:] + 27

8 AppKit 0x00007fff37f41bec -[NSColorPanel _withColorSettingDisabled:] + 37

9 AppKit 0x00007fff37f42088 -[NSColorPanel _forceSetColor:] + 108

10 AppKit 0x00007fff37f41ea0 -[NSColorPanel setColor:] + 119

11 AppKit 0x00007fff37a9f487 -[NSTextView updateFontPanel] + 1949

12 AppKit 0x00007fff37bfd73d -[NSTextView(NSSharing) becomeFirstResponder] + 271

13 IDEKit 0x000000010e68bb91 -[IDEAttributedStringControlTextView becomeFirstResponder] + 42

14 AppKit 0x00007fff37b6c00a -[NSWindow _realMakeFirstResponder:] + 415

15 AppKit 0x00007fff37c4145d -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 3983

16 AppKit 0x00007fff37b84e80 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 2612

17 AppKit 0x00007fff37b8420d -[NSWindow(NSEventRouting) sendEvent:] + 349

18 IDEKit 0x000000010e23f56b -[IDEWorkspaceWindow sendEvent:] + 154

19 AppKit 0x00007fff37a47618 -[NSApplication(NSEvent) sendEvent:] + 352

20 IDEKit 0x000000010e2856c7 -[IDEApplication sendEvent:] + 922

21 AppKit 0x00007fff37a37005 -[NSApplication run] + 707

22 AppKit 0x00007fff37a28e7d NSApplicationMain + 777

23 Xcode 0x000000010c4e7e8d main + 541

24 libdyld.dylib 0x00007fff71b1a405 start + 1



Thread 0 Crashed:: Dispatch queue: com.apple.main-thread

0 libsystem_kernel.dylib 0x00007fff71c6947a __pthread_kill + 10

1 libsystem_pthread.dylib 0x00007fff71d26707 pthread_kill + 384

2 libsystem_c.dylib 0x00007fff71bf1a08 abort + 120

3 com.apple.dt.IDEKit 0x000000010e201069 +[IDEAssertionHandler _handleAssertionWithLogString:assertionSignature:assertionReason:extraBacktrace:] + 1276

4 com.apple.dt.IDEKit 0x000000010e202718 -[IDEAssertionHandler handleUncaughtException:] + 1094

5 com.apple.dt.IDEKit 0x000000010e2027ee IDEHandleUncaughtException + 94

6 com.apple.AppKit 0x00007fff37a37086 -[NSApplication run] + 836

7 com.apple.AppKit 0x00007fff37a28e7d NSApplicationMain + 777

8 com.apple.dt.Xcode 0x000000010c4e7e8d main + 541

9 libdyld.dylib 0x00007fff71b1a405 start + 1



Thread 1:

0 libsystem_pthread.dylib 0x00007fff71d235b4 start_wqthread + 0



Thread 2:

0 libsystem_pthread.dylib 0x00007fff71d235b4 start_wqthread + 0



Thread 3:

0 libsystem_kernel.dylib 0x00007fff71c63146 mach_msg_trap + 10

1 libsystem_kernel.dylib 0x00007fff71c636ac mach_msg + 60

2 com.apple.CoreFoundation 0x00007fff3a81c19b __CFRunLoopServiceMachPort + 322

3 com.apple.CoreFoundation 0x00007fff3a81b737 __CFRunLoopRun + 1695

4 com.apple.CoreFoundation 0x00007fff3a81ae13 CFRunLoopRunSpecific + 499

5 com.apple.Foundation 0x00007fff3ceb7cad -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212

6 com.apple.DTDeviceKitBase 0x0000000125ddd55e +[DTDKRemoteDeviceConnection startServiceBrowsers] + 204

7 com.apple.Foundation 0x00007fff3ceadef2 __NSThread__start__ + 1064

8 libsystem_pthread.dylib 0x00007fff71d26d76 _pthread_start + 125

9 libsystem_pthread.dylib 0x00007fff71d235d7 thread_start + 15



Thread 4:

0 libsystem_kernel.dylib 0x00007fff71c63146 mach_msg_trap + 10

1 libsystem_kernel.dylib 0x00007fff71c636ac mach_msg + 60

2 com.apple.CoreFoundation 0x00007fff3a81c19b __CFRunLoopServiceMachPort + 322

3 com.apple.CoreFoundation 0x00007fff3a81b737 __CFRunLoopRun + 1695

4 com.apple.CoreFoundation 0x00007fff3a81ae13 CFRunLoopRunSpecific + 499

5 com.apple.Foundation 0x00007fff3ceb7cad -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212

6 com.apple.DTDeviceKitBase 0x0000000125deb08d -[DTDKRemoteDeviceDataListener listenerThreadImplementation] + 636

7 com.apple.Foundation 0x00007fff3ceadef2 __NSThread__start__ + 1064

8 libsystem_pthread.dylib 0x00007fff71d26d76 _pthread_start + 125

9 libsystem_pthread.dylib 0x00007fff71d235d7 thread_start + 15



Thread 5:: com.apple.CFSocket.private

0 libsystem_kernel.dylib 0x00007fff71c6a7c6 __select + 10

1 com.apple.CoreFoundation 0x00007fff3a84992a __CFSocketManager + 632

2 libsystem_pthread.dylib 0x00007fff71d26d76 _pthread_start + 125

3 libsystem_pthread.dylib 0x00007fff71d235d7 thread_start + 15



Thread 6:: JavaScriptCore bmalloc scavenger

0 libsystem_kernel.dylib 0x00007fff71c668f6 __psynch_cvwait + 10

1 libsystem_pthread.dylib 0x00007fff71d27082 _pthread_cond_wait + 701

2 libc++.1.dylib 0x00007fff6ec6b81a std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 18

3 com.apple.JavaScriptCore 0x00007fff3eedf714 void std::__1::condition_variable_any::wait<std::__1::unique_lock<bmalloc::Mutex> >(std::__1::unique_lock<bmalloc::Mutex>&) + 84

4 com.apple.JavaScriptCore 0x00007fff3eee3c2b bmalloc::Scavenger::threadRunLoop() + 331

5 com.apple.JavaScriptCore 0x00007fff3eee37a9 bmalloc::Scavenger::threadEntryPoint(bmalloc::Scavenger*) + 9

6 com.apple.JavaScriptCore 0x00007fff3eee5fc7 void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)(bmalloc::Scavenger*), bmalloc::Scavenger*> >(void*) + 39

7 libsystem_pthread.dylib 0x00007fff71d26d76 _pthread_start + 125

8 libsystem_pthread.dylib 0x00007fff71d235d7 thread_start + 15



Thread 7:

0 libsystem_kernel.dylib 0x00007fff71c63146 mach_msg_trap + 10

1 libsystem_kernel.dylib 0x00007fff71c636ac mach_msg + 60

2 com.apple.spotlight.index 0x00007fff694177cf _handleExceptions + 120

3 libsystem_pthread.dylib 0x00007fff71d26d76 _pthread_start + 125

4 libsystem_pthread.dylib 0x00007fff71d235d7 thread_start + 15



Thread 8:

0 libsystem_pthread.dylib 0x00007fff71d235b4 start_wqthread + 0



Thread 9:: com.apple.NSEventThread

0 libsystem_kernel.dylib 0x00007fff71c63146 mach_msg_trap + 10

1 libsystem_kernel.dylib 0x00007fff71c636ac mach_msg + 60

2 com.apple.CoreFoundation 0x00007fff3a81c19b __CFRunLoopServiceMachPort + 322

3 com.apple.CoreFoundation 0x00007fff3a81b737 __CFRunLoopRun + 1695

4 com.apple.CoreFoundation 0x00007fff3a81ae13 CFRunLoopRunSpecific + 499

5 com.apple.AppKit 0x00007fff37a45026 _NSEventThread + 132

6 libsystem_pthread.dylib 0x00007fff71d26d76 _pthread_start + 125

7 libsystem_pthread.dylib 0x00007fff71d235d7 thread_start + 15



Thread 10:: DYMobileDeviceManager

0 libsystem_kernel.dylib 0x00007fff71c63146 mach_msg_trap + 10

1 libsystem_kernel.dylib 0x00007fff71c636ac mach_msg + 60

2 com.apple.CoreFoundation 0x00007fff3a81c19b __CFRunLoopServiceMachPort + 322

3 com.apple.CoreFoundation 0x00007fff3a81b737 __CFRunLoopRun + 1695

4 com.apple.CoreFoundation 0x00007fff3a81ae13 CFRunLoopRunSpecific + 499

5 com.apple.Foundation 0x00007fff3ceb7cad -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212

6 com.apple.Foundation 0x00007fff3ceb7bc6 -[NSRunLoop(NSRunLoop) run] + 76

7 com.apple.GPUToolsMobileFoundation 0x000000012ca8d5a9 -[DYMobileDeviceManager _deviceNotificationThread:] + 126

8 com.apple.Foundation 0x00007fff3ceadef2 __NSThread__start__ + 1064

9 libsystem_pthread.dylib 0x00007fff71d26d76 _pthread_start + 125

10 libsystem_pthread.dylib 0x00007fff71d235d7 thread_start + 15



Thread 11:

0 libsystem_kernel.dylib 0x00007fff71c63146 mach_msg_trap + 10

1 libsystem_kernel.dylib 0x00007fff71c636ac mach_msg + 60

2 com.apple.CoreFoundation 0x00007fff3a81c19b __CFRunLoopServiceMachPort + 322

3 com.apple.CoreFoundation 0x00007fff3a81b737 __CFRunLoopRun + 1695

4 com.apple.CoreFoundation 0x00007fff3a81ae13 CFRunLoopRunSpecific + 499

5 com.apple.CoreFoundation 0x00007fff3a81abea CFRunLoopRun + 40

6 libSwiftPM.dylib 0x0000000131309146 closure #1 in FSEventStream.start() + 262

7 libSwiftPM.dylib 0x00000001311877a2 closure #1 in Thread.init(task:) + 146

8 libSwiftPM.dylib 0x00000001311878f9 thunk for @escaping @callee_guaranteed () -> () + 25

9 libSwiftPM.dylib 0x00000001311878be @objc ThreadImpl.main() + 46

10 com.apple.Foundation 0x00007fff3ceadef2 __NSThread__start__ + 1064

11 libsystem_pthread.dylib 0x00007fff71d26d76 _pthread_start + 125

12 libsystem_pthread.dylib 0x00007fff71d235d7 thread_start + 15



Thread 12:

0 libsystem_pthread.dylib 0x00007fff71d235b4 start_wqthread + 0



Thread 13:

0 libsystem_pthread.dylib 0x00007fff71d235b4 start_wqthread + 0



Thread 14:

0 libsystem_pthread.dylib 0x00007fff71d235b4 start_wqthread + 0



Thread 15:

0 libsystem_pthread.dylib 0x00007fff71d235b4 start_wqthread + 0



Thread 16:

0 libsystem_pthread.dylib 0x00007fff71d235b4 start_wqthread + 0



Thread 17:

0 libsystem_pthread.dylib 0x00007fff71d235b4 start_wqthread + 0



Thread 18:

0 libsystem_pthread.dylib 0x00007fff71d235b4 start_wqthread + 0



Thread 19:: Dispatch queue: com.apple.dt.SpotlightIndexerProcess (QOS: BACKGROUND)

0 com.apple.DNTDocumentationModel 0x0000000112e63030 outlined init with copy of Any + 0

1 com.apple.DNTDocumentationModel 0x0000000112e60400 JSON.optionalValueForKey<A>(_:) + 144

2 com.apple.DNTDocumentationModel 0x0000000112e60272 JSON.valueForKey<A>(_:) + 130

3 com.apple.DNTDocumentationModel 0x0000000112e611a3 JSON.jsonForKey(_:) + 115

4 com.apple.DNTDocumentationSupport 0x0000000113119cf6 LanguageEntityRelationship.init(relatedEntityJSON:sourceLanguage:role:) + 246

5 com.apple.DNTDocumentationSupport 0x00000001131866c1 JSON<>.ownerWithSourceLanguage(_:) + 161

6 com.apple.DNTDocumentationSupport 0x000000011321e6d3 InstanceMethod.init(json:role:) + 195

7 com.apple.DNTDocumentationSupport 0x000000011321f0e9 protocol witness for WebJSONInitializable.init(json:role:) in conformance InstanceMethod + 9

8 com.apple.DNTDocumentationSupport 0x0000000113171037 static DocumentationService.entityForJSONDictionary(_:) + 359

9 com.apple.DNTDocumentationSupport 0x00000001131707ec DocumentationService.deserializeEntity(cachePair:) + 1132

10 com.apple.DNTDocumentationSupport 0x00000001130f1c48 specialized Sequence.map<A>(_:) + 360

11 com.apple.DNTDocumentationSupport 0x00000001130eec09 IndexOperation.main() + 329

12 com.apple.DNTDocumentationSupport 0x00000001130ef838 @objc IndexOperation.main() + 24

13 com.apple.Foundation 0x00007fff3d0622c0 __NSOPERATION_IS_INVOKING_MAIN__ + 17

14 com.apple.Foundation 0x00007fff3cec7af4 -[NSOperation start] + 731

15 com.apple.Foundation 0x00007fff3d0626ce __NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__ + 17

16 com.apple.Foundation 0x00007fff3cef0ed8 __NSOQSchedule_f + 182

17 libdispatch.dylib 0x00007fff71ad6143 _dispatch_block_async_invoke2 + 83

18 libdispatch.dylib 0x00007fff71aca4de _dispatch_client_callout + 8

19 libdispatch.dylib 0x00007fff71acc690 _dispatch_continuation_pop + 414

20 libdispatch.dylib 0x00007fff71acbd8e _dispatch_async_redirect_invoke + 703

21 libdispatch.dylib 0x00007fff71ad87e5 _dispatch_root_queue_drain + 326

22 libdispatch.dylib 0x00007fff71ad8f25 _dispatch_worker_thread2 + 92

23 libsystem_pthread.dylib 0x00007fff71d2371d _pthread_wqthread + 220

24 libsystem_pthread.dylib 0x00007fff71d235c3 start_wqthread + 15



Thread 20:

0 libsystem_pthread.dylib 0x00007fff71d235b4 start_wqthread + 0



Thread 21:

0 libsystem_pthread.dylib 0x00007fff71d235b4 start_wqthread + 0



Thread 22:

0 libsystem_kernel.dylib 0x00007fff71c67012 __semwait_signal + 10

1 libsystem_c.dylib 0x00007fff71bea122 nanosleep + 196

2 com.apple.CoreSymbolicationDT 0x000000010f279391 cleaner_thread_main(void*) + 41

3 libsystem_pthread.dylib 0x00007fff71d26d76 _pthread_start + 125

4 libsystem_pthread.dylib 0x00007fff71d235d7 thread_start + 15



Thread 0 crashed with X86 Thread State (64-bit):

rax: 0x0000000000000000 rbx: 0x0000000114220d40 rcx: 0x00007ffee3719788 rdx: 0x0000000000000000

rdi: 0x0000000000000307 rsi: 0x0000000000000006 rbp: 0x00007ffee37197b0 rsp: 0x00007ffee3719788

r8: 0x000000010ea9c6b8 r9: 0x0000000000000012 r10: 0x0000000000000000 r11: 0x0000000000000246

r12: 0x0000000000000307 r13: 0x00007fff962e1560 r14: 0x0000000000000006 r15: 0x0000000000000016

rip: 0x00007fff71c6947a rfl: 0x0000000000000246 cr2: 0x00007fc5db92ad00


Logical CPU: 0

Error Code: 0x02000148

Trap Number: 133