We have faced the issue of "abort trap 6" in Xcode 12. Due to this reason app not running using Xcode 12. We are using the swift 5 versions and jsqmessageviewcontroller objective c library.
Below errors getting in Xcode 12.
<unknown>:0: error: fatal error encountered while reading from module 'wwww'; please file a bug report with your project and the crash log
<unknown>:0: note: module 'wwww' full misc version is '5.3.2(5.3.2)/Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)'
top-level value not found
Cross-reference to module 'JSQMessagesViewController'
... JSQMessageMediaData
error: Abort trap: 6 (in target 'zapwww' from project 'zapwww')
If anyone has a solution please help us.
I had the same error in Xcode 12.5.1 and it seems to be a bug that has been fixed in the next beta. However there seem to be several issues that could cause this error. So my solution might not work.
For me the problem was very specific and only happened in the following scenario:
A method that returns an optional RealmObject (might be different in your case) is called.
The returned RealmObject has been assigned a variable.
Trying to unwrap the variable with guard let or if let using the same name for the new safely unwrapped variable.
The easiest fix is using different variable names or
Safely unwrapping the returned object directly without assigning it a variable.
Example that causes the error in my case:
class MyClass {
func returnObject() -> Object? {
return nil
}
func anyMethod() {
let myObject = returnObject()
guard let myObject = myObject else { return } // <-- works anywhere else but here.
}
}
Same example that fixed the error in my case:
class MyClass {
func returnObject() -> Object? {
return nil
}
func anyMethod() {
let myObject = returnObject()
guard let myNewObject = myObject else { return } // <-- Changed name of new variable here
}
}
I've seen people had this issue with other types, so it's not limited to the RealmObject type. But going through all guard let or if let with the same variable name is a good start.
I've also seen other people use fix it by cleaning the build folder or removing packages and reinstalling them. That didn't help for me though.
Problem: Abort Trap (In my case my code is working perfectly but when I trying to make an Archive file I got the "Abort Trap")
Solution:- Just Select Your Project from project Navegater (most Left Pane) Select Project > Select Targets > Build Settings > Swift Compiler - Code Genration > Optimization Level > Debug and Realease make "No Optimization [-Onone]"enter image description here
Flutter Specific
I had to set Optimization Level to No Optimization [-Onone] for Pods target.
Just Select Your Project from project Navigater (most Left Pane) Select
Pods > Build Settings > Swift Compiler - Code Generation > Optimization Level > Debug and Realease make No Optimization [-Onone]
for me i have just remove the library which cause the problem from pods file , then installed again will fix the problem
just had to run: 'pod update' to update my Realm pods and fixed it for me.
Related
I'm an Xcode newbie. I'm using non-modified Swift source code from the Github project that is 100% working itself as it's released to public.
I installed pods for it.
When trying to build this non-modified testing app in xCode, it fails with:
MXKSendReplyEventStringLocalizer.swift:19:7 Type 'MXKSendReplyEventStringLocalizer' does not conform to protocol 'MXSendReplyEventStringLocalizerProtocol'
As the code itself should be working out of the box, I suppose the issue is caused by my Mac's environment.
if I select "Fix" in the problematic code block (adding protocol stubs offered by Xcode), this error disappears on the next build attempt, but new ones appear, I. believe because the placeholder was set by selecting "Fix" previously.
Command SwiftEmitModule failed with a nonzero exit code
About this code:
_class MXKSendReplyEventStringLocalizer: NSObject, MXSendReplyEventStringLocalizerProtocol {
func replyToEndedPoll() -> String {
<#code#>
}
Any advise what direction to investigate is appreciated. Searching other threads related to MXSendReplyEventStringLocalizer didn't help.
Here is the problematic code block** that is highlighted by Xcode on the initial build:
import Foundation
class MXKSendReplyEventStringLocalizer: NSObject, MXSendReplyEventStringLocalizerProtocol {
func senderSentAnImage() -> String {
VectorL10n.messageReplyToSenderSentAnImage
}
func senderSentAVideo() -> String {
VectorL10n.messageReplyToSenderSentAVideo
}
I just updated my Xcode to Version 14.1 (14B47b) from version 13.4. When I try to run my SwiftUI project in the live preview, the "Abort Trap" errors showed everywhere in the project.
Part of the error log is as below:
CompileSwift normal x86_64 /Users/apple/Downloads/SwapSpot/SwapU/ViewModels/ItemVMs/ItemGridViewModel.swift (in target 'SwapU' from project 'SwapU')
unknown:0: error: fatal error encountered during compilation; please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project
unknown:0: note: SmallVector unable to grow. Requested capacity (4294967297) is larger than maximum value for size type (4294967295)
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.
I found a post that answers as such:
We will not observe "Abort: trap 6", if under Build Settings, we are using "Optimize for Speed" in Debug, instead of "No Optimization"
We can also avoid "Abort: trap 6", if we change the following code
guard let batchUpdateResult = batchUpdateResult else { return }
to
guard let batchUpdateResult2 = batchUpdateResult else { return }
I tried both methods mentioned above. Renaming the guard let variable did not work at all. Changing the optimization level in the target removed all the Abort Trap errors, and the project runs successfully in the simulator.
However, the live preview stopped working due to the optimization level. The new error is stated below:
OptimizationLevelError: not building -Onone
"SwapU.app" needs -Onone Swift optimization level to use previews
I believe this is a swift compiler error. Can anyone help me avoid this while keeping the live preview working?
In a Swift 4 Playground this code:
let time = 1234
let description: String? = nil
let keyed: [String : Any?] = [
"time": time,
"description": description
]
let filtered: [String : String] = keyed
.filter{ _, value in value != nil }
.mapValues { value in return String(describing: value!) }
print(keyed)
print(filtered)
Produces this output:
["description": nil, "time": Optional(1234)]
["time": "1234"]
Which is exactly what I want (only key-value pairs where the original value is not nil, with the value unwrapped and converted to a string). However in Xcode 9 (beta 3) my build fails with 'filter' is unavailable. Is this a beta ¯\_(ツ)_/¯ kind of thing, or am I missing something?
You are using Swift 3.2 instead of Swift 4.
You can change it under your target's Build Options > Swift Compiler - Language > Swift Language Version
Excerpt from Foundation's docs:
https://developer.apple.com/documentation/swift/dictionary/2903389-filter?changes=latest_minor
func filter(_ isIncluded: (Dictionary.Element) throws -> Bool) rethrows -> [Dictionary.Key : Dictionary.Value]
Xcode 9.0+
I tried to resolve this a few ways, including rebooting Xcode, clearing DerivedData etc., but at the time nothing worked. I came back to the project several days later and found that the same code which had previously failed to build now built without issue (without my having made any relevant changes). So I'm blaming this on a quirk of the Xcode 9 beta. Or perhaps something was just gummed up somewhere and Xcode eventually cleared a cache or something of that nature. ¯\_(ツ)_/¯
I had the same issue today.
My project that was created in Swift 3.x with xCode 8.x. After the upgrade to xCode 9 it was working fine until today when the 'filter is unavailable' error kicked in.
Setting the Language Version explicitly to Swift 4 didn't solve it. (Neither did cleaning the project, relaunching xCode etc.)
The trick -that worked for me- was to convert to whole project to Swift 4.
(I used started with the migration tool at Edit/Convert/To current Swift syntax, which wasn't too helpful in may case but that's a completely different matter.)
After that the error was gone...
In a Swift 4 Playground this code:
let time = 1234
let description: String? = nil
let keyed: [String : Any?] = [
"time": time,
"description": description
]
let filtered: [String : String] = keyed
.filter{ _, value in value != nil }
.mapValues { value in return String(describing: value!) }
print(keyed)
print(filtered)
Produces this output:
["description": nil, "time": Optional(1234)]
["time": "1234"]
Which is exactly what I want (only key-value pairs where the original value is not nil, with the value unwrapped and converted to a string). However in Xcode 9 (beta 3) my build fails with 'filter' is unavailable. Is this a beta ¯\_(ツ)_/¯ kind of thing, or am I missing something?
You are using Swift 3.2 instead of Swift 4.
You can change it under your target's Build Options > Swift Compiler - Language > Swift Language Version
Excerpt from Foundation's docs:
https://developer.apple.com/documentation/swift/dictionary/2903389-filter?changes=latest_minor
func filter(_ isIncluded: (Dictionary.Element) throws -> Bool) rethrows -> [Dictionary.Key : Dictionary.Value]
Xcode 9.0+
I tried to resolve this a few ways, including rebooting Xcode, clearing DerivedData etc., but at the time nothing worked. I came back to the project several days later and found that the same code which had previously failed to build now built without issue (without my having made any relevant changes). So I'm blaming this on a quirk of the Xcode 9 beta. Or perhaps something was just gummed up somewhere and Xcode eventually cleared a cache or something of that nature. ¯\_(ツ)_/¯
I had the same issue today.
My project that was created in Swift 3.x with xCode 8.x. After the upgrade to xCode 9 it was working fine until today when the 'filter is unavailable' error kicked in.
Setting the Language Version explicitly to Swift 4 didn't solve it. (Neither did cleaning the project, relaunching xCode etc.)
The trick -that worked for me- was to convert to whole project to Swift 4.
(I used started with the migration tool at Edit/Convert/To current Swift syntax, which wasn't too helpful in may case but that's a completely different matter.)
After that the error was gone...
I have a strange problem with the new Xcode 8 (no beta version) and swift3.
Once every other 3-4 times that I compile my code I get a 'command failed due to signal segmentation fault 11' error. I just need to enter new empty line, or sometimes changing some spaces, or add a comment (everywhere in the code) and the error disappears and I can compile again.
This is really strange because I'm not changing anything in the code! And sometimes I can compile and it works, then I don't change anything, I compile again and I get the error.
This is really annoying!
I have noticed this is happening since I have installed several 'Firebase' pods (Firebase, Firebase/Auth etc...). But I need them.
Anyone has any suggestion?
PS: I have set the Enable Bitcode of my project to No as many solution suggested, but nothing. In the error message it is not indicated any swift page where the error can be, an example is:
While loading members for 'Class_name' at
While deserializing 'func_name' (FuncDecl #42)
'func_name' is this one:
public class func loginUser(fir_user: FIRUser) {
let user = SFUser()
user.email = fir_user.email
user.isLogged = true
try! sfRealm.write() {
sfRealm.add(user, update:true)
}
var userToAdd = [String:AnyObject]()
userToAdd["email"] = fir_user.email! as NSString
let ref=FIRDatabase.database().reference()
let usersRef = ref.child(childName)
usersRef.setValue([key:value])
}
But then, as I said, I can just enter an empty row in another file and it compiles!
Thanks
I have the same issue i just figure out that i was using xcode 8.1 and the project's working copy was in xcode 8.2.1 so i just re install xcode 8.2.1 and problem got solved. Hope other can get the help trough this.
Ok, it seems that I have found the solution: it is a problem with Firebase and cocoapods, so 2 solutions:
Download Firebase and import into your project
I, instead, updated cocoapods to the last version and it worked. Upgraded Firebase - Now Getting Swift Compile Error
In my case there was some type checking issue deep down the compiler so the editor didn't give error in the gutter but on building the project I was getting signal setmentation fault 11 error:
1. While type-checking 'GetStoreAPIRequestModel' at /Users/.../StoreAPIModel.swift:9:1
2. While type-checking expression at [/Users/.../StoreAPIModel.swift:15:18 - line:15:31] RangeText="[Dictionary]()"
3. While resolving type [Dictionary] at [/Users/.../StoreAPIModel.swift:15:18 - line:15:29] RangeText="[Dictionary]"
So I changed my code from:
var stores = [Dictionary]() {
willSet {
allStores.removeAll()
for model in newValue {
allStores.append(StoreAPIModel(dictionary: model as! Dictionary).getModel())
}
}
}
To (more descriptive dictionary):
var stores = [[String : Any]]() {
willSet {
allStores.removeAll()
for model in newValue {
allStores.append(StoreAPIModel(dictionary: model as [String : AnyObject]).getModel())
}
}
}
This is tricky problem. Issue can be with line of code or syntax. I was getting similar error and it was due to incorrect usage of dictionary. I was trying to increment the value of dictionary element.
Solution is to triage the code, detailed error provide which module has issue, so try commenting part of code until you find the line which is causing the issue.
Hi i had the same issue with FireBase , my problem was that i was extending FIRStorageReference and FIRDatabaseReference and some time it compile successfully some time i get
command failed due to signal segmentation fault 11
so i removed that files and implement the method other way , now everything works fine.
Found my problem when this occurred. (No cocoapods.) I thought I had left the program in a working state, but I was wrong. I am writing a straightforward command-line program. What it does is somewhat general, so I defined all the strings that make it specific in let statements at the top of the program so that I could someday use the program in a different context.
Since that was working so well, I thought I'd be clever and do the same with a filter of an array of dictionaries. I turned:
list.filter { $0["SearchStrings"] == nil }
into:
let test = { $0["SearchStrings"] == nil }
// ...
list.filter(test)
meaning to continue working on the let, but I never went back and did that. Building gave me the segmentation fault error. Defining test as a function fixed the problem.
(Incidentally, I understand how to strip a filtering function down to the terse braces notation in the context of the call to Array.filter, and why that works, but I don't understand why I can't assign the brace expression to a constant and use it as such.)