IBDesignable drawings not displaying in storyboard - ios

I am having an issue with IBDesignable elements not appearing in the storyboard view. It seems to be particular to my machine/version of Xcode (2015 11" Macbook Air running MacOS 10.14.4 and Xcode 10.2.1) and not an error in the code, as the same project displays fine when run on a 13" Retina (Xcode 9.2). It also displays correctly in the simulator.
I have tried cleaning and rebuilding the project, creating a new project, restarting Xcode, restarting the computer, deleting derived data, and updating to the latest version of Xcode but have had no success.
When I attempt to run Editor > Debug Selected Views, I get the following error: "Could not attach to pid: #### Error 1."
Below is an image showing my IBDesignable class and the resulting storyboard presentation.
Any help with this would be greatly appreciated!
UPDATE:
I also noticed that when I select the designable view, the inspector reads "Designables Updating," as in the image below:

This finally solved my problem:
https://stackoverflow.com/a/26720740/5291486
To sum up, I enabled Editor > Automatically Refresh Views and then clicked Editor > Refresh All Views.

Verify if the code in your draw function is correct.

Related

Xcode 9 Storyboard: an internal error occurred. editing functionality may be limited

When I am opening my project in Xcode 9, getting above error for Storyboard and Launchscreen.
Note: Cleaning derived data didn't help me.
Please have a look at the screenshot.
You can find the issue in Problem Report, just clink on report a bug and open the log.txt file where you can find the issue. In my case i set invalid table row height.
I was getting same issue in Xcode 10.2.1
I have open interface builder (Story board) as source code just like attached screen shot by right click on storyboard file
Followed below steps
Updated version 3.0 to 3.5 <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0"
Open storyboard as interface builder again
Its get refreshed now and I was not getting error now and view was proper also
However when I revisted the spruce code of story board the version reverted to 3.0 again.
But this worked for as refresh and resolved my problem
Trash derived data by two ways either by command or Preferences.
rm -rf ~/Library/Developer/Xcode/DerivedData/
or
Xcode -> Preferences -> Location -> Derived Data
In Xcode menu go to product clear the project.
Disconnect connected device and restart Xcode and system.
More: https://www.e-learn.cn/content/wangluowenzhang/266937
This generally happens when you have a compiler error in the code that the editor can't figure out or handle. So it crashes. Unfortunately, the only way to fix this is to find out the piece of code and fix it.
I had this when Swift could not figure out the type for one of my variables.
This answer is worth checking out as well.
After quite some tries I was able to fix it here. Xcode-select was pointing to a wrong version of Xcode (here pointing to Xcode 8.3.3).
To check, use
xcode-select -p
To change, use
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
The problem seems to occur when using a Xcode 9 instance while xcode-select points to a Xcode 8 version.
In case you need to use Xcode 8.x again, don't forget to switch back.
When it was happen to me at that time I have configuration was like,
OS : macOS Sierra Version 10.12.6
Xcode : 9.0
I have created new project and open storyboard and this error was there.
Solution : I just quit the xcode and start again and error was not that.
So, it's just requires restart of xcode!
Mostly this error occurred when you have open 2 different version of Xcode.
Solution: Please close both Xcode and clear drived data.now again try, use one Xcode at a time
Check image density. Change to 72dpi or more.
I have also faced this issue.
Solution is very simple just delete the derived data of xcode and restart the xcode.
Just quit (Forcefully if needed) the Xcode and start again.
For me, Just quitting Xcode and open again solved this issue
Xcode 9.4.1
MacOS High Seirra 10.13.4
I had the same issue today
Xcode 10.1 ; Quit Xcode & Restarting Mac Book fixed this issue for today,
I fixed this issue by-
updating my Mac to MacOS High Siera
deleted Xcode
installed new Xcode from AppStore
I faced the same issue. And solved by updating Command Line Tools and/or deleting unused/older Xcode versions,
Go to Xcode Preferences > Locations,
Update Command Line Tools to Xcode 9.0
Delete derived data
Additionally, delete older Xcode versions
Restart Mac
This error is a general error when something goes wrong with Interface Builder. Unfortunately, the error itself does not point to a specific cause. It is sometimes an error in the tools, sometimes an error in the OS, sometimes an error in developer code, and sometimes an error in user configuration.
Common causes include:
Incorrect permissions / ownership set on files.
Manually deleting files in ~/Library/Developer.
Installing buggy 3rd party kexts (especially security or firewall software).
Xcode 9.3
Empty Storyboard/ new project
macOS High Sierra 10.13.4
For my case, this happens when I open a storyboard from a workspace.
So I got rid of workspace and cocoapods. Then just use xcode projects and carthage for thirdparty libraries. Storyboards open faster and without this error.
I just resolved the same bug which appear on my xcode 9.3.1 by following below step,
Clean the projects
Quit the xocde
Removed BUILD folder from project folder
Open again
I also had this issue and I tried most solutions provided here.
In the end, what helped me was quitting Xcode (Version 10.1) and restarting my MacBook.
Just FYI, I got this answer and in the log it said...
Exception name: NSInternalInconsistencyException
Exception reason: scale must be > 0
The reason turned out to be that I'd been converting to dark mode and making my button etc. icons using Image Assets. It turned out that I had a tab controller and the pages it was pointing to did not have their icons set to asset catalog images yet.
Just Quit project and again open Story Board will ok with all the design controls. In my case .
For all others that is facing to this problem and had no luck deleting derived data, it seems there is a bug when you try to add aspect ratio between a element and superview. So when you add aspect ratio constraint and then after you change the second element in the inspector to superview, the constraint is still in the element hierarchy but it should be moved to view hierarchy or, better, add the aspect ratio constraint dragging from element to superview and selecting equal width.
The same problem, Xcode Version 12.0 (12A7209). Apple from Xcode 9 to 12 didn't fixed no one problem with Storyboard.
Solution: Just Re-open your project.
I faced the same problem and error in my storyboard today. One of my controllers was showing nothing but a black background and blue outlines.
I fixed this as follows
Create a new controller
Copy views from the old (dysfunctional) controller to the new controller
Connect views to their respective outlets in the .swift file. (Constraints weren't lost when I copied the views from the old to the new controller)
I had this problem using Xcode 12.2
Some time after adding a UITabBarController to my storyboard, I started getting this error. Checking the log provided by Xcode, I figured out that it was related to the tab bar controller, specifically because it's not supported as detail view for split view controller. Weird, because I didn't use split view controller.
=================================
ASSERTION:
=================================
Failed to update scene 'ihF-5r-7AU, uvd-WH-zGG, Tgo-fH-4sa, ExD-dD-O6v, BUC-1K-8XU, and SVS-tP-wFU' with IBLayoutConstraint (x120), IBUIViewAutolayoutGuide (x6), UIButton (x3), UIImageView (x2), UILabel (x14), UINavigationItem (x5), UITabBarItem (x2), UITableView (x3), UITableViewCell (x2), UITableViewCellContentView (x2), UIView (x15), and UIViewController (x6).
Exception name: NSInvalidArgumentException
Exception reason: UITabBarController is unsupported as viewController for -[UISplitViewController setViewController:forColumn:] in Primary column
Finally, as someone pointed out, I checked the storyboard source code and found a few splitViewMasterSizeMetrics tags, one tag per tab from my tab bar controller. I deleted those tags and worked like a charm. I don't even know how that split view references were added as I've never used it on my project
So my take would be:
check your log
if you can't still figure out the problem, search on the storyboard source code for any occurrences related to the error
I had the same issue. Very old project and UI builder showing just boxes and giving the scale must be > 0 error. Had some old graphics in the UI with less than 72 dpi. Deleted those / replaced them with 72 dpi or more and voila. Instantly everything was OK. Did the usual delete derived data and reboot and and and but this was the cure.
-> Check images less than 72 dpi and repair them.
Quit Xcode and reopen it without using Rosetta and everything will be OK.
Step 1) Open storyboard as source code as shown below:
Step 2) You will see this line on top, change version="3.0" into version="3.5"
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
3) Step 3 Restart Xcode.
Hope this will help you.

