Xcode 11 crashes when copy/pasting views from different storyboards - ios

I have a problem with Xcode 11 running on Catalina (it had the same problem with Moave).
When I try to copy/paste a view or a ViewController from one storyboard to another Xcode crashes with this exception:
...
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Application Specific Information:
Sending paste: to IBStructureAreaDockView from <NSMenuItem: 0x7fe24030ddd0 Paste>
ProductBuildVersion: 11A1027
ASSERTION FAILURE in /Library/Caches/com.apple.xbs/Sources/IDEInterfaceBuilder/IDEInterfaceBuilder-15400/InterfaceBuilderKit/WidgetIntegration/View/IBViewIntegration.m:2451
Details: There should only be 1 parent of all the constraint items extracted from the pasteboard: {(
)}
Object: <IBUIView: 0x7fe23db1c600>
Method: -ibDidExtractObjects:fromPasteboard:intoDocument:context:
Thread: <NSThread: 0x7fe23ac17e80>{number = 1, name = main}
Hints:
0: Sending paste: to IBStructureAreaDockView from <NSMenuItem: 0x7fe24030ddd0 Paste>
Backtrace:
0 -[IDEAssertionHandler handleFailureInMethod:object:fileName:lineNumber:assertionSignature:messageFormat:arguments:] (in IDEKit)
1 _DVTAssertionHandler (in DVTFoundation)
2 _DVTAssertionFailureHandler (in DVTFoundation)
3 -[NSView(IBViewIntegration) ibDidExtractObjects:fromPasteboard:intoDocument:context:] (in IDEInterfaceBuilderKit)
4 -[IBUIView(IBUIViewIntegration) ibDidExtractObjects:fromPasteboard:intoDocument:context:] (in IDEInterfaceBuilderCocoaTouchIntegration)
5 -[IBDocument ibDidExtractObjects:fromPasteboard:context:] (in IDEInterfaceBuilderKit)
6 -[IBDocument insertObjectsFromPasteboard:ofType:asChildrenOfObject:atIndex:context:finishExtractingObjectsBlock:] (in IDEInterfaceBuilderKit)
7 -[IBDocument insertOrMoveChildrenFromPasteboard:ofType:asChildrenOfObject:atIndex:context:finishExtractingObjectsBlock:] (in IDEInterfaceBuilderKit)
8 -[IBDocument addOrMoveChildrenFromPasteboard:ofType:toObject:context:finishExtractingObjectsBlock:] (in IDEInterfaceBuilderKit)
9 -[IBStoryboardDocument addOrMoveChildrenFromPasteboard:ofType:toSceneGroup:context:] (in IDEInterfaceBuilderKit)
10 -[IBSceneDockViewController performDockPasteWithPasteboard:context:] (in IDEInterfaceBuilderKit)
11 -[IBSceneDockViewController dockViewPerformPaste:] (in IDEInterfaceBuilderKit)
12 -[IBStructureAreaDockView paste:] (in IDEInterfaceBuilderKit)
13 -[NSApplication(NSResponder) sendAction:to:from:] (in AppKit)
14 __37-[DVTApplication sendAction:to:from:]_block_invoke.86 (in DVTKit)
15 DVTInvokeWithFailureHint (in DVTFoundation)
16 -[DVTApplication sendAction:to:from:] (in DVTKit)
17 -[NSMenuItem _corePerformAction] (in AppKit)
18 -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] (in AppKit)
19 -[NSMenu performKeyEquivalent:] (in AppKit)
20 routeKeyEquivalent (in AppKit)
21 -[NSApplication(NSEvent) sendEvent:] (in AppKit)
22 -[IDEApplication sendEvent:] (in IDEKit)
23 -[NSApplication run] (in AppKit)
24 NSApplicationMain (in AppKit)
25 main (in Xcode)
26 start (in libdyld.dylib)
Performing #selector(paste:) from sender NSMenuItem 0x7fe24030ddd0
abort() called
Application Specific Signatures:
[parentsOfItemsInConstraints count] == 1
...
Is it happening to someone else? Is this something not supported by storyboard?

