IB Does not like to be in the right pane! Impossible to insert new objects or modify in a view.

Here is the set up


I have a UIViewController with several labels, textFields and buttons.


All referenced with IBOutlets.


In viewDidLoad I adapt some texts of labels as needed.


I go to this view through a segue.


So far so good.


Now I insert a new object (label or button or text field)

-> They do not show at run time.

But they are defined in yhe same way as other labels !


I reference them with IBOutlets, without problem.


But if I test them (in viewDidLoad or later in code), they are nil.

Accepted Reply

I may have found the reason, which has nothing to do with left or right position.


I observed that in that case, the file path reference at the top of the view controller is incomplete.


Instead of the full :

Project > Product > Controller > ClassName > selection

it shows only

ClassName > selection


Hence, when I drag from IB to the class to insert an IBOutlet, it is not recognized (message in red in the window of IBOutlet or IBAction creation is like: (could not insert IBAction, class is not part of language swift").

ANother consequence was that changes made in the file were not saved when I closed and reopened the project


This happened after I copied a complete project in Finder, opened the new copy in XCode and started editing the file.

Problem was solved by selecting the class in project files browser: path shown was complete, I could insert IBOutlets.


My analysis so far:

The file displayed is not the one of the project hierarchy, but a copy some where (or a reference in the copied folder ?)

Selecting from project files browser brings the right file reference, hence solving the problem.

  • In my case it was because some classes were inside a group folder and IB was unable to read them. Moving them out of the group folder and into the main root solved the issue. It's an Xcode bug though because Xcode versions before 14.1 is were recognizing it properly!

Add a Comment

Replies

In fact, it was even more curious: any change made in IB did appear in IB, but not at run time (eg: setting constraints, moving objects, …)


I think I have found the problem, which looks like a serious bug in IB:


if the IB pane is open on the right (not the main pane on the left) where the left pane contains some code, changes are not taken into account. Even after closing, reopening, or clean build.


Once I set up with IB panel on the left and code on right, evreything is OK. But all the additions or changes that were made on the right may be lost.


Is this a known bug ?


I submitted bug report #42206298


Edited

That does not occur in all projects.

I may have found the reason, which has nothing to do with left or right position.


I observed that in that case, the file path reference at the top of the view controller is incomplete.


Instead of the full :

Project > Product > Controller > ClassName > selection

it shows only

ClassName > selection


Hence, when I drag from IB to the class to insert an IBOutlet, it is not recognized (message in red in the window of IBOutlet or IBAction creation is like: (could not insert IBAction, class is not part of language swift").

ANother consequence was that changes made in the file were not saved when I closed and reopened the project


This happened after I copied a complete project in Finder, opened the new copy in XCode and started editing the file.

Problem was solved by selecting the class in project files browser: path shown was complete, I could insert IBOutlets.


My analysis so far:

The file displayed is not the one of the project hierarchy, but a copy some where (or a reference in the copied folder ?)

Selecting from project files browser brings the right file reference, hence solving the problem.

  • In my case it was because some classes were inside a group folder and IB was unable to read them. Moving them out of the group folder and into the main root solved the issue. It's an Xcode bug though because Xcode versions before 14.1 is were recognizing it properly!

Add a Comment