Azat Azat - 1 year ago 69
iOS Question

Command failed due to signal: Segmentation fault: 11 compile error

I spent a lot of time trying to solve that issue myself and already double checked available answers on SO with the same error. So here are the list of thing that I already excluded from possible reasons:

  1. No issue with frameworks as indicated here. I have created another project with the same frameworks set and all is fine

  2. No issue with SwiftyJSON, also works fine in test project

  3. No compile issues highlighted in the code

  4. I went through two different
    files (from my original project and fresh test project) using comparison tool to find some differences in project settings, all the same

  5. I also compared build command options for two projects and all the same

When I go to the Report Navigator and look for each file which wasn't compiled successfully, I found some weird correlation: any file that use some of the API of
fails to compile. To prove that assumption I found some file which was compiled successfully and added there the following line of code

let abc = NSString(string: "abc")

and then this file stops to compile too.

So for some files it says that casting
class object with
as NSString
is invalid, somewhere
creation fails, in some other places calling
was incorrect etc. But when I copy pasted all that pieces of code that caused
Segmentation fault
error to my new fresh project, they compiled successfully

And of course, that project was compiling fine using Xcode 6 just one day ago

I don't know where to go from here and how to fix that issues, any help will be very useful


I uploaded the project that doesn't compile to the GitHub

Answer Source

In "MYHelpers.h/.m" of your project (presumably from a NSString category with some utility methods is defined:

#pragma mark - NSString+Utils

@interface NSString (Utils)
- (NSString *)trim; // trim whitespace characters with new line
- (NSString *):(NSString *)appendString;
- (NSURL *)toURL;
- (NSString *)URLEncodedString;
- (NSString *)URLDecodedString;
- (NSString *)lightURLEncodeString;
+ (BOOL)emailValidate:(NSString *)email;
- (CGSize)sizeForStringWithFont:(UIFont *)font constrainedToSize:(CGSize)size;
- (id)JSON;

The second method

- (NSString *):(NSString *)appendString;

has an empty selector name. This is allowed in Objective-C, and you can call the method with

NSString *foobar = [@"foo" :@"bar"];

(I don't know if the method was intentionally defined with an empty selector name – I wouldn't recommend it.)

But it causes the Swift compiler to crash. This happens only if NSString is referenced somewhere in the Swift code. (The compiler should never crash, no matter how malformed the input is, so I would recommend to file a bug report at Apple).

You can rename the method to

- (NSString *)appendString:(NSString *)appendString;

(or simply remove it if you don't need it in your project), that should solve the problem.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download