The command could not be completed due to a signal: Segmentation error: 11 compilation error

I spent a lot of time trying to solve this problem myself and already double-checked the available answers on SO with the same error. So, here is a list of things that I have already excluded from possible reasons:

  • There are no problems with the frames listed here . I created another project with the same frameworks, and everything is fine.
  • No with SwiftyJSON , also works great in a test project
  • The code does not highlight compilation problems
  • I looked at two different project.pbxproj files (from my original project and a new test project) using the comparison tool to find some differences in the project settings, anyway
  • I also compared build team commands for two projects and all the same

When I go to Report Navigator and look for every file that has not been compiled successfully, I find some strange correlation: any file that uses some of the NSString APIs cannot compile. To prove this assumption, I found a file that was compiled successfully and added the following line of code there

 let abc = NSString(string: "abc") 

and then this file also stops compiling.

So, for some files, it indicates that the String listing of the class object with as NSString invalid, somewhere the NSAttributedString / NSString creation worked, in some other places an incorrect call to compare or rangeOfString was called, etc. But when I copy all those code fragments that caused the Segmentation fault error for my new new project, they compiled successfully

And of course, this project compiled fine using Xcode 6 just one day ago

I don’t know where to go from here and how to fix these problems, any help would be very helpful

UPD

I uploaded a project that does not compile on GitHub

+6
source share
2 answers

In the "MYHelpers.h / .m" of your project (presumably from https://github.com/AlexandrGraschenkov/MYHelpers ) the NSString category is defined with some utility methods:

 #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 

Second method

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

has an empty selector name. This is permitted 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 would not recommend it.)

But this causes the Swift compiler to crash. This only happens if NSString is mentioned somewhere in the Swift code. (The compiler should never crash, no matter how bad the input is, so I would recommend filing a bug report with Apple).

You can rename the method to

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

(or just delete it if you do not need it in your project), which should solve the problem.

+1
source

I also encountered the same problem in my project. See my screenshot My scenario: Find the scenario below in which I found this error at the end. 1. I use my objective C code in my fast-paced project. 2. This is basically a class of the UIImage category that I used in my code.

The reason for this error: As far as I can tell, the compliment was embarrassed by some bit code, and it could not show the exact reason. Therefore, this message was transmitted below:

Signal Failure: Segmentation Error: 11

My solution: I just imported #import <UIKit/UIKit.h> into the category class header file, and my error was resolved instantly.

Glad to help you!

0
source

All Articles