Reference to 'X' is ambiguous
Asked Answered
A

8

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.

Andromeda answered 19/8, 2014 at 8:6 Comment(7)
Please post your codes instead of screenshotsDeplorable
@Deplorable 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.Andromeda
I think you have wrote 'include' instead 'import' somewhere in your code.Mantellone
@Mantellone i didn't but i also updated my question since something different just happenedAndromeda
try cleaning your build and deleting the app from the device. Then run the build againCrenate
@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)Andromeda
#31199942Intermarriage
A
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...

Andromeda answered 21/8, 2014 at 11:33 Comment(6)
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!Xhosa
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!Nerves
Excellent, This answer should get more up votes, (the button inside the organizer window also did not work for me)Criseldacrisey
I was having a similar problem, in a multi-project workspace, where it was building successfully, but then complaining about "Reference to <X> 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.)Selfoperating
And old post, I know... But the problem remains... What does 'clean the project' mean? Product -> Clean Build Folder?Ramose
@Ramose i havent touched mac / ios in years but there used to be a project -> clean menu point (next to build)Andromeda
O
15

This's maybe you import like this:

#import "xxxx.h"

I fix it through this:

#import < xxxx/xxxx.h>

Osteal answered 21/2, 2017 at 8:18 Comment(0)
K
13

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

Kawasaki answered 21/2, 2016 at 14:20 Comment(2)
wow, never thought a duplicated import would throw an error like that..Gilcrest
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.Vicechairman
T
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

Toga answered 6/4, 2016 at 18:52 Comment(1)
this worked for me, and non of above proposed solution worked in my case :))Habitude
C
1

Remove use_frameworks! from pod file fix my ambiguous problem.

Catling answered 6/12, 2016 at 14:21 Comment(0)
S
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"
Sealy answered 1/2, 2017 at 20:6 Comment(0)
H
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.

Hipparch answered 28/7, 2017 at 10:10 Comment(0)
P
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!

Post answered 17/5, 2018 at 13:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.