Reputation: 349
I just installed Xcode 5.0.2 with OS X Mavericks. When running my project which is originally built for iOS 5.1 on Xcode 4.5 I get the 'NSInternalInconsistencyException' error as shown below:
*** Assertion failure in -[UIStoryboardEmbedSegue perform],
/SourceCache/UIKit_Sim/UIKit-2903.23/UIStoryboardEmbedSegue.m:19
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException',
reason: 'There are unexpected subviews in the container view.
Perhaps the embed segue has already fired once or
a subview was added programmatically?'
What I did was to solve any warnings displayed that are related to deprecated APIs, however I am still facing this problem.
My Questions are:
Note: I noticed I am using iOS 7 in xCode 5 as a base SDK while it used to be iOS 6 on xCode 4.5, but the deployment target was set to 6.0 in both. Changing the deployment target in Xcode 5 to other SDK versions did not fix the issue.
Note 2: I noticed the issue does not happen when running on Xcode 4.5 on iPhone Simulator for iOS 6 and the Base SDK is set to iOS 6.0.
Storyboard Screenshot
The Table View Controller has a container view with an 'embed segue' to a view controller.
Upvotes: 3
Views: 2905
Reputation: 2149
If anyone else stumbles on this here is my story:
After merging my Swift2 feature branch into my Swift3 branch I got this error.
I had a ContainerView in my Storyboard. I added an outlet for this ContainerView to my ViewController. After that I created an override and added a breakpoint to the following method:
override func prepare(for segue: UIStoryboardSegue, sender: Any?)
When the breakpoint was hit, I checked how many subviews the ContainerView has by executing the following in the console.
po containerView.subViews
This told me that my ContainerView already had one subview of the type UIVisualEffectBackdropView (or with a similar name).
So I checked my ContainerView again and realized that the custom class that it was assigned to was of type UIVisualEffectView. This apparently caused it to automatically add the backdropView and thus making it incompatible with the assertion that in the end raises the error. All I had to do was not inheriting from UIVisualEffectView but from a normal UIView. Of course to achieve the visual effect I have to add it to the ViewController that the ContainerView is embedding.
Hope this helps saving somebody from a headache :)
Upvotes: 0
Reputation: 349
I figured it out.
How I had my UI
I am creating a universal app for both iPhone and iPad with a storyboard for each of these devices. I had a tab bar controller connected to a navigation controller which is then connected to a UITableViewController which displays a table in a static cell (in order to have the top rows displayed with the titles). Inside this UITableViewController I had a container view (which was set with a custom class MyApp_UITableViewCell) which displayed many dynamic rows.
The cause
The issue was caused because of the container view that was set to have the custom class as : MyApp_BIUiTableViewCell. By removing the reference to this custom class in the storyboard the issue was removed
How I solved it
Changed the base SDK and Deployment Target to be iOS 7.
In the storyboards for each device: I removed the reference custom cell in the identity inspector for each container view (which was set as MyApp_UITableViewCell)
My Recommendations
For similar issues what I can say is to check the custom classes set and try to remove ones (one by one). Also, try commenting out each viewDidload and viewDidappear contents and see where the issue is being caused.
Upvotes: 1