*** ImageIO - Could not find ColorSync function during PDF creation

I am trying to create a PDF in my application and everything works, except that when I run my project in a simulator or on a device, I get an exception breakpoint on a line of code that does not crash the application, but generates a log *** ImageIO - could not find ColorSync function 'ColorSyncProfileCreateSanitizedCopy'

. After I continue running, I get another exception breakpoint, which still doesn't crash the application or print any output.

Here is the code I'm using to draw the PDF:

+(void)drawText:(NSString *)textToDraw ofSize:(CGFloat)textSize inFrame:(CGRect)frameRect andRotate:(BOOL)shouldRotate
{

    CFStringRef stringRef = (__bridge CFStringRef)textToDraw;
    // Prepare the text using a Core Text Framesetter
    CTFontRef font = CTFontCreateWithName (CFSTR("Helvetica"), textSize, NULL);
    NSDictionary *attributes = @{ (__bridge id)kCTFontAttributeName : (__bridge id) font };
    CFAttributedStringRef currentText = CFAttributedStringCreate(NULL, stringRef, (__bridge CFDictionaryRef)attributes);
    CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString(currentText);


    CGMutablePathRef framePath = CGPathCreateMutable();
    CGPathAddRect(framePath, NULL, frameRect);

    // Get the frame that will do the rendering.
    CFRange currentRange = CFRangeMake(0, 0);
    CTFrameRef frameRef = CTFramesetterCreateFrame(framesetter, currentRange, framePath, NULL);
    CGPathRelease(framePath);

    // Get the graphics context.
    CGContextRef    currentContext = UIGraphicsGetCurrentContext();

    // Put the text matrix into a known state. This ensures
    // that no old scaling factors are left in place.
    CGContextSetTextMatrix(currentContext, CGAffineTransformIdentity);


    // Core Text draws from the bottom-left corner up, so flip
    // the current transform prior to drawing.
    CGContextTranslateCTM(currentContext, 0, frameRect.origin.y*2);
    CGContextScaleCTM(currentContext, 1.0, -1.0);

    if(shouldRotate){
        CGAffineTransform myTextTransform;
        myTextTransform =  CGAffineTransformMakeRotation  (90 / 180.0 * M_PI);
        CGContextSetTextMatrix (currentContext, myTextTransform);
    }

    // Draw the frame.
    CTFrameDraw(frameRef, currentContext); //This is where the exception breakpoint stops
                                           //*** ImageIO - could not find ColorSync function
                                           //'ColorSyncProfileCreateSanitizedCopy'

    CGContextScaleCTM(currentContext, 1.0, -1.0);
    CGContextTranslateCTM(currentContext, 0, (-1)*frameRect.origin.y*2);



    CFRelease(frameRef);
    CFRelease(stringRef);
    CFRelease(framesetter);
}

      

After I continue the application past these breakpoints, I get more exception breakpoints here:

libc++abi.dylib`__cxa_throw:
0x107726519:  pushq  %rbp  //BREAKPOINT IS ON THIS LINE
0x10772651a:  movq   %rsp, %rbp
0x10772651d:  pushq  %r15
0x10772651f:  pushq  %r14
0x107726521:  pushq  %r12
0x107726523:  pushq  %rbx
0x107726524:  movq   %rdx, %r14
0x107726527:  movq   %rsi, %r15
0x10772652a:  movq   %rdi, %rbx
0x10772652d:  callq  0x107726123               ; __cxa_get_globals
0x107726532:  movq   %rax, %r12
0x107726535:  callq  0x107726ab0               ; std::get_unexpected()
0x10772653a:  movq   %rax, -0x60(%rbx)
0x10772653e:  callq  0x107726aea               ; std::get_terminate()
0x107726543:  movq   %rax, -0x58(%rbx)
0x107726547:  movq   %r15, -0x70(%rbx)
0x10772654b:  movq   %r14, -0x68(%rbx)
0x10772654f:  leaq   -0x20(%rbx), %r14
0x107726553:  movabsq $0x434c4e47432b2b00, %rax
0x10772655d:  movq   %rax, -0x20(%rbx)
0x107726561:  movq   $0x1, -0x78(%rbx)
0x107726569:  incl   0x8(%r12)
0x10772656e:  leaq   0x1d(%rip), %rax          ; __cxxabiv1::exception_cleanup_func(_Unwind_Reason_Code, _Unwind_Exception*)
0x107726575:  movq   %rax, -0x18(%rbx)
0x107726579:  movq   %r14, %rdi
0x10772657c:  callq  0x107729448               ; symbol stub for: _Unwind_RaiseException
0x107726581:  movq   %r14, %rdi
0x107726584:  callq  0x1077265b9               ; __cxa_begin_catch
0x107726589:  movq   -0x58(%rbx), %rdi
0x10772658d:  callq  0x107726af9               ; std::__terminate(void (*)())

      

As soon as I continue with these breakpoints, the PDF is actually created and the application continues to function as expected. These breakpoints are just really annoying and I don't know what to do to fix the problem causing them. This happens on iOS 8.0 and up. Any help with this would be greatly appreciated.

+3


source to share


1 answer


solvable. Avoid using CTFrameDraw (frameRef, currentContext) or drawPageAtIndex: inRect :. And use the basic graphical way to manually generate PDFs. This seems to be an undocumented bug in iOS 8 or higher.



See http://pigfly.github.io/blog/2014/11/11/road-to-ios-0-dot-x/ for details

+1


source







All Articles