Compiling an app, I get Undefined symbols for architecture arm64

I have some third party static libraries which I've put into an XCFramework. When I add the framework to another app, the classes in the libraries are visible when I import the framework, but when I compile the app, I get the following error:

Undefined symbols for architecture arm64:

  "_OBJC_CLASS_$_<Class Name>", referenced from:

      type metadata for Local object.o

  "_OBJC_METACLASS_$_<Class Name>", referenced from:

      _OBJC_METACLASS_$__TtC8Local object.o

The Environment:

IDE: Xcode 12.4

OS: macOS 11.15.4 - Catalina

Machine: MacBookPro15,1

The details:

The XCFramework is built from a project based upon the Framework template.

The libraries, the *.a files, are included in the project and they are "required." Their respective header, *.h files, are included and set to public. They are also listed in the umbrella header file with this notation:

#import <FrameworkName/Library name.h>

In the build settings, SKIP_INSTALL is set to NO. BUILD_LIBRARY_FOR_DISTRIBUTION is set to YES.

I use the following terminal command to archive the framework:

xcodebuild archive -scheme Name -archivePath ./Name-iOS SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES

I then use the following terminal command to create the Xcframework:

xcodebuild -create-xcframework -framework ./NAME-iOS.xcarchive/Products/Library/Frameworks/NAME.framework -output ./NAME.xcframework

I take the product of this and drop it into the "Frameworks, Libraries, and Embedded Content" section of the app project where I want to use the libraries. I could drop the libraries into the app outside of a framework (and I have and they work just fine) but I want to build a single portable object so I can move this functionality from one project to another without a lot of copy and pasting.

So far, so good. When I reference an object in a swift class, like so:

import Foundation
import NAME

class AppLocalObject: ClassInName {

}

Everything seems to be fine. I don't get any errors from Xcode saying it can't find the "ClassInName" object. But when I try to compile the app I get the aforementioned error.

I'm sure I'm doing something wrong that's simple to fix. But I don't know what that is.

Did you ever find a solution to this? I'm experiencing the same thing.

I have exactly the same issue with XCode 13 and MacOS 11.6 when compiling for iPad 3rd gen.

Did anyone find a solution to this? I have a similar problem in Swift, when I set BUILD_LIBRARY_FOR_DISTRIBUTION=YES, some symbols are missing, although if not they are present. Yet it does not work well if BUILD_LIBRARY_FOR_DISTRIBUTION is not set, although it is some runtime problem then...

Compiling an app, I get Undefined symbols for architecture arm64
 
 
Q