ios – Undefined symbol in linking archive Xcode 15 in mixed Swift/Objective-C


Added Swift code to Objective-C project.
Built and working for simulator. Failing with Undefined symbol error for Archive.

Deep investigation of compiled files

Objective-C “*.o” file wants symbol:

_OBJC_CLASS_$_AClass

But AClass.swift “AClass.o” file have only (per nm output):

0000000000002318 D _OBJC_METACLASS_$_AClass

Comparing with simulator compilation I see that AClass.swift compiled into AClass.o with:

0000000000002890 S _OBJC_CLASS_$_AClass
0000000000002398 D _OBJC_METACLASS_$_AClass

I do not understand why Archive not puts that “S OBJC_CLASS$_AClass”.

What I already did:

  • cleared/removed and restarted all possible;
  • having @objc attributes of cause and
  • re-added swift files to Xcode (first the were placed there strange – not in group and one file showed in several places. But removed completely and re-added so compiled to simulator);
  • experimented with all possible arch settings in build config;
  • compared build logs in attempt to find some special flags preventing this (no special, just -DDEBUG=1 and like that). And of cause compilation and linking used different “sdk” folders. One for simulator and one for iPhone devices;
  • set Debug for Archive and do not remove debug symbols. Set all ONLY_ACTIVE_ARCH to No. No effect;
  • Symbols Hidden by Default is set to No.

How to build Archive finally?

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img