I am experiencing a "Command failed due to signal: Segmentation fault: 11" error when building my app. The code that I supect triggering this error, appears in the viewDidLoad method in a custom class, the entire code for this class follows below.
import UIKit
import Bolts
import Parse
import FBSDKLoginKit
import FBSDKCoreKit
import FBSDKShareKit
import ParseFacebookUtilsV4
class SignUpViewController: UIViewController {
@IBAction func signUp(sender: AnyObject) {
}
@IBOutlet weak var userImage: UIImageView!
@IBOutlet weak var interestedInWomen: UISwitch!
override func viewDidLoad() {
super.viewDidLoad()
let graphRequest = FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "id, name, gender"])
graphRequest.startWithCompletionHandler( {
(connection, result, error) -> Void in
if error != nil {
print(error)
} else if let result = result {
PFUser.currentUser()?["gender"] = result["gender"]!
PFUser.currentUser()?["name"] = result["name"]!
PFUser.currentUser()?.saveInBackground()
var userId = result["id"] as String
var facebookProfilePictureUrl = "https://graph.facebook.com/" + userId + "picture?type=large"
if let fbipicUrl = NSURL(string: facebookProfilePictureUrl) {
if let data = NSData(contentsOfURL: fbipicUrl) {
self.userImage = UIImage(data: data)
}
}
}
})
}
Some output from the error log can be viewed here (there is more output, but this part is what seems relevant to me at the moment):
1. While type-checking 'viewDidLoad' at /Users/oivind/Dropbox/søndagsåpent/ParseServerStarterProject/ParseStarterProject/SignUpViewController.swift:28:14
2. While type-checking expression at [/Users/oivind/Dropbox/søndagsåpent/ParseServerStarterProject/ParseStarterProject/SignUpViewController.swift:33:9 - line:62:10] RangeText="graphRequest.startWithCompletionHandler( {
(connection, result, error) -> Void in
if error != nil {
print(error)
} else if let result = result {
PFUser.currentUser()?["gender"] = result["gender"]!
PFUser.currentUser()?["name"] = result["name"]!
PFUser.currentUser()?.saveInBackground()
var userId = result["id"] as String
var facebookProfilePictureUrl = "https://graph.facebook.com/" + userId + "picture?type=large"
if let fbipicUrl = NSURL(string: facebookProfilePictureUrl) {
if let data = NSData(contentsOfURL: fbipicUrl) {
self.userImage = UIImage(data: data)
}
}
}
})"
3. While type-checking declaration 0x7ffb2a8175b8 at /Users/oivind/Dropbox/søndagsåpent/ParseServerStarterProject/ParseStarterProject/SignUpViewController.swift:47:17
4. While type-checking expression at [/Users/oivind/Dropbox/søndagsåpent/ParseServerStarterProject/ParseStarterProject/SignUpViewController.swift:47:30 - line:47:46] RangeText="result["id"] as S"
5. While type-checking expression at [/Users/oivind/Dropbox/søndagsåpent/ParseServerStarterProject/ParseStarterProject/SignUpViewController.swift:47:30 - line:47:41] RangeText="result["id"]"
I am using the latest release of Xcode 7.3 (but no beta).
What I've found so far is that if I comment out this part of code, the app will build perfectly fine:
var userId = result["id"] as String
var facebookProfilePictureUrl = "https://graph.facebook.com/" + userId + "picture?type=large"
if let fbipicUrl = NSURL(string: facebookProfilePictureUrl) {
if let data = NSData(contentsOfURL: fbipicUrl) {
self.userImage = UIImage(data: data)
}
}
But I cannot for the life of me figure out what actually is causing this error.
This is my first question here on SO, I have been searching around for a while and I found a similar thread that seems to lead me in the right direction but the answers there did not quite help me resolve my issue, the other thread that appears to have some relevant suggestions can be found here:
Command failed due to signal: Segmentation fault: 11
Strangely, after the build error appeared, an error in Xcode appeared as well where the syntax highlighting that color highlights parts of the code crashes every 60 seconds or so whenever I edit this particular swift file. Now that may be just a random occurence but I might also be relevant in some way (perhaps some parts of this code is so messed up that it not only won't build but it also crashes parts of Xcode :P )