Saz*_*han 9 xcode compiler-errors build ios swift
在Swift项目中工作时,我有两个模块,比方说
BaseFeature Base有一个SHService类,我从那里调用Feature模块的函数(类SHCommon)。功能模块正在无错误地构建,但Base在链接阶段引发错误。

import Foundation
import Feature
class SHService {
public func printMe(printString: String){
SHCommon().printMe(printString: printString)
}
}
Run Code Online (Sandbox Code Playgroud)
import Foundation
public class SHCommon {
public init(){}
public func printMe(printString: String) {
print(printString)
}
}
Run Code Online (Sandbox Code Playgroud)

知道为什么会这样吗?
小智 5
查看您的屏幕截图,我尝试复制此设置并遇到了同样的问题(我不得不说错误消息有点神秘)。所以问题是您在工作区中有两个 iOS 应用程序项目。虽然 iOS 应用程序是一个 swift 模块,但不可能将一个 iOS 应用程序导入到另一个应用程序中。但是,您可以做的是将您的Feature框架转换为框架,然后将该框架导入Base应用程序。或者将SHCommon类提取到框架中,Feature并且Base将导入。
有关框架的更多信息:https : //developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Tasks/CreatingFrameworks.html
Swift 链接错误:类型元数据访问器
error: type metadata accessor for Module.Class
Run Code Online (Sandbox Code Playgroud)
我在 Xcode 测试目标中遇到此错误。解决方案是:
Test target -> General -> select <app> in Host Application -> Allow testing Host Application APIs
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4196 次 |
| 最近记录: |