Two targets with separate .xib (image resources with same names)
Asked Answered
S

1

11

I have a project with two targets, let's say appA and appB.

Both targets share code of main view controller (appViewController) except the .xib files.

I also have two sets of png's each for one target.

My file/project structure looks like:

*common* (members of both targets):
    appViewController.h
    appViewController.m

*appA* (members of target appA):
    appViewController.xib
    set of png files

*appB* (members of target appB):
    appViewController.xib
    set of png files

PNG's in both sets have the same names but they are placed in separate folders/groups and one group is member of one target and the other of the other target (same with appViewController.xib)

Everything works fine except when i try to edit .xib files in IB - it seemes to get confused and show partly images from one target and partly from the other.

Since .xib's are somewhat complex (>40 images) editing one with partly wrong images is almost impossible - images have to be properly placed on one background image (background image is also different for appA and appB).

The problem exists only at edit-time (in IB). After compilation all the images in both targets are correct.

I found one quick & dirty solution to this. Before i start editing one .xib i remove references to the other set of png's. That way IB shows correct images for the .xib i'm editing. I simply import back all the references (png's of the other target) when i'm done.

I found a similiar question which was not really answered.

I wonder, does anyone have a cleaner solution to this? There has to be a better way to do it.

Settlings answered 16/1, 2012 at 10:3 Comment(3)
Open a ticket in the Apple Bug Report site.Silicic
Thanx! i'll probably really do that. Just wanted to check with the community if maybe i missed something in the documentation - i haven't read a lot on IB since i usually make all the GUI in code :)Settlings
bug reported under id 10736585Settlings
S
7

No answers so far...

So let me answer my own question (still hoping for a better answer).

When you want to edit .xib of one target, you remove the references of the other targets' resources (pngs).

Then you quit xcode and open your project again. The pngs will be the right ones (since xcode doesn't hold references to the wrong ones at the moment).

When you're done - reimport deleted references (take care that you check the right 'target membership').

Edit: This seems to be a known issue with IB - XCode. Till they resolve it we'll just have to use workaround mentioned above.

Settlings answered 21/1, 2012 at 20:56 Comment(1)
After 8 years still the same issue in Xcode 11.7, unbelievableCowherb

© 2022 - 2024 — McMap. All rights reserved.