The issue for me was because i had the app running in the background. After closing the emulator i was able to copy/cut and paste (even in different storyboard files).

Xcode->Preferences-Locations
Click on the little arrow underneath "Derived Data" and delete that folder.
After I did this I could cut and paste between storyboards.

Same issue here. I think it's a bug with the new Xcode 11.
Found a quick workaround. Instead of copying and pasting view controllers which will cause Xcode to crash you can use cmd + D to duplicate the view controllers . But this will only be useful if in the same storyboard

Select View Controller, Edit > copy
On another storyboard, Edit > paste

i found a quick hack, go to your project navigator then right click on your .storyboard file and choose open as Source code.
you will get your storyboard in xml format, search and copy the class of the controller, and paste the same way you copied it in the other storyboard.
make sure to get the whole code of the view controller.
<!--Detail View Controller-->
<scene sceneID="n6l-mp-H1E"> .... </scene>

Its seems like kernel has issues while pasting the entire storyboard , But this only happens when the simulator apps is open . Close simulator app and try to paste it it works perfect

I tried clearing derived data and cleaning the project and the project folder and force restarted Xcode multiple times but all that didn't work.
Also I couldn't duplicated the views since I needed to copy in a different storyboard.
What eventually did the trick for me was to open an assistant editor and drag/drop whichever views I needed to copy.

CLOSE the SIMULATOR! That will work and allow the copy-paste of view controllers from different storyboards.

Two possible cases:
either you have to copy and paste from one project to another;
or within the same project, but different or same storyboard.
You can fix it by closing the emulator running in the background and then copy and paste or by copying and pasting from your storyboard (XML format).

I have found that instead of selecting the scene, selecting the view controller and perform a copy and paste to new storyboard worked.

Drag and drop worked instead of copy/paste for me. Happy coding!

I faces this issue lots of time, it seems like due to new version of Xcode.
Here is the solution that works for me.
Delete Derived Data and restart the XCode.
Clean & build the project.
Make sure XCode should not busy in following tasks:
Building Project
Indexing (wait until finish)
Running Project
Storyboard opening
Now you can try to copy one view controller from one storyboard to another it can be possible.

Related

Error rendering JW Player - should have parent view controller:<RNSScreen> but actual parent is:<UIViewController>

