Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

could not execute support code to read Objective-C class data in the process. at real iPhone device

Tags:

ios

iphone

when this objective-c based method call in Simulator, it doesn't matter. But in real iPhone device, it occurs Thread 1: signal SIGABRT

warning: could not execute support code to read Objective-C class data in the process. This may reduce the quality of type information available.

here is code

+ (NSData *)aesDecrypt:(NSURL *)url :(NSString *)key {

NSData *data = [NSData dataWithContentsOfURL: url];
if (data == nil) {
    NSLog(@"file not found");
    return nil;
}

char keyPtr[kCCKeySizeAES128];
bzero(keyPtr, sizeof(keyPtr));

[key getCString:keyPtr maxLength:sizeof(keyPtr)];

size_t bufferSize = [data length] + kCCBlockSizeAES128;
size_t decryptedBytesSize = 0;

void *buffer = malloc(bufferSize);

CCCryptorStatus result = CCCrypt(kCCDecrypt, kCCAlgorithmAES128, kCCOptionPKCS7Padding, keyPtr, kCCKeySizeAES128, keyPtr, [data bytes],
        [data length], buffer, bufferSize, &decryptedBytesSize);

NSData *decrypted = [NSData dataWithBytes:buffer length:bufferSize];

NSError *error;

if (kCCSuccess != result) {
    NSLog(@"aes decrypt error");
    return nil;
}

return decrypted;
}

enter image description here enter image description here

I tried to fix that code several types.

  • return other types.
  • save NSData to files, and return nothing. read it in swift.

All of my tries can't fix the problems: No problem in Simulator, death in real device - iPhone 6 with iOS 11.3.1

EDIT) attach screenshot: Other Linker Flags enter image description here

like image 989
myoungjin Avatar asked May 15 '18 09:05

myoungjin


2 Answers

There maybe linking problem with Objective C code.

Try one of the following:

  • Go to your project
  • Add -ObjC to your Other Linker Flags
  • Enable Modules (C and ObjC) = Yes
like image 180
Nirav Bhatt Avatar answered Sep 25 '22 03:09

Nirav Bhatt


I had the same error message and traced it to my array declaration:

private var boundaries = [CLLocationCoordinate2D]()

I altered the declaration to explicitly declare boundaries as an CLLocationCoordinate2D array like so:

private var boundaries:[CLLocationCoordinate2D] = [CLLocationCoordinate2D]()

That declaration silenced the error message.

In your case, you're using an old c method, malloc for your buffer instead of letting swift manage your memory so perhaps that's the problem. Or possibly if you explicitly declared decrypted as an array that would take care of the issue.

like image 36
Michael Avatar answered Sep 22 '22 03:09

Michael