24

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.

shim
  • 9,289
  • 12
  • 69
  • 108
HellGate
  • 708
  • 1
  • 5
  • 20
  • 7
    Please post your codes instead of screenshots – Raptor Aug 19 '14 at 08:07
  • @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 Aug 19 '14 at 08:13
  • 1
    I think you have wrote 'include' instead 'import' somewhere in your code. – Cy-4AH Aug 19 '14 at 09:02
  • @Cy-4AH i didn't but i also updated my question since something different just happened – HellGate Aug 19 '14 at 09:18
  • try cleaning your build and deleting the app from the device. Then run the build again – Ignacy Debicki Aug 20 '14 at 16:11
  • @IgnacyDebicki this were the things i did first when this happened. also its a build error and not a launch error. however i am currently creating a new project and moving everything to the new project. so far it includes most of the files and no build error (however some strange header not found errors but i will figure that out soon i hope) – HellGate Aug 20 '14 at 17:26
  • http://stackoverflow.com/questions/31199442/reference-to-is-ambigous-error-in-xcode/41765279#41765279 – Mohit Tomar Jan 20 '17 at 13:55

8 Answers8

18

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...

HellGate
  • 708
  • 1
  • 5
  • 20
  • I spent hours and hours in trying to solve my problem. Thank you so much for this. I cannot say I understand what is going on, but my project compiles. Thanks a billion! – Sjakelien Dec 27 '14 at 13:06
  • My project was building just fine, but I was plagued with these errors which were preventing me from using any kind of autocomplete and forced me to apply "runtime debugging". No other posts addressed this issue directly- thank you! – William Smith Jan 20 '15 at 14:31
  • Excellent, This answer should get more up votes, (the button inside the organizer window also did not work for me) – Umair Apr 17 '15 at 13:34
  • I was having a similar problem, in a multi-project workspace, where it was building successfully, but _then_ complaining about "Reference to is ambiguous" for enums in my lowest-level common library/framework. So no problem building, but all these annoying errors showing up in my Issue navigator that weren't "real errors". Blowing away the ModuleCache as described here fixed it for me, thanks! (I didn't need to create a new project or workspace.) – Apollo Grace Nov 03 '16 at 10:56
  • And old post, I know... But the problem remains... What does 'clean the project' mean? Product -> Clean Build Folder? – Yossi Apr 28 '20 at 08:06
  • 1
    @Yossi i havent touched mac / ios in years but there used to be a project -> clean menu point (next to build) – HellGate May 05 '20 at 14:47
15

This's maybe you import like this:

#import "xxxx.h"

I fix it through this:

#import < xxxx/xxxx.h>

NSKevin
  • 564
  • 8
  • 20
13

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

Jibeex
  • 5,509
  • 3
  • 27
  • 37
  • wow, never thought a duplicated import would throw an error like that.. – highboi Sep 08 '16 at 14:23
  • This was my case too. But the cause was that I've added use_frameworks! to my podfile. Solution was to remove an old import from the file. – RealNmae Nov 28 '16 at 08:25
10

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

Matan Guttman
  • 648
  • 8
  • 16
1

Remove use_frameworks! from pod file fix my ambiguous problem.

furkan
  • 61
  • 3
1

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"
Renetik
  • 5,887
  • 1
  • 47
  • 66
0

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.

Mahesh Cheliya
  • 1,334
  • 1
  • 16
  • 21
0

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!

David H
  • 40,852
  • 12
  • 92
  • 138