0

I have a project within a project in xCode. I'm creating a new MyView.h, MyView.m and MyView.xib. When I put the MyView.m and MyView.xib in the outer project I can load the view from the inner project like this:

    MyView *myView = [[MyView alloc] initWithFrame:CGRectMake(0, 0, 320, 60)];
    [[[UIApplication sharedApplication] keyWindow] addSubview:myView];

However, when I move the MyView.m and MyView.xib files inside the inner project I get a linking error:

Undefined symbols for architecture armv7:  "_OBJC_CLASS_$_MyView", referenced from: ...

I'd like to be able to put MyView.m in the subproject because its ViewController is in the subproject and when it's outside the subproject I get the same linking error when I try to connect IBActions from the MyView to MyView's ViewController.

Any help would be great thanks!

1 Answer 1

1

The superproject needs to list the subproject under 'Build Phases' within 'Link Binary with Libraries'. Also, ensure that the MyView.m file is part of the build set of the subproject.

Sign up to request clarification or add additional context in comments.

7 Comments

Thanks that works perfectly. I hit the plus button under Link Binary With Libraries searched for the xcode.proj file in finder and added that. Next I clicked on the blue project name in the top left, then under targets, for each target, went to the build phases tab and drag and dropped MyView.m onto the Compile Sources list.
Errg. Spoke too soon. Everything compiles, but when I make changes to the .xib in interface builder they don't appear in the actual app. Do I have to add the MyView.xib to some xCode setting?
Yes, in the Utilities window (right side), under 'Target Membershp' add the xib. But, if it wasn't there already, the compiler or something would have complained.
hmm, it straight up can't find the xib at runtime when it's in the subproject... only finds it when its in the superproject. The Utilities window won't let me add the xib to the target of the superproject, only the subproject...
You'll only be able to add it to a target in the project that the file is a part of. Must be the xib is in the subproject.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.