Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift linking error: type metadata accessor for Module.Class

While working in Swift project, I have two modules, let's say

  1. Base
  2. Feature

Base has a SHService class from where I am calling a function of Feature module (of class SHCommon). Feature module is building without error but Base raises error in linking phase.

Snapshot of workspace:

Base.SHService

import Foundation
import Feature

class SHService {

    public func printMe(printString: String){
        SHCommon().printMe(printString: printString)
    }
}

Feature.SHCommon

import Foundation

public class SHCommon {

    public init(){}
    public func printMe(printString: String) {
        print(printString)
    }
}

Link error:

Any idea why this is happening?

like image 233
Sazzad Hissain Khan Avatar asked Nov 15 '19 13:11

Sazzad Hissain Khan


2 Answers

I had the same error after a long I found the solution that I had to add the not linked framework (library) to any target you important at General -> Frameworks and Libraries

like image 192
Amir Ardalan Avatar answered Sep 23 '22 08:09

Amir Ardalan


error: type metadata accessor for Module.Class

I got this error in Xcode test target. Solution was:

Test target -> General -> select <app> in Host Application -> Allow testing Host Application APIs
like image 37
yoAlex5 Avatar answered Sep 23 '22 08:09

yoAlex5