简体   繁体   中英

Inconsistent objective-c compiler errors in Xcode

I have developed an app in IOS that uses CoreData. I have just started to port this app to OS X. I am using two separate Xcode 7 projects each of which will reference shared code common to both implementations. This code is held in a folder outside the projects. My first step was to place the CoreData model and all the entity class code in the shared folder and add references to these in both projects.

The IOS project compiles OK, but when I compile the OS X project I get errors in one of the entity classes.

I then created a couple of new empty projects - one for iOS and one for os x and added the shared code to each. I got the same results. Basically the compiler thinks a symbol has been redefined, but only in the os x project.

Can anyone suggest why this is happening.

Here are the errors: /Users/Keith/Documents/My Projects/Writing Shed (Shared Code)/Data Models/Entities/Text.h /Users/Keith/Documents/My Projects/Writing Shed (Shared Code)/Data Models/Entities/Text.h:12:1: Redefinition of 'Collection' as different kind of symbol

/Users/Keith/Documents/My Projects/Writing Shed (Shared Code)/Data Models/Entities/Text+CoreDataProperties.h /Users/Keith/Documents/My Projects/Writing Shed (Shared Code)/Data Models/Entities/Text+CoreDataProperties.h:25:47: Reference to 'Collection' is ambiguous

/Users/Keith/Documents/My Projects/Writing Shed (Shared Code)/Data Models/Entities/Text+CoreDataProperties.h:33:31: Reference to 'Collection' is ambiguous

/Users/Keith/Documents/My Projects/Writing Shed (Shared Code)/Data Models/Entities/Text+CoreDataProperties.h:34:34: Reference to 'Collection' is ambiguous

/Users/Keith/Documents/My Projects/Writing Shed (Shared Code)/Data Models/Entities/Text+CoreDataProperties.h:35:31: Reference to 'Collection' is ambiguous

/Users/Keith/Documents/My Projects/Writing Shed (Shared Code)/Data Models/Entities/Text+CoreDataProperties.h:36:34: Reference to 'Collection' is ambiguous

I had an entity called Collection. For some reason the compiler thought this was a redefinition of the name, but only in the OS X project. Thinking that Collection was probably not the best choice of name I renamed it (both the name in the model and the class name). The problem has now gone away, though I have no idea why it only affected the OS X project. My IOS app has been in development for 18 months using the original name, so it's a mystery (I have raised the matter with Apple).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM