2

I updated to Xcode 5.1 and can no longer build several of my projects which use Core Plot 1.4, complaining generally about garbage collection, and proposing that I convert to ARC. I complied, but there were several statements that could not be converted. I quickly came to SO to find a solution, and I found a promising one here:

Core Plot and Xcode 5.1 - How to convert Core Plot to ARC?

I followed this suggestion, and it worked for the conversion to ARC. However, I was now left with 2 errors (not warnings) in CPTTextStylePlatformSpecific.m, which complained: “Implicit conversion loses integer precision: 'NSTextAlignment' (aka 'unsigned long') to 'CPTTextAlignment' (aka 'enum _CPTTextAlignment’)”. This issue had not appeared when building the project before the Xcode update.

The offending code:

    // Text alignment and line break mode
NSParagraphStyle *paragraphStyle = [attributes valueForKey:NSParagraphStyleAttributeName];
if ( paragraphStyle ) {
    newStyle.textAlignment = paragraphStyle.alignment;
    newStyle.lineBreakMode = paragraphStyle.lineBreakMode;
}

return [[newStyle copy] autorelease];

And here:

    // Text alignment and line break mode
NSParagraphStyle *paragraphStyle = [attributes valueForKey:NSParagraphStyleAttributeName];
if ( paragraphStyle ) {
    newStyle.textAlignment = paragraphStyle.alignment;
    newStyle.lineBreakMode = paragraphStyle.lineBreakMode;
}

return newStyle;

In both cases, the error was on the line

    newStyle.textAlignment = paragraphStyle.alignment;

I am guessing the enum is an integer, and the integer to long assignment is the issue. Seems like it merits a warning, not an error. Is there a compiler flag I can set to achieve this? Or is there a bigger issue I am missing?

Community
  • 1
  • 1
wudkutter
  • 21
  • 4
  • Do you have warnings as errors turned on? – Jon Shier Mar 13 '14 at 05:08
  • Jshier, excellent and timely response. I had just found this "Related" posting after submitting my question: [link](https://stackoverflow.com/questions/18596460/core-plot-and-xcode-5-compile-error-implicit-conversion-from-enumeration-type?rq=1) – wudkutter Mar 13 '14 at 05:22

1 Answers1

2

I had exactly this issue and found that in the CorePlot project, that I had imported into my project, I had the "Apple LLVM 5.1 - Warning Policies", "Treat Warnings as Errors" set you "Yes". I still get the warning but at least I can build and submit my project. This is still not ideal and I would really like a proper solution - I suppose I'll just have to keep checking the CorePlot repository for updates.

Warnings As Errors...

Sean
  • 440
  • 1
  • 6
  • 20
  • Changing "Treat Warnings as Errors" got me round the problem, but upgrading to Core Plot 1.5.1 also removed the warnings. – AW101 Jun 18 '14 at 15:57