Hi everyone.
I have a simple type alias: public typealias SendableCustomStringConvertible = Sendable & CustomStringConvertible
Trying to compile framework, I get a compiler error:
Undefined symbols for architecture x86_64:
"protocol descriptor for Swift.Sendable", referenced from:
type metadata accessor for Swift.CustomStringConvertible & Swift.Sendable in BaseError.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The problem is that this error is not reproducable in another project. What are the possible reasons? What am I doing wrong?
1 Like
Jumhyn
(Frederick Kellison-Linn)
2
Is that typealias used anywhere in the project, or does the definition alone seem to break linking?
The alone definition leads to this error. One more interesting thing, the next lines of code don't lead to error:
extension OrderedDictionary: @unchecked Sendable where Key: Sendable, Value: Sendable {}
extension OrderedSet: @unchecked Sendable where Element: Sendable {}
extension NonEmpty: @unchecked Sendable where RawValue: Sendable {}
extension URL: @unchecked Sendable {}
The problem for now is only with typealis. But error occurs in another file. What I mean is typealias is defined in file A, and error occurs in file B.
If I replace typealias with direct protocol composition of Sendable & CustomStringConvertible, the error still occurs, only in file B and only inside this particular framework.
Some more details:
- it is a dynamic framework
- framework imports only one system library: Foundation
- 3 libraries are added via SPM: SwiftCollections, NonEmpty, SwiftURL
The simplified code in file B is:
public protocol BaseError: LocalizedError, CustomStringConvertible, CustomDebugStringConvertible {
var code: Int { get }
var domain: String { get }
var domainShortCode: String { get }
var underlying: BaseError? { get }
var userInfo: [String: any SendableCustomStringConvertible] { get }
}
Just while writing the message above I've got an idea: the minimal deploy target is iOS 12. So, I bumped it to iOS 13 and error has disappeared.
Thanks for response 
Jumhyn
(Frederick Kellison-Linn)
5
Glad you figured it out! Still, I was under the impression that as a marker protocol, Sendable was meant to have no ABI impact, so I’m a bit confused why it would be showing up in linker errors… 
(And, regardless, it seems like availability checking should have thrown this out with a reasonable error messages as opposed to a linking failure)
3 Likes