反序列化全局" UIEdgeInsetsZero"

时间:2018-06-05 15:48:11

标签: ios xcode uiedgeinsets xcode10 swift4.2

如果我写的话,将Swift 4.2与Xcode 10 beta一起使用:

import UIKit
let foo: UIEdgeInsets = .zero

然后我在编译时遇到致命错误:

*** DESERIALIZATION FAILURE (please include this section in any bug report) ***
result is ambiguous
0  swift                    0x000000010784fc5a PrintStackTraceSignalHandler(void*) + 42
1  swift                    0x000000010784f066 SignalHandler(int) + 966
2  libsystem_platform.dylib 0x00007fff62a5ef5a _sigtramp + 26
3  libsystem_platform.dylib 0x0000000000000010 _sigtramp + 2639925456
4  libsystem_c.dylib        0x00007fff627fc1ae abort + 127
5  swift                    0x0000000104cf599b swift::ModuleFile::fatal(llvm::Error) + 1915
6  swift                    0x0000000104d2d4d2 swift::SILDeserializer::readGlobalVar(llvm::StringRef) + 1890
7  swift                    0x0000000104dd7f9a swift::SerializedSILLoader::getAllForModule(swift::Identifier, swift::FileUnit*) + 234
8  swift                    0x0000000103b2adbe performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 34750
9  swift                    0x0000000103b1f10f swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7839
10 swift                    0x0000000103ac8c48 main + 13144
11 libdyld.dylib            0x00007fff62750015 start + 1
12 libdyld.dylib            0x0000000000000041 start + 2643132461
Stack dump:
0.  Program arguments: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -merge-modules -emit-module /Users/coeur/Library/Developer/Xcode/DerivedData/Edgy-gbvthkytwkmyekdynhvvbtmysdbk/Build/Intermediates.noindex/Edgy.build/Debug-iphonesimulator/Edgy.build/Objects-normal/x86_64/ViewController~partial.swiftmodule /Users/coeur/Library/Developer/Xcode/DerivedData/Edgy-gbvthkytwkmyekdynhvvbtmysdbk/Build/Intermediates.noindex/Edgy.build/Debug-iphonesimulator/Edgy.build/Objects-normal/x86_64/AppDelegate~partial.swiftmodule /Users/coeur/Library/Developer/Xcode/DerivedData/Edgy-gbvthkytwkmyekdynhvvbtmysdbk/Build/Intermediates.noindex/Edgy.build/Debug-iphonesimulator/Edgy.build/Objects-normal/x86_64/Edgy~partial.swiftmodule -parse-as-library -sil-merge-partial-modules -disable-diagnostic-passes -disable-sil-perf-optzns -target x86_64-apple-ios12.0-simulator -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.0.sdk -I /Users/coeur/Library/Developer/Xcode/DerivedData/Edgy-gbvthkytwkmyekdynhvvbtmysdbk/Build/Products/Debug-iphonesimulator -F /Users/coeur/Library/Developer/Xcode/DerivedData/Edgy-gbvthkytwkmyekdynhvvbtmysdbk/Build/Products/Debug-iphonesimulator -enable-testing -g -module-cache-path /Users/coeur/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -swift-version 4.2 -enforce-exclusivity=checked -Onone -D DEBUG -serialize-debugging-options -Xcc -working-directory -Xcc /Users/coeur/Development/Edgy -Xcc -I/Users/coeur/Library/Developer/Xcode/DerivedData/Edgy-gbvthkytwkmyekdynhvvbtmysdbk/Build/Intermediates.noindex/Edgy.build/Debug-iphonesimulator/Edgy.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/coeur/Library/Developer/Xcode/DerivedData/Edgy-gbvthkytwkmyekdynhvvbtmysdbk/Build/Intermediates.noindex/Edgy.build/Debug-iphonesimulator/Edgy.build/Edgy-generated-files.hmap -Xcc -I/Users/coeur/Library/Developer/Xcode/DerivedData/Edgy-gbvthkytwkmyekdynhvvbtmysdbk/Build/Intermediates.noindex/Edgy.build/Debug-iphonesimulator/Edgy.build/Edgy-own-target-headers.hmap -Xcc -I/Users/coeur/Library/Developer/Xcode/DerivedData/Edgy-gbvthkytwkmyekdynhvvbtmysdbk/Build/Intermediates.noindex/Edgy.build/Debug-iphonesimulator/Edgy.build/Edgy-all-target-headers.hmap -Xcc -iquote -Xcc /Users/coeur/Library/Developer/Xcode/DerivedData/Edgy-gbvthkytwkmyekdynhvvbtmysdbk/Build/Intermediates.noindex/Edgy.build/Debug-iphonesimulator/Edgy.build/Edgy-project-headers.hmap -Xcc -I/Users/coeur/Library/Developer/Xcode/DerivedData/Edgy-gbvthkytwkmyekdynhvvbtmysdbk/Build/Products/Debug-iphonesimulator/include -Xcc -I/Users/coeur/Library/Developer/Xcode/DerivedData/Edgy-gbvthkytwkmyekdynhvvbtmysdbk/Build/Intermediates.noindex/Edgy.build/Debug-iphonesimulator/Edgy.build/DerivedSources/x86_64 -Xcc -I/Users/coeur/Library/Developer/Xcode/DerivedData/Edgy-gbvthkytwkmyekdynhvvbtmysdbk/Build/Intermediates.noindex/Edgy.build/Debug-iphonesimulator/Edgy.build/DerivedSources -Xcc -DDEBUG=1 -emit-module-doc-path /Users/coeur/Library/Developer/Xcode/DerivedData/Edgy-gbvthkytwkmyekdynhvvbtmysdbk/Build/Intermediates.noindex/Edgy.build/Debug-iphonesimulator/Edgy.build/Objects-normal/x86_64/Edgy.swiftdoc -emit-objc-header-path /Users/coeur/Library/Developer/Xcode/DerivedData/Edgy-gbvthkytwkmyekdynhvvbtmysdbk/Build/Intermediates.noindex/Edgy.build/Debug-iphonesimulator/Edgy.build/Objects-normal/x86_64/Edgy-Swift.h -module-name Edgy -o /Users/coeur/Library/Developer/Xcode/DerivedData/Edgy-gbvthkytwkmyekdynhvvbtmysdbk/Build/Intermediates.noindex/Edgy.build/Debug-iphonesimulator/Edgy.build/Objects-normal/x86_64/Edgy.swiftmodule 
1.  While deserializing SIL global "UIEdgeInsetsZero"
error: Abort trap: 6

4 个答案:

答案 0 :(得分:36)

以下是我发现 Xcode 10 beta Xcode 10 beta 2 的解决方法。只是临时将此包含在项目中的某处,直到您更新Xcode:

#if swift(>=4.2)
import UIKit.UIGeometry
extension UIEdgeInsets {
    public static let zero = UIEdgeInsets()
}
#endif

已在Xcode 10 beta 3及更新版本中解决问题。

(由于此拉取请求,决议发生了:https://github.com/apple/swift/pull/17122

答案 1 :(得分:4)

这是Swift编译器的错误,请参阅https://bugs.swift.org/browse/SR-7879了解当前状态并获取更多信息。

您可以尝试使用此解决方法:

将所有出现的.zero替换为

tableView.separatorInset = .zero

tableView.separatorInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)

在整个工作区中搜索.zero,检查类型以及类型为UIEdgeInsets时,只需替换.zero

答案 2 :(得分:3)

它已在Xcode 10 beta 3中得到修复。

https://download.developer.apple.com/Developer_Tools/Xcode_10_beta_3/Release_Notes_for_Xcode_10_beta_3.pdf

“现在可以成功使用UIEdgeInsets上的zero属性。(40735990)”

答案 3 :(得分:1)

Xcode 10 转到构建设置全选 和搜索优化级别
Swift编译器的更改-代码生成优化级别 调试:无优化[-Onone]以优化速度[-O] 它对我有用。