XCode-相同的类名称,两个目标 [英] XCode - Same classe name, two targets

查看:251
本文介绍了XCode-相同的类名称,两个目标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图重新组合同一个XCode项目中的几个应用程序.因此,我创建了一个新的XCode项目并添加了两个目标,并将两个应用程序的源代码导入其中一个目标中.

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;

我尝试用Google搜索它,发现将标题搜索路径"设置为$(SRCROOT)/Target1(或$(SRCROOT)/Target2),应该可以解决我的问题,但这是行不通的.

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.

还有其他解决方案吗?

仅供参考,我正在使用XCode v.4.4.1

FYI, I'm using XCode v.4.4.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 =否

USE_HEADERMAP = NO

,然后在每个目标用户标题搜索路径"变量中将其设置为标题目录位置.

and set in each target "User Header Search Path" variable to the the headers directory location.

有关更多信息和更详细的说明, 请参考这个问题并在stackoverflow中回答

For more information and more detailed explanation, please refer to this question and answer in stackoverflow

控制Xcode将包含的项目头文件

这篇关于XCode-相同的类名称,两个目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