草庐IT

ios - Swift 3/Xcode 8 端口后的 Swift 编译器段错误

coder 2023-09-07 原文

我已经在 SO 中检查了多个答案,但似乎没有任何解决方案适合我。在编译我的 iOS (≥9.3) 应用程序时,出现以下编译器错误,因为我将我的项目转换为 Swift 3/Xcode 8。

我尝试清理、删除 DerivedData、重建 Carthage 框架等 - 但没有任何效果 -

也许以前有过这种经历的人可以立即发现问题。

控制台输出/堆栈跟踪:

0  swift                    0x000000010bc8cb6d PrintStackTraceSignalHandler(void*) + 45
1  swift                    0x000000010bc8c5b6 SignalHandler(int) + 470
2  libsystem_platform.dylib 0x00007fffd300dbba _sigtramp + 26
3  libsystem_platform.dylib 000000000000000000 _sigtramp + 754918496
4  swift                    0x00000001090c98d2 llvm::Value* llvm::function_ref<llvm::Value* (unsigned int)>::callback_fn<swift::irgen::emitArchetypeWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::ProtocolDecl*)::$_0>(long, unsigned int) + 530
5  swift                    0x00000001091a7600 swift::irgen::emitImpliedWitnessTableRef(swift::irgen::IRGenFunction&, llvm::ArrayRef<swift::irgen::ProtocolEntry>, swift::ProtocolDecl*, llvm::function_ref<llvm::Value* (unsigned int)> const&) + 240
6  swift                    0x00000001090c96a7 swift::irgen::emitArchetypeWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::ProtocolDecl*) + 247
7  swift                    0x00000001091a39cd swift::SILWitnessVisitor<(anonymous namespace)::WitnessTableBuilder>::visitProtocolDecl(swift::ProtocolDecl*) + 5997
8  swift                    0x00000001091a14d7 swift::irgen::IRGenModule::emitSILWitnessTable(swift::SILWitnessTable*) + 503
9  swift                    0x00000001091138ed swift::irgen::IRGenerator::emitGlobalTopLevel() + 2077
10 swift                    0x00000001091d4fcb performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&, swift::SourceFile*, unsigned int) + 1259
11 swift                    0x00000001090a31c7 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 23687
12 swift                    0x000000010909b265 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 17029
13 swift                    0x000000010905882d main + 8685
14 libdyld.dylib            0x00007fffd2e01255 start + 1
15 libdyld.dylib            0x0000000000000067 start + 757067283

有问题的文件/类如下:

class JSONDataProvider<Input, Output, APIInformation>: DataProvider
    where APIInformation: APIAccessInformation, APIInformation.Input == Input,
    Output: JSONDataType, Input: Equatable, Input:     SignificanceComparable
{
    static var updateCallbacksWithoutInputChange: Bool { return false }

    // MARK: - Protocol Variables
    var callbackId: Int = 0
    var callbacks: [Int : (Result<(Output, Input)>) -> ()]

    var inputCache: Input?
    var outputCache: Result<(Output, Input)>?

    // MARK: - Private Properties
    fileprivate let apiInformation: APIInformation
    fileprivate let requestHandler: URLRequestHandler

    // MARK: - Init
    init(apiInformation: APIInformation, requestHandler: URLRequestHandler)
    {
        self.apiInformation = apiInformation
        self.requestHandler = requestHandler
        self.callbacks = [:]
    }
}

对于上下文:(省略扩展名)

protocol DataProvider
{
    associatedtype Input: Equatable, SignificanceComparable
    associatedtype Output

    static var updateCallbacksWithoutInputChange: Bool { get }

    var inputCache: Input? { get set }
    var outputCache: Result<(Output, Input)>? { get set }

    var callbackId: Int { get set }
    var callbacks: [Int : (Result<(Output, Input)>) -> Void] { get set }

    func fetchData(from input: Input)

    mutating func registerCallback(_ callback: @escaping (Result<(Output, Input)>) -> Void) -> Int
    mutating func unregisterCallback(with id: Int)
}

和:

protocol APIAccessInformation
{
    associatedtype Input: Equatable, SignificanceComparable

    var requestMethod: Alamofire.HTTPMethod { get }
    var baseURL: String { get }

    func apiParameters(for input: Input) -> [String : Any]
}

有什么想法吗?谢谢!

最佳答案

原来泛型是问题所在。由于似乎没有人确切地知道为什么,我已经调整了我的架构,所以我不需要这个通用类型。

我把这个问题留在这里,以防其他人遇到类似问题或知道确切原因和修复方法的人找到这个线程。

关于ios - Swift 3/Xcode 8 端口后的 Swift 编译器段错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39549264/

