Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fatal error encountered while deserializing SIL global "UIEdgeInsetsZero"

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
like image 877
Cœur Avatar asked Jun 05 '18 15:06

Cœur


4 Answers

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)

like image 171
Cœur Avatar answered Oct 11 '22 03:10

Cœur


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.

like image 24
Dilip Bhuva Avatar answered Oct 11 '22 05:10

Dilip Bhuva


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)"

like image 34
Guillaume Vachon Avatar answered Oct 11 '22 05:10

Guillaume Vachon


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.

like image 4
Piotr Merski Avatar answered Oct 11 '22 03:10

Piotr Merski