XCode Storyboard is empty and changes not visible on it

I have a serious problem on XCode. I can not see my storyboards correctly even they are full of elements. Sometimes elements are visible after I restart the XCode but later it happens again. Another issue is that even I change fonts or change locations of elements its not visible on storyboard until I restart the XCode.
XCode version is: 8.2.1 (8C1002)
You can see in the image that storyboard is transparent.

Xcode 8 storyboard error

Anyone can help me something goes wrong with me, I cant see my storyboard View, subview, imageview. All became white and its show error like on storyboard file
"An internal error occurred. Editing functionality may be limited."
I have open my project in xcode 8 and 8.1 beta latest xcode but both have same issue.
Main thing is that this is happening with all project not just one.
For example i am opening new project that is open in xcode 8 and i cant see that storeyboad file. Old project is working fine which are not open in xocde 8 i can see that project and open in xcode 7.3.1. but if i open that in xcode 8 and convert to xcode 8 compatible and this issue happen.
I have the same problem with Xcode.
I resolved it by disabling SIP (System Integrity Protection):
Press Command-R when start hold til logo and loading status appear
Open terminal
In terminal print: csrutil disable
Restart system
I have also faced this issue and resolve it by only follow these steps:-
Go to Xcode -> Preferences
Select Locations Tab
Click on Derived Data arrow.
Trash Derived Data Folder.
Restart System
Automatic Fixed this issue.
May this help you.
They inserted autolayout a few versions ago, exactly for this foreseeable reason. It's highly discouraged to use storyboards without autolayout, if you want to work with size classes, different devices with different screen resolutions, orientations, ecc.
My suggestion is revert the project to previous commit, reopen it with xcode7, add the needed constraint and reopen with xcode8 (you will still have problems, because of the many bugs of the new storyboard but they are mostly fixable).
Another option to keep working with in xcode8 it is to use a "freeform" simulated size from the Size inspector of the view controller and adapt the sizes to the old viewcontroller dimensions, but you will have to manage compatibility with all devices sizes programmatically, as i hope it is already being done. It doesn't anyway guarantee that everything works
There are some bugs in storyboard of xcode 8 so if you are not using autolayout then you should use xcode 7. now as you said in question that you are getting problem to open storyboard in older xcode (i.e. 7.x) that because once you open project in xcode 8 then it's change some configuration of storyboard which are not compatible with older xcodes.
So now for solution Open your project in xcode 8 -> open storyboard -> File inspector -> Under Interface builder document -> select xcode 7.x instead of latest xcode 8 from Open in
It will show popup something like Saving for Xcode 7.x will close your document and data for Xcode 8.0 features will be removed. Click Save and close the xcode 8 and open project in your older xcode (7.x) and you will able to open storyboard as it was before!!!
You can refer below screenshot,
Hopefully Apple will fix issue related storyboard and in newer version of xcode 8 you will able to switch project without messing up your UI! But right now there should be a workaround as i mentioned above! Try it!!
for me I just make all the views in storyboard size to inferred
^^"

