24
votes

After several changes to my project I suddenly get this build error:

Reference to 'kCGImageAlphaPremultipliedLast' is ambiguous

Reference is ambiguous error screenshot

and when when taking a look at the error it shows me that it is referenced 4 times:

Xcode error screenshot

Can someone please tell me how this can happen and how can I figure out what is causing this? I am not importing anything from CoreGraphics explicitly and my Prefix file only imports ´Foundation.h´ and some self made macros. I am however importing several headers containing pure C code but they are all encapsulated in something like this:

#ifndef __MYCCODE_H
#define __MYCCODE_H
// imports here
// c code here
#endif

This happens in Xcode 5 using LLVM 5.1

Edit: this seems to be a different problem with this project. after commenting this line of code I get another error:

Malformed or corrupted AST file: 'Unable to load module "/Users/xxx/Library/Developer/Xcode/DerivedData/ModuleCache/1NHZ5MC2OSMJV/CoreImage.pcm": module file out of date'

Removing the module and adding it again did not help. Deleting the derived data also didn't help. This error also appears when going back to a working commit.

8
Please post your codes instead of screenshots - Raptor
@Raptor for me this problem seems like it is hidden somewhere in the project and not just in this function and i can't just post my whole project here. also i an using the same function in other projects and it is not happening there. - HellGate
I think you have wrote 'include' instead 'import' somewhere in your code. - Cy-4AH
@Cy-4AH i didn't but i also updated my question since something different just happened - HellGate
try cleaning your build and deleting the app from the device. Then run the build again - Ignacy Debicki

8 Answers

18
votes

Ok after creating a new Project and coping everything to this project the build was successful however i got this "Malformed or corrupted AST file" error several times again but it can be solved by:

  • Clean the project
  • Deleting everything inside '~/Library/Developer/Xcode/DerivedData/ModuleCache/' (the button inside the organizer window did not work for me)
  • Clean once more
  • Build project

after that it works just fine except that i have to do this fix from time to time

i also did a diff to the old project and it seems a lot of frameworks and other old stuff got stuck in there from testing things so in case you have this check your project settings file for old stuff.

i thought that xcode and me can be friends one day. guess not...

15
votes

This's maybe you import like this:

#import "xxxx.h"

I fix it through this:

#import < xxxx/xxxx.h>

13
votes

I have got this problem when I have imported a header file twice. After one of them is removed, the problem disappears.

10
votes

For anyone still struggling with issue: Non of the of the proposed solutions worked in my case. I'm compiling all my frameworks using Carthage and was getting these errors in my main project whenever I import a header of a framework that's using a framework used also by my main project. What eventually solved it was disabling 'Modules' on the main project. enter image description here

1
votes

Remove use_frameworks! from pod file fix my ambiguous problem.

1
votes

Well some solutions here are nice but use_frameworks! is exactly what I need now even thou it made this problem happening. But it looks like build does not like when I use frameworks and header is referenced twice like this

#import "TSMessage.h"
#import "TSMessage+CSExtension.h"

but problem gets away when it compiles like this

#import "TSMessage+CSExtension.h"
0
votes

use

#import "anyviewcontroller.h"

instead of any module

@import anymodule;

I am using LGSideMenuController, when i integrate it first time, it is working well, but i don't know why i got this error after some time.

so i replaced module @import LGSideMenuController; into header file Like this #import "UIViewController+LGSideMenuController.h"

and error goes away.

0
votes

I just had the same warnings littering up my build report (but only under the triangle). In the end what worked for me was to insure that EVERY usage of:

#import <Module/Module.h> 

in the app was replaced by:

@import Module;

Now all those annoying warnings are gone!