Swift 3 Compiler error: Command failed due to signal: Segmentation fault: 11 - swift

I'm trying to extend a Firebase class but am getting a compiler error with the following:
It appears to be related to the failable initialiser but I'm not sure. Is this a bug?
class FIRAuthMock: FIRAuth {
var mockUser: FIRUser
init?(user: FIRUser) {
self.mockUser = user
}
}
Xcode 8.0, Swift 3.0

Related

swiftc Segmentation fault 11 saying "While emitting IR SIL function"

Archiving iOS project makes swiftc throw segmentation fault 11. I just updated to xcode 11.5, swift v5.2.4. Project builds and runs on emulator. The exact error message is "3. While emitting IR SIL function" and the function code is below that this error is pointing to the function name. Can someone point whats wrong with new version as the code was working before update Xcode and swift.
func startC() {
if let controller = self as? MyProtocol {
if !startRandomizer() {
controller.finished()
} else {
controller.sendComm(to:nil)
}
}
}

Xcode 11.4 Cast from 'Bool.Type' to unrelated type 'AnyClass' (aka 'AnyObject.Type') always fails

Since Xcode 11.4, the following code:
override public class func transformedValueClass() -> AnyClass { // What do I transform
return Bool.self as! AnyClass
}
gives a warning: Cast from 'Bool.Type' to unrelated type 'AnyClass' (aka 'AnyObject.Type') always fails
Tried replacing the as! with as, this removes the warning, but the app won't build anymore and the Buildtime displays: error: Segmentation fault: 11
What's going on with Xcode 11.4 and this?

Xcode project keeps crashing after converting to Swift 4, "Class implemented in both..."

I recently converted an Xcode project to Swift 4. I fixed all the syntax errors. However, my app now crashes, after outputting an error message which starts
Class MPExportableArtworkProperties is implemented in both...
I have been looking around S/O but all I find is that its related to MapBox which I don't even have in my project/podfile. Can it have something to do with the regular map-kit? It crashes the app when I open the tab with my map, so I'm guessing that's where the problem is.
Full error message, formatted for readability:
objc[24634]: Class MPExportableArtworkProperties is implemented in both
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/MediaPlaybackCore.framework/MediaPlaybackCore
(0x126b1b108) and
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/MediaPlayer.framework/MediaPlayer
(0x1258107d0).
One of the two will be used. Which one is undefined.
This is the plowerthingscontroller saying that you are logged in
libc++abi.dylib: terminating with uncaught exception of type
NSException
I had this exact error, and in the end found it was due to something completely different: a circular dependency. Consider:
class DependencyManager {
static let shared = DependencyManager()
let aDependency: SomeDependency
init() {
aDependency = SomeDependency()
}
func resolve() -> SomeProtocol {
// Create the actual class
return 0
}
}
where SomeDependency requires SomeProtocol
class SomeDependency {
let x: SomeProtocol
// Me trying to be clever and auto-inject the dependency
init(x: SomeProtocol = DependencyManager.shared.resolve()) {
self.x = x
}
}
So when you first access DependencyManager.shared it tries instantiate SomeDependency, which requires DependencyManager.shared to already be instantiated.
I have no idea why MPExportableArtworkProperties is mentioned in the error, however cleaning up the code fixed the issue for me.

Protocol adoption by extension causing "Abort trap: 6" on Xcode 8.3.2/Swift 3.1

The following code causes the Swift compiler to crash with Command failed due to signal: Abort trap 6:
import UIKit
protocol ZeroProtocol {
static var zero: Self { get }
}
// CGPoint already has CGPoint.zero so we attempt to adopt ZeroProtocol.
// This causes "Abort trap: 6" on compilation.
extension CGPoint: ZeroProtocol {}
I'm almost certain that this code compiled a few months ago without trouble. Strangely, adopting the protocol with my own struct doesn't produce any error:
import UIKit
protocol ZeroProtocol {
static var zero: Self { get }
}
struct TestStruct {
static var zero = TestStruct()
}
// Works fine.
extension TestStruct: ZeroProtocol {}
I have submitted a bug report to Apple, but any workaround would be appreciated.

Error when using Generic as property type in Swift

I'm having an issue when using a Generic as the type constraint on a property. Here is a very simple example:
import UIKit
class TSSignal<MessageType> {
var message: MessageType?
init() {
}
}
In Xcode 6 Beta (6A215l) this will not compile. It fails with the following error at the bottom:
TSSignal.swift:13:9: error: unimplemented IR generation feature non-fixed class layout var message: MessageType? ^ LLVM ERROR: unimplemented IRGen feature! non-fixed class layout Command /Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolc‌​hain/usr/bin/swift failed with exit code
But, if I remove the line var message: MessageType? it will build fine. Any ideas? Thanks.
Edit - changed code and error to reflect current status of issue
Edit - related: Swift compile error when subclassing NSObject and using generics
Update (6/18/14) - The issue still persists as of Xcode 6 - Beta 2
Update (7/25/14) - The issue still persists as of Xcode 6 - Beta 4 (thanks #Ralfonso, and I verified as well)
Update (8/4/14) - The issue is FIXED as of Xcode 6 - Beta 5!
There is a workaround without type erasure (works as of Xcode6-Beta2):
import UIKit
class TSSignal<MessageType> {
var _message: [MessageType] = []
func getMessage() -> MessageType? {
if _message.count > 0 {
return _message[0]
} else {
return nil
}
}
func setMessage(maybeMessage: MessageType?) {
if let message = maybeMessage {
_message = [message]
} else {
_message = []
}
}
init() {
}
}
EDIT EDIT:
This is definitely a bug in the compiler.
I tried to 'outsmart' the compiler by using the following:
class TSSignal<TMessage>
{
var messageType : Optional<TMessage> = nil
init() { }
}
Same issue.
This is NOT an "answer" (it is my own question), but I thought it worth noting what I did in this case to move passed this situation, for the time being.
import UIKit
class TSSignal {
var message: AnyObject?
init() {
}
}
Lame, but I am sure it's only temporary.