Can't open storyboard or xib files in xCode 6 or more

Every time I try to open storyboards and xib files in new xCode 6 or 6.1 and on Yosemite. This happens while my colleague can open it in xCode 6 on Maverick. I repeatedly get following error:
The document "MainStoryboard.storyboard" could not be opened. The operation couldn’t be completed. (com.apple.InterfaceBuilder error -1.)
I still can open it on xCode 5 on Yosemite. I also tried this method:
Open xib file in an text editor and remove all ImageViews' property of ImageName which has .png format; It helped to open some of it but not All of them!
It is a very bad situation and I am stuck!
This information are provided by console:
Exception raised while unarchiving document objects - -[NSTaggedPointerString getCharacters:range:]: Range {0, 10} out of bounds; string length 4
What is the problem and how can I solve it?
Well the problem was with name of some images I used in UIImageViews.
I opened xib files in a text editor and find all of these patterns "X/Y.png".
And I replaced it with "Y.png".
That solved my problem!
Back the project up before you do this but:
Drop to terminal
Confirm that Developer Tools are set up correctly by typing xcode-select -p
(it should be /Applications/Xcode.app/Contents/Developer)
If it isn't then, it should be pointing to wherever your Xcode lives i.e. /Applications/MyDeveloperTools/Xcode.app/Contacts/Developer
You can change it by running:
xcode-select -s /path/to/the/folder/where/xcode/is/Xcode.app/Contents/Developer
If that's all fine then.
Drop to terminal (or stay there if you're still there
Navigate to your project folder (where the Xibs are) n.b. its important that the above steps are right too!
run ibtool --upgrade myNonWorkingXibOnXode6.xib
From here on in, that Xib should work fine.
Another note is that "compiled nibs won't work via that any more"
Had some similar error when opening a storyboard in Xcode 6 for the first time.
One solution, for me was to open the storyboard with your text editor of choice and manually set auto layout to false: useAutolayout="NO". Problem with this approach is that you'll loose all of your layout constraints.
Another option that worked even better for me, was to install/use Xcode 5.1, open the storyboard and, in File Inspector in section Interface Builder Document, update Opens in option to use Default (5.1), then open the storyboard again in Xcode 6.

Running first singleview ios application on Xcode

I'm writing a very first program for iOS in Xcode 6 (Single-view application).
I added a label and ran a simulation.
I have seen this label on a simulator. But when i added an additional button on a Main.storyboard's ViewControler and rebuilt the project - the was no any button. It seems like simulator ran first version without the button. How can i launch last version of my project on a simulator?
Thanks.
Xcode 6 run by default with auto layout enabled along with size classes also enabled..
you can check that by disable both of them by going to your storyboard and show file inspector (you'll find it on the right side pane)
And then rerun the app.. if you find the button in its place.. then you should start learn how to use the auto layout cause it's essential now by apple to support any universal app you wish to create in the future .

Resources