6

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 project.pbxproj 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 NSString 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 String class object with as NSString is invalid, somewhere NSAttributedString/NSString creation fails, in some other places calling compare or rangeOfString 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

UPD

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

4
  • 1
    let abc = NSString(string: "abc") alone compiles (if "Foundation" is imported). Can you provide minimal sample code exhibiting the problem? – In any case, a compiler segmentation fault is a bug and should be reported to Apple. Commented Sep 19, 2015 at 20:34
  • @MartinR as I already mentioned, if I create new project, any listed issues go away, all compiles successfully. That happens only on my project that was initially created in the Xcode 6 Commented Sep 19, 2015 at 20:36
  • @MartinR I cleaned my original project and uploaded to the GitHub. Please check it Commented Sep 19, 2015 at 21:14
  • For me it was a lengthy function that contained test data array, Commented Aug 17, 2016 at 12:04

2 Answers 2

1

In "MYHelpers.h/.m" of your project (presumably from https://github.com/AlexandrGraschenkov/MYHelpers) 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;
@end

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.

Sign up to request clarification or add additional context in comments.

1 Comment

@Azat: Yes, some detective work before I call it a day :)
0

I had also faced same problem in my project. See my screen shot My scenario: Find the scenario below in which I had found this bug at my end. 1. I am using my objective- C code in my swift project. 2. Basically It was a category class of UIImage which I was using in my code.

Reason of this bug: As far as I am able to judge that complier was confused with some bit code and it was not able to show exact reason. So it was throwing this below message:

Command failed due to signal: Segmentation fault:11

My solution: I just imported #import <UIKit/UIKit.h> in my category class header file and my bug has been resolved instantly.

Happy to help you!!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.