问题
I'm trying to regroup several applications I have in the same XCode project. So I created a new XCode project and added two targets, and import the source code of my two apps in one of the targets.
The problem is that I have classes with the same name in the two applications. When I compile the first one, no problem. But if I try to compile the second target, I have lots of issues like this :
In file included from /Users/administrateur/Documents/Merged_iPhone_Projects/Target2/Classes/VisitFormViewController.m:18:
In file included from /Users/administrateur/Documents/Merged_iPhone_Projects/Target1/Classes/VisitFormDetailsViewController.h:11:
/Users/administrateur/Documents/Merged_iPhone_Projects/Target1/Classes/RoundedCornersTableViewCell.h:18:61: error: property has a previous declaration
@property (nonatomic, readonly) BkCustomCellBackgroundView *roundedCornersView;
^
Target2/Classes/RoundedCornersTableViewCell.h:18:61: note: property declared here
@property (nonatomic, readonly) BkCustomCellBackgroundView *roundedCornersView;
I try to google it and found that setting the "Header Search Paths" to $(SRCROOT)/Target1 (or $(SRCROOT)/Target2), should solve my problem, but this is not working.
Anybody has an other solution?
FYI, I'm using XCode v.4.4.1
Thanks
回答1:
You should arrange the resources for each target by directory and define the target membership in the file inspector.
Also, for each target you can use a "user build setting" that is undocumented:
USE_HEADERMAP = NO
and set in each target "User Header Search Path" variable to the the headers directory location.
For more information and more detailed explanation, please refer to this question and answer in stackoverflow
controlling which project header file Xcode will include
回答2:
The classes will need different names -- otherwise, there will be a collision at load, and the implementation which you will receive is not specified.
来源:https://stackoverflow.com/questions/12347646/xcode-same-classe-name-two-targets