Swift name manglings


Gerriet M. Denkmann
 

macOS 12.5, Xcode Version 8.3.2 (8E2002), a Cocoa Swift project.

Worked fine; then I changed the name of the Target from “OldName” to "NewName".

Now nothing works. I get told:

Unknown class ‘_TtC4<OldName>10<SomeClass>’, using ‘NSObject’ instead. Encountered in Interface Builder file at path…

I tried cleaning the build folder - but still.

So I had to change the Target back to OldName.

How can one tell Xcode (or the compiler) to redo the name-mangling?

Gerriet.


 


On Jul 7, 2017, at 10:31 AM, Gerriet M. Denkmann <g@...> wrote:

Unknown class ‘_TtC4<OldName>10<SomeClass>’, using ‘NSObject’ instead. Encountered in Interface Builder file at path…

Changing the target name changes the product name and module name (by default unless you explicitly specify them.)
The references to your Swift classes in IB still have the old module name in them. You could update them manually in the IB inspector.

—Jens


Quincey Morris
 

On Jul 7, 2017, at 11:10 , Jens Alfke <jens@...> wrote:

The references to your Swift classes in IB still have the old module name in them. You could update them manually in the IB inspector.

There’s an “Inherit From Target” checkbox in recent Xcodes, in the Identity inspector under the module name field. I would expect that, if checked, to cause the module name change to be picked up automatically.

It may be that this project was created before that checkbox existed, hence the need to change the module name manually. If not, if it’s checked but the module didn’t change automatically, it sounds like it needs a bug report.


Gerriet M. Denkmann
 

On 8 Jul 2017, at 01:16, Quincey Morris <quinceymorris@rivergatesoftware.com> wrote:

On Jul 7, 2017, at 11:10 , Jens Alfke <jens@mooseyard.com> wrote:

The references to your Swift classes in IB still have the old module name in them. You could update them manually in the IB inspector.
There’s an “Inherit From Target” checkbox in recent Xcodes, in the Identity inspector under the module name field. I would expect that, if checked, to cause the module name change to be picked up automatically.
I always wondered what this checkbox is good for.
You are right: when this is checked for all custom classes in IB then the app runs as expected.

As Jens mentioned I could “could update [the module names] manually in the IB inspector”, but using this checkbox is more future proof.

Thanks a lot for your help!

Kind regards,

Gerriet.