Xcode - Is there a way to disable all IBInspectable temporarily, to speed up Storyboard?

324 Views Asked by At

I really like IBInspectable and IBDesignable features, that allow to speed up things and have a better view of final result, directly in Storyboard. But Gosh…they slow down soooo much my storyboard loading, and makes it very laggy every time I edit a controller that include a view with IBInspectable. It is barely unusable (on 2018 MBP, 16GO RAM). The two libs I have that use IBInspectable are PMSuperButton and Hero.

Note that it is NOT rebuilding, contrarily to this question : IBDesignable view causes endless rebuilding. Also note that unticking Automatically Refresh Views doesn't change anything.

So I'm searching for a way to temporarily disable all of them, as most often I don't need them.

I was thinking of a macro that would be able to toggle it :

#define IBInspectable_togglable IBInspectable //enabled
//#define IBInspectable_togglable //disabled

But this doesn't do the job. And even if it has worked, I had no clue for Swift, which doesn't support macros.

Does anyone has any idea to perform this ?

2

There are 2 best solutions below

0
AaoIi On

You just need to close the project, and open up the xib or storyboard in Xcode without opening the whole project.

That will stop customized IBInspectable from loading.

This will allow you to get a great experience in designing the whole view without lags in your case.

0
dilip On

Just comment out the whole extension that has these @IBInspectable variables, finish your other changes on the storyboard, and uncomment it again when you want to run the project.