We have a problem with a React Native app throwing a parent view controller error with the https://github.com/chaimPaneth/react-native-jw-media-player component (React Native wrapper around the native libs)
Essentially we have the component working, although only under the condition that it's nested within a ScrollView, the second we remove the ScrollView and just wrap the component in a standard View we get this error.
Exception thrown while executing UI block: child view controller:<JWPlayerKit.JWPlayerViewController: 0x7f91c807ac00> should have parent view controller:<RNSScreen: 0x7f9168512950> but actual parent is:<UIViewController: 0x7f91aef1d920>
As an example, the following will throw this error and crash the app.
<View>
<JWPlayer .../>
</View>
This however will work fine, and we have no idea why.
<ScrollView>
<JWPlayer .../>
</ScrollView>
We can see that RNSScreen is something to do with React Native Screens, but that all appears to be fine, and enabled (we also tried disabling screens and that did nothing)
We're using react-navigation v6 and v0.2.6 of react-native-jw-media-player
I have a feeling this has something to do with the React Navigation and the layering of components or screens.
Can anyone assist here? Does this error mean anything to anyone? We're completely stuck
The full stacktrace we see on screen is:
Exception thrown while executing UI block: child view controller:<JWPlayerKit.JWPlayerViewController: 0x7f91c807ac00> should have parent view controller:<RNSScreen: 0x7f9168512950> but actual parent is:<UIViewController: 0x7f91aef1d920>
__44-[RCTUIManager flushUIBlocksWithCompletion:]_block_invoke
RCTUIManager.m:1201
__44-[RCTUIManager flushUIBlocksWithCompletion:]_block_invoke.498
__RCTExecuteOnMainQueue_block_invoke
_dispatch_call_block_and_release
_dispatch_client_callout
_dispatch_main_queue_callback_4CF
__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
__CFRunLoopRun
CFRunLoopRunSpecific
GSEventRunModal
-[UIApplication _run]
UIApplicationMain
main
start_sim
0x0
0x0```
Upgrading react-native-jw-media-player to 0.2.19 seems to fix it.
Source and other possible fixes:
https://github.com/chaimPaneth/react-native-jw-media-player/issues/174

App crashing on runTransitionForCurrentState but no clue as to why

I've tried searching for this, but no luck, so hoping there are some guru's who may know the answer.
I'm seeing loads of reports in iTunes Connect of my app crashing with a particular stack trace, but the stack trace reveals nothing useful.
#0. Crashed: main
0 UIKit 0x1871100c0 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 324
1 UIKit 0x1871100bc __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 320
2 UIKit 0x1870630c8 _runAfterCACommitDeferredBlocks + 292
3 UIKit 0x187070a80 _cleanUpAfterCAFlushAndRunDeferredBlocks + 92
4 UIKit 0x186da25a4 _afterCACommitHandler + 96
5 CoreFoundation 0x181c0c728 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
6 CoreFoundation 0x181c0a4cc __CFRunLoopDoObservers + 372
7 CoreFoundation 0x181c0a8fc __CFRunLoopRun + 928
8 CoreFoundation 0x181b34c50 CFRunLoopRunSpecific + 384
9 GraphicsServices 0x18341c088 GSEventRunModal + 180
10 UIKit 0x186e1a088 UIApplicationMain + 204
11 MyApp 0x100082e6c main (main.m:19)
12 libdyld.dylib 0x1816d28b8 start + 4
No pattern to the reports, happens on iOS 9.1, 9.2, 9.3-10 and various iPhones and iPads and no clues to help reproduce it.
Has anyone experienced something like this before and have some insight/suspicion on what may cause it?
I have the exact same crash, and I've figured out the cause. A highly-reduced version of my code looks something like
[self dismissViewControllerAnimated:YES completion:nil];
// call a method that ends up doing
[appRootViewController dismissViewControllerAnimated:NO completion:nil];
self in the above snippet is a view controller that's been presented modally over the root. The view controller itself has also presented modally over current context some other controller. So what I'm doing is trying to dismiss that over-current-context controller with animation, then calling other code that ultimately dismisses any presented view controller from the root without animation.
Or to put it another way, the view controller providing the current context for an animated dismiss that I just kicked off gets removed from the view hierarchy while the previous animated dismissal is in progress.
When reproducing this in Xcode, it also logs the following to the console:
transitionViewForCurrentTransition is not set, presentation controller was dismissed during the presentation? (<_UIOverCurrentContextPresentationController: 0x7faf277d9c30>)

Auto-Layout crash on iOS 9 with auto-layout disabled

I know this is a generic question, but I hope that someone who had a similar experience may have an idea of what's probably happening.
I'm getting a crash that occurs only on iOS 9 in our iPad-only app. It says NSInternalInconsistencyException.
It occurs on both Portrait and Landscape modes, and on many iPad generations (iPad 2, iPad Pro, iPad 4, ...).
I don't have Auto Layout enabled anywhere in the project, yet it looks like an auto layout issue.
It's very hard to replicate, so I'm not able to debug it on Xcode, but I'm seeing reports on the crash analytics service "Crashlytics". Here's the stack trace from Crashlytics:
Auto layout internal error. Cannot find an outgoing row
head for incoming head <unknown var (bug!) with engine as delegate[...]
Thread : Fatal Exception: NSInternalInconsistencyException
0 CoreFoundation 0x23d4568b __exceptionPreprocess
1 libobjc.A.dylib 0x356c2e17 objc_exception_throw
2 CoreFoundation 0x23d455d1 -[NSException initWithCoder:]
3 Foundation 0x24a873b3 -[NSISEngine minimizeConstantInObjectiveRowWithHead:]
4 Foundation 0x24a86e4d -[NSISEngine optimize]
5 Foundation 0x24a82a53 -[NSISEngine withBehaviors:performModifications:]
6 UIKit 0x27e040bb -[UIView(Hierarchy) _postMovedFromSuperview:]
7 UIKit 0x280fb227 __UIViewWasRemovedFromSuperview
8 UIKit 0x27e02ddb -[UIView(Hierarchy) removeFromSuperview]
9 UIKit 0x282e5fa9 -[UIKeyboardPredictionView setPredictionViewState:animate:notify:]
10 UIKit 0x281e3787 -[UIKeyboardImpl updatePredictionView]
11 UIKit 0x27f155e3 -[UIKeyboardImpl finishLayoutChangeWithArguments:]
12 UIKit 0x27e31437 -[UIKeyboardImpl updateLayout]
13 UIKit 0x27e36077 -[UIKeyboardImpl setDelegate:force:]
14 UIKit 0x27e2f6e1 -[UIPeripheralHost(UIKitInternal) _reloadInputViewsForResponder:]
15 UIKit 0x27e2f20d -[UIResponder(UIResponderInputViewAdditions) reloadInputViews]
16 UIKit 0x27e8d853 -[UIResponder becomeFirstResponder]
17 UIKit 0x27e8db6d -[UIView(Hierarchy) becomeFirstResponder]
18 UIKit 0x27f12289 -[UITextField becomeFirstResponder]
19 UIKit 0x27fbe69f -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) setFirstResponderIfNecessary]
20 UIKit 0x27fbdc75 -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) oneFingerTap:]
21 UIKit 0x28334e27 _UIGestureRecognizerSendTargetActions
22 UIKit 0x27fa2303 _UIGestureRecognizerSendActions
23 UIKit 0x27e3a7af -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:]
24 UIKit 0x28335f2f ___UIGestureRecognizerUpdate_block_invoke809
25 UIKit 0x27dfc287 _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks
26 UIKit 0x27df9e77 _UIGestureRecognizerUpdate
27 UIKit 0x27e386f9 -[UIWindow _sendGesturesForEvent:]
28 UIKit 0x27e37e43 -[UIWindow sendEvent:]
29 UIKit 0x27e097e5 -[UIApplication sendEvent:]
30 UIKit 0x27e07fdf _UIApplicationHandleEventQueue
31 CoreFoundation 0x23d08c3f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
32 CoreFoundation 0x23d0882d __CFRunLoopDoSources0
33 CoreFoundation 0x23d06b9b __CFRunLoopRun
34 CoreFoundation 0x23c5a249 CFRunLoopRunSpecific
35 CoreFoundation 0x23c5a035 CFRunLoopRunInMode
36 GraphicsServices 0x2cd24ad1 GSEventRunModal
37 UIKit 0x27e6f899 UIApplicationMain
38 Mr Appliance 0xcda7b main (main.m:16)
39 libdyld.dylib 0x35e0e873 start
The problem is that I don't know where in the code this is happening. The stack trace doesn't show where in the code the crash is occurring. It only says main.m line 16 which is return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));.
That line in main.m is where your program starts running, not where the error happens. The exception is thrown at #1 the top of the list after all the other items have happened. The problem lies somewhere in between.
After some view is removed from its superview there's an exception, and it does show NSISEngine errors indicating that perhaps AutoLayout is turned on for some XIB or Storyboard - or else iOS is using AutoLayout internally to handle the arrangement of the new layout.
This answer has a nearly identical stack trace & points to the issue being with using incorrect gesture methods to handle firstResponder changes and dismiss a keyboard. If you're doing something similar (dismissing some view, editing a UITableView?) maybe it's with the wrong method pointing to a delegate that doesn't exist?
https://stackoverflow.com/questions/33800918/uitextfield-becomefirstresponder-crashes-the-ios-app-randomly
The stacktrace indicates an issue regarding the onscreen keyboard. There is a layout change that ends up with a non exsistant delegate. Looks like your code triggers direct or indirect a layoutchange related to the keyboard.
Thing is, a keyboard on the screen is not grated even when your app does recive input.
As for the iPad Pro and the Smart Keyboard you may have a quicktype bar and that can be hidden too. Quite some apps have issues with external keyboards.
Try connecting a bluetooth keyboard to one of your test device. Connect it to xcode, set a breakpoint on exeptions and try your textfields. Guess you will find what you are looking for.
May be you might have misspelled any viewcontroller or xib name while initiating it or may be you have changed, name of the file, or moved it, in physical folder and forget to remove it from xcode.

NSRangeException on iOS 8

I upgraded XCode 5 to 6 to test my projects out on the iPhone 6 and 6 Plus and was getting cryptic crashes on startup:
'*** -[__NSArrayM objectAtIndex:]: index 4 beyond bounds [0 .. 3]'
*** First throw call stack:
(
0 CoreFoundation 0x000000010569b3f5 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000104b20bb7 objc_exception_throw + 45
2 CoreFoundation 0x00000001055864d3 -[__NSArrayM objectAtIndex:] + 227
3 UIKit 0x00000001028164e1 _UIViewTopDownSubtreeTraversal + 193
4 UIKit 0x0000000102e43286 -[UIView(UIConstraintBasedLayout_EngineDelegate) _invalidateSystemLayoutSizeFittingSizeAtEngineDelegateLevel] + 128
5 Foundation 0x0000000103aa66df -[NSISEngine tryToAddConstraintWithMarker:expression:integralizationAdjustment:mutuallyExclusiveConstraints:] + 915
6 Foundation 0x0000000103c2f678 -[NSLayoutConstraint _addLoweredExpression:toEngine:integralizationAdjustment:lastLoweredConstantWasRounded:mutuallyExclusiveConstraints:] + 275
7 Foundation 0x0000000103a9ae3a -[NSLayoutConstraint _addToEngine:integralizationAdjustment:mutuallyExclusiveConstraints:] + 220
8 UIKit 0x0000000102e40495 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 474
9 Foundation 0x0000000103aa8a8e -[NSISEngine withBehaviors:performModifications:] + 155
10 UIKit 0x0000000102e4029b __57-[UIView(AdditionalLayoutSupport)
After a LOT of trial and error and trying various XIBs in various configurations, the issue occurred because I was mixing some XIBs with Auto Layout turned on, containing other UIViews (based on XIBs) with AutoLayout off.
Turning AutoLayout off for all of my XIBs solved the issue.
Faced the same issue. Found that the problem is in button whose layer was used as mask for another button's layer for some visual effect (CALayer's mask property). Removing mask button from view hierarchy fixed the problem. I just moved it to view controller scene in storyboard.
Looks like using layer as a mask caused problem in _UIViewTopDownSubtreeTraversal function used by autolayout. Maybe other layer manipulations for some view also can.
One solution I found is that you need to have at least 6 screens and then the app won't crash.
Still trying to get it to work with less screens.
Turned off Auto Layout on my only XIB (LaunchScreen.xib) but that didn't solve the problem.

ios Xcode Debugging - strange bug - Dismissing View Controller

I have literally been tearing my hair out for the past couple of days, as I have a bug in my app that seems to strike at random! I thought I would ask on here to see if anyone has had a similar experience.
The app is just crashing when a certain view controller is loaded. But this only seems to happen 1 out of every 25-30 times - so it just seems completely random to me!
The console shows the following error
Warning: Attempt to dismiss from view controller <UINavigationController: 0x1f025c30> while a presentation or dismiss is in progress!
The app then crashes.
However, there is not actually any code to dismiss this view controller - I use JASidepanels (https://github.com/gotosleep/JASidePanels) however this bug only occurs with one view. So as there is no code to dismiss it, I really am not sure how this is happening. (JASidepanels slides and hides this panel - but this is not called when the view loads)
Below is the symbolicated crash report - I really cannot find much of use in here at all:
Incident Identifier: 8E0C4F14-1B7B-4241-A1D3-37AD55F3D432
CrashReporter Key: fb5a345eac1c4c3ba4fbe6158b1d6af5833f137e
Hardware Model: iPad2,7
Process: appName [7665]
Path: /var/mobile/Applications/130C6C0F-40E0-4EE7-AD2A-F7CFCFD6C462/appName.app/appName
Identifier: appName
Version: ??? (???)
Code Type: ARM (Native)
Parent Process: launchd [1]
Date/Time: 2013-07-02 14:24:24.588 +0100
OS Version: iOS 6.1.3 (10B329)
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Crashed Thread: 9
Last Exception Backtrace:
0 CoreFoundation 0x32f5729e __exceptionPreprocess + 158
1 libobjc.A.dylib 0x3ae1297a objc_exception_throw + 26
2 CoreFoundation 0x32f56d80 __NSFastEnumerationMutationHandler + 124
3 UIKit 0x34d6ff92 -[UIView(Hierarchy) subviews] + 326
4 UIKit 0x34d7b04a -[UIView(Geometry) resizeSubviewsWithOldSize:] + 22
5 UIKit 0x3519cc28 -[UIView(AdditionalLayoutSupport) _is_layout] + 112
6 UIKit 0x34d68a8c -[UIView(Hierarchy) layoutSubviews] + 68
7 UIKit 0x34d627fe -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 254
8 QuartzCore 0x34b0cd86 -[CALayer layoutSublayers] + 210
9 QuartzCore 0x34b0c924 CA::Layer::layout_if_needed(CA::Transaction*) + 456
10 QuartzCore 0x34b0d858 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 12
11 QuartzCore 0x34b0d23e CA::Context::commit_transaction(CA::Transaction*) + 234
12 QuartzCore 0x34b0d04c CA::Transaction::commit() + 312
13 QuartzCore 0x34b0ceac CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 56
14 CoreFoundation 0x32f2c6c8 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 16
15 CoreFoundation 0x32f2a9bc __CFRunLoopDoObservers + 272
16 CoreFoundation 0x32f2ad12 __CFRunLoopRun + 738
17 CoreFoundation 0x32e9deb8 CFRunLoopRunSpecific + 352
18 CoreFoundation 0x32e9dd44 CFRunLoopRunInMode + 100
19 GraphicsServices 0x36a692e6 GSEventRunModal + 70
20 UIKit 0x34db32fc UIApplicationMain + 1116
21 appName 0x0009c1a2 main (main.m:16)
22 libdyld.dylib 0x3b249b1c start + 0
And thread 9 - that crashed:
Thread 9 Crashed:
0 libsystem_kernel.dylib 0x3b310d98 __workq_kernreturn + 8
1 libsystem_c.dylib 0x3b25ecf6 _pthread_workq_return + 14
2 libsystem_c.dylib 0x3b25ea12 _pthread_wqthread + 362
3 libsystem_c.dylib 0x3b25e8a0 start_wqthread + 4
Any help would be greatly appreciated!
Dismissing a Presented View Controller
When it comes time to dismiss a presented view controller, the
preferred approach is to let the presenting view controller dismiss
it. In other words, whenever possible, the same view controller that
presented the view controller should also take responsibility for
dismissing it. Although there are several techniques for notifying the
presenting view controller that its presented view controller should
be dismissed, the preferred technique is delegation. For more
information, see “Using Delegation to Communicate with Other
Controllers.”
Make sure that you don't dismiss you viewController inside this viewcontroller(according to the documentation). The best way dismiss viewController outside use delegate.
“Using Delegation to Communicate with Other Controllers.”
Try to use
if (![self.presentedViewController isBeingPresented]) {
}
I don't think this is connected with modal/presented view controllers at all.
From the stack trace only one thing is clear - it's a typical exception caused by changing objects in collection while enumerating them in the same time. In this case the collection is probably the of subviews (your main thread is enumerating them).
One of the usual causes is updating the view hierarchy from a secondary thread (not the main thread).

Resources