Error fetching view hierarchy

Ever since the beta of XC8 was released, the View Hierarchy browser (an amazing tool when it works) seems to have broken. I was able to get it working once, and only once on a specific device. The next time I try I get something like:


Error: Unable to capture view hierarchy.

Details: Error fetching view hierarchy: (

"Exception gathering view hierarchy information: snapshot method cannot be called from within draw"

)

Method: -[DBGAbstractViewDescriber handleFetchedViewInfo:fetchError:resultHandler:]

Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.


Where the UI view would normally be is "Unable to capture view hierarchy. Check the console log for more information"


Anyone else see this?

Same problem here, looking forward for workaround. However, you can still print view hierarchy using lldb.

// First you need to get viewControllers hierarchy
po [[[UIWindow keyWindow] rootViewController] _printHierarchy]
// Next step is to get a UIView's adress of appeared controller
po [<UIView adress> recursiveDescription]

New to iOS dev but not new to coding. Using XCode 8.0 and going through the FoodTracker tutorial I am receiving what seems to be a similar error message in Lesson 4 (Work with View Controllers). The provided code also gives the same error message. It happens when I click on the ImageView in the simulator. It says "Thread 9: signal SIGABRT" which I take to mean an exception was thrown and not handled by the app. I added a breakpoint for all exceptions but the breakpoint isn't catching anything and I'm not sure what the error is telling me to fix.



Error:

Unable to capture view hierarchy.

Details: Error fetching view hierarchy: (

"Exception gathering view hierarchy information: -[UIApplication _performWithUICACommitStateSnapshotting:] must be called on the main thread

(

0 CoreFoundation

0x000000010420434b __exceptionPreprocess + 171

1 libobjc.A.dylib

0x000000010156521e objc_exception_throw + 48

2 CoreFoundation

0x0000000104208442 +[NSException raise:format:arguments:] + 98

3 Foundation

0x0000000101131e09 -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 166

4 UIKit

0x0000000101a407c2 -[UIApplication _performWithUICACommitStateSnapshotting:] + 305

5 UIKit

0x0000000101dd2ecc +[UIScreen _beginDisableScreenUpdatesForSnapshotUsingSnapshotCover:] + 622

6 UIKit

0x0000000101ad59a3 __53-[UIView drawViewHierarchyInRect:afterScreenUpdates:]_block_invoke + 40

7 UIKit

0x0000000101afefcc +[_UIReplicantView _pendingSnapshotOfTarget:snapshotBlock:] + 705

8 UIKit

0x0000000101ad588c -[UIView drawViewHierarchyInRect:afterScreenUpdates:] + 263

9 libViewDebuggerSupport.dylib

0x000000010101ad9f +[DBGViewDebuggerSupport_iOS _renderEffectViewUsingDrawHierarchyInRect:] + 2081

10 libViewDebuggerSupport.dylib

0x000000010101a07d +[DBGViewDebuggerSupport_iOS snapshotView:errorString:] + 524

11 libViewDebuggerSupport.dylib

0x000000010101d8ac +[DBGViewDebuggerSupport _snapshotView:andAddDataToDictionary:] + 82

12 libViewDebuggerSupport.dylib

0x000000010101d5d6 +[DBGViewDebuggerSupport collectViewInfo:] + 178

13 libViewDebuggerSupport.dylib

0x000000010101def4 +[DBGViewDebuggerSupport _collectSubviewInfoForView:encodeLayers:] + 43

14 libViewDebuggerSupport.dylib

0x000000010101e062 +[DBGViewDebuggerSupport _collectSubviewInfoForView:encodeLayers:] + 409

15 libViewDebuggerSupport.dylib

0x000000010101e062 +[DBGViewDebuggerSupport _collectSubviewInfoForView:encodeLayers:] + 409

16 libViewDebuggerSupport.dylib

0x000000010101e062 +[DBGViewDebuggerSupport _collectSubviewInfoForView:encodeLayers:] + 409

17 libViewDebuggerSupport.dylib

0x000000010101e062 +[DBGViewDebuggerSupport _collectSubviewInfoForView:encodeLayers:] + 409

18 libViewDebuggerSupport.dylib

0x000000010101e062 +[DBGViewDebuggerSupport _collectSubviewInfoForView:encodeLayers:] + 409

19 libViewDebuggerSupport.dylib

0x000000010101e062 +[DBGViewDebuggerSupport _collectSubviewInfoForView:encodeLayers:] + 409

20 libViewDebuggerSupport.dylib

0x000000010101d0ac +[DBGViewDebuggerSupport fetchViewHierarchy] + 661

21 ???

0x0000000119cafc4b 0x0 + 4727700555

22 FoodTracker

0x0000000100f7a350 main + 0

23 libsystem_c.dylib

0x00000001051d6ff7 abort + 129

24 libsystem_sim_kernel.dylib

0x00000001052a794b __interposition_sim_fallback_abort_with_payload + 0

25 libsystem_sim_kernel.dylib

0x00000001052a795a __interposition_sim_fallback_terminate_with_reason + 0

26 TCC

0x000000010dc3954b __TCCAccessRequest_block_invoke_2.80 + 0

27 TCC

0x000000010dc39473 __CRASHING_DUE_TO_PRIVACY_VIOLATION__ + 0

28 TCC

0x000000010dc3c6c3 __tccd_send_block_invoke + 268

29 libxpc.dylib

0x00000001053fbfc7 _xpc_connection_reply_callout + 45

30 libxpc.dylib

0x00000001053f3d1b _xpc_connection_call_reply + 36

31 libdispatch.dylib

0x00000001050e20cd _dispatch_client_callout + 8

32 libdispatch.dylib

0x00000001050c1366 _dispatch_queue_override_invoke + 1426

33 libdispatch.dylib

0x00000001050c33b7 _dispatch_root_queue_drain + 720

34 libdispatch.dylib

0x00000001050c308b _dispatch_worker_thread3 + 123

35 libsystem_pthread.dylib

0x000000010548b4de _pthread_wqthread + 1129

36 libsystem_pthread.dylib

0x0000000105489341 start_wqthread + 13

)"

)

Method: -[DBGAbstractViewDescriber handleFetchedViewInfo:fetchError:resultHandler:]

Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.

Update: I found out the fix for the issue I was having. In the original debug output, I keyed in on CRASHING_DUE_TO_PRIVACY_VIOLATION. Did some research and there are key/value pairs required in the Info.plist file required to access certain resources. One resource is the Photo Library for which the key is "Privacy - Photo Library Usage Description" and incidentally the Camera resource has its own key which is "Privacy - Camera Usage Description." These keys have to be created under the Information Property List by clicking the plus icon to the right and selecting the desired key. The value property is the text the user is shown when the pop-up asks for permission to access the resource. See this link for additional information: http://stackoverflow.com/questions/39384804/crash-on-xcode-8-0-gm-iphone-simulator-ios-10

Error fetching view hierarchy
 
 
Q