简体   繁体   中英

Using bundles with xibs XCode5

I'm trying to build a structure in XCode 5, where several apps share code but each app uses a different UIs.

Since each target will use diffrent xibs, I thought it would be nice to have xibs and images in a bundle (one bundle for each target). But I can't get it to work, when I put xibs in a bundle the aren't compiled into nibs.

Doesn't Xcode 5 support this approach? Which other solution exists?

There's two ways you can do this. You can either use the "bundle" approach as detailed by Matt Galloway in his tutorial on this very subject iOS Library With Resources .

Alternatively, you can use the "pseudo framework" approach, as practiced using Karl Stenerud's iOS Universal Framework .

I looked closely at both approaches and it's indubitable that they each have pro's and cons. In the end I went with the bundle approach. It means an extra step which is to build your bundle then copy that bundle file over to the parent project. However, we felt that it was more orthodox than using the pseudo framework method.

One downside of having Xib components is that with Auto Layout, you'll need to create placeholder containers, so that you can instantiate the Xibs and add them in to your parent view.

ps. Have a look at this post that has some more info:

IOS Static Framework with resources inside

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM