fatal error encountered while deserializing SIL global "UIEdgeInsetsZero"
Asked Answered
H

4

11

Using Swift 4.2 with Xcode 10 beta, if I write:

import UIKit
let foo: UIEdgeInsets = .zero

Then I get a fatal error at compile time:

*** 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
Harelip answered 5/6, 2018 at 15:48 Comment(2)
I ran into this as well. My radar: 40937125.Leclair
This bug is addressed in the Xcode release notes.Morel
E
3

It has been fixed today in Xcode 10 beta 3.

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

"The zero property on UIEdgeInsets can now successfully be used. (40735990)"

Earvin answered 3/7, 2018 at 18:7 Comment(0)
H
35

Here is workaround I found for Xcode 10 beta and Xcode 10 beta 2. Just temporary include this somewhere in your project until you update Xcode:

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

Issue resolved in Xcode 10 beta 3 and newer.

(the resolution happened thanks to this pull request: https://github.com/apple/swift/pull/17122)

Harelip answered 5/6, 2018 at 18:9 Comment(2)
@fabb OK, I changed the link, but both of them redirect to the same page and require to be identified as an Apple developer because it is beta content.Recur
the previous link didn't work, even when i was already logged in, no idea whyComitative
B
3

It is the bug of Swift compiler, see https://bugs.swift.org/browse/SR-7879 for current state and get more information.

You can try to use this workaround:

Replace all occurrence .zero like

tableView.separatorInset = .zero

to

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

Helpful is search .zero in the whole workspace, checking type, and when the type is UIEdgeInsets, just replace .zero.

Burly answered 7/6, 2018 at 5:41 Comment(2)
Or replace .zero with .init() ... you don't need the verbosity of UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)Recur
Why so complicated? Just use UIEdgeInsets()Aqualung
E
3

It has been fixed today in Xcode 10 beta 3.

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

"The zero property on UIEdgeInsets can now successfully be used. (40735990)"

Earvin answered 3/7, 2018 at 18:7 Comment(0)
K
2

Xcode 10 goto Build settings select All and Search for Optimization Level
Change in Swift Compiler - Code Generation Optimization Level Debug : No Optimization[-Onone ] to Optimise for Speed [-O] It worked for me.

Kernite answered 5/10, 2018 at 4:55 Comment(3)
if this happens again, change the settings back to the way they were before, smh.Dysentery
you saved my day.Rill
Change Optimise for Speed [-O] to No Optimization[-Onone] in Optimization Level Release if the problem encountered while Archive.Scaly

© 2022 - 2024 — McMap. All rights reserved.