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?
2
Answers
Stack Overflow similar questions hints gave me some more ideas and one of it worked ).. All was needed is just to increase iOS Deployment Target. From 12.0 to 12.4 worked in my case.
Flutter Xcode 12 archive build fails with Undefined symbol: _OBJC_CLASS_$_STPAPIClient
Certainly! Here’s a concise checklist:
@objc
if needed.@objcMembers
on NSObject subclasses.-Swift.h
file).