有关ios - Swift 3/Xcode 8 端口后的 Swift 编译器段错误的更多相关文章

  1. ruby - 如何在 Lion 上安装 Xcode 4.6,需要用 RVM 升级 ruby - 2

    我实际上是在尝试使用RVM在我的OSX10.7.5上更新ruby,并在输入以下命令后:rvminstallruby我得到了以下回复:Searchingforbinaryrubies,thismighttakesometime.Checkingrequirementsforosx.Installingrequirementsforosx.Updatingsystem.......Errorrunning'requirements_osx_brew_update_systemruby-2.0.0-p247',pleaseread/Users/username/.rvm/log/138121

  2. ruby - 如何验证 IO.copy_stream 是否成功 - 2

    这里有一个很好的答案解释了如何在Ruby中下载文件而不将其加载到内存中:https://stackoverflow.com/a/29743394/4852737require'open-uri'download=open('http://example.com/image.png')IO.copy_stream(download,'~/image.png')我如何验证下载文件的IO.copy_stream调用是否真的成功——这意味着下载的文件与我打算下载的文件完全相同,而不是下载一半的损坏文件?documentation说IO.copy_stream返回它复制的字节数,但是当我还没有下

  3. Ruby 文件 IO 定界符? - 2

    我正在尝试解析一个文本文件,该文件每行包含可变数量的单词和数字,如下所示:foo4.500bar3.001.33foobar如何读取由空格而不是换行符分隔的文件?有什么方法可以设置File("file.txt").foreach方法以使用空格而不是换行符作为分隔符? 最佳答案 接受的答案将slurp文件,这可能是大文本文件的问题。更好的解决方案是IO.foreach.它是惯用的,将按字符流式传输文件:File.foreach(filename,""){|string|putsstring}包含“thisisanexample”结果的

  4. Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting - 2

    1.错误信息:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:requestcanceledwhilewaitingforconnection(Client.Timeoutexceededwhileawaitingheaders)或者:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:TLShandshaketimeout2.报错原因:docker使用的镜像网址默认为国外,下载容易超时,需要修改成国内镜像地址(首先阿里

  5. ruby - 为什么不能使用类IO的实例方法noecho? - 2

    print"Enteryourpassword:"pass=STDIN.noecho(&:gets)puts"Yourpasswordis#{pass}!"输出:Enteryourpassword:input.rb:2:in`':undefinedmethod`noecho'for#>(NoMethodError) 最佳答案 一开始require'io/console'后来的Ruby1.9.3 关于ruby-为什么不能使用类IO的实例方法noecho?,我们在StackOverflow上

  6. .net - 是否有 Ruby .NET 编译器? - 2

    是否有适用于Ruby语言的.NETFramework编译器?我听说过DLR(动态语言运行时),这是否将使Ruby能够用于.NET开发? 最佳答案 IronRuby是Microsoft支持的项目,建立在动态语言运行时之上。 关于.net-是否有Ruby.NET编译器?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/199638/

  7. ruby-on-rails - 如何使用 Xcode 4.5.1 在 OSX Lion 10.8.2 上编译 EventMachine gem - 2

    我找遍了所有我能找到的地方,但似乎找不到解决这个问题的办法。我在Lion10.8.2上使用Xcode4.5.1,并尝试为Rails项目运行bundle,但它一直卡在这上面。我正在为Heroku使用Thingem。Bolanos@Jeremys-Mac-mini⦿-1.9.3fishfarm$sudogeminstalleventmachinePassword:Buildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingeventmachine:ERROR:Failedtobuildgemnativeextens

  8. ruby - 为 IO::popen 拯救 "command not found" - 2

    当我将IO::popen与不存在的命令一起使用时,我在屏幕上打印了一条错误消息:irb>IO.popen"fakefake"#=>#irb>(irb):1:commandnotfound:fakefake有什么方法可以捕获此错误,以便我可以在脚本中进行检查? 最佳答案 是:升级到ruby​​1.9。如果您在1.9中运行它,则会引发Errno::ENOENT,您将能够拯救它。(编辑)这是在1.8中的一种hackish方式:error=IO.pipe$stderr.reopenerror[1]pipe=IO.popen'qwe'#

  9. ruby - IO::EAGAINWaitReadable:资源暂时不可用 - 读取会阻塞 - 2

    当我尝试使用“套接字”库中的方法“read_nonblock”时出现以下错误IO::EAGAINWaitReadable:Resourcetemporarilyunavailable-readwouldblock但是当我通过终端上的IRB尝试时它工作正常如何让它读取缓冲区? 最佳答案 IgetthefollowingerrorwhenItrytousethemethod"read_nonblock"fromthe"socket"library当缓冲区中的数据未准备好时,这是预期的行为。由于异常IO::EAGAINWaitReadab

  10. ruby - 如何使用 ruby​​ fibers 避免阻塞 IO - 2

    我需要将目录中的一堆文件上传到S3。由于上传所需的90%以上的时间都花在了等待http请求完成上,所以我想以某种方式同时执行其中的几个。Fibers能帮我解决这个问题吗?它们被描述为解决此类问题的一种方法,但我想不出在http调用阻塞时我可以做任何工作的任何方法。有什么方法可以在没有线程的情况下解决这个问题? 最佳答案 我没有使用1.9中的纤程,但是1.8.6中的常规线程可以解决这个问题。尝试使用队列http://ruby-doc.org/stdlib/libdoc/thread/rdoc/classes/Queue.html查看文

随机推荐