Controlling the targets Interface Builder builds for IB_DESIGNABLE / IBDesignable
Asked Answered
H

1

13

I'm trying to make use of IB_DESIGNABLE in my app.

The problem is my app is huge and takes an appreciable amount of time to build (ie. many minutes), so I would like keep all my custom views in a separate target and have Interface Builder only build that target to satisfy.

Whatever I try, Xcode seems to build all the targets in my project when doing Interface Builder's "designable" build, even if I move all the storyboards and IB_DESIGNABLE classes into their own framework and remove them from all other targets. The majority of the code in question is written in Objective-C.

Is there anyway to configure or trick interface builder into only building the target I want it to build? I've tried googling but have failed to turn up anything that describes how interface builder decides what to build or how to influence it.

Hindrance answered 1/7, 2016 at 10:41 Comment(2)
Would love to know that considering I have just spent 2 hours trying to exclude iOS only libraries from the IB build which requires x86 architecture.Ostracod
I believe that with Swift the build is really simple. If you use a designable, IB will build the module which contains that designable. A module is a target and that target is being built. Therefore probably the best solution is to move the designables to a separate target, that is, a separate Swift module.Ostracod
T
13

By received wisdom from an IB team member:

If you're looking for faster IBDesignable build times, put custom UI code in it's own framework. IB only builds the target w/ the designable

Here's an example of that strategy implemented in the wild.

Sure doesn't look like there's any way to accomplish this without the separate framework.

Tetragrammaton answered 7/7, 2016 at 23:5 Comment(1)
Thanks alexcurylo! Have some bounty. Will have to give this a go again, very useful to have a working example to compare against.Hindrance

© 2022 - 2024 — McMap. All rights reserved.