在 Xcode 中为不同的目标使用相同的代码 [英] Using the same code for different target in Xcode

查看:34
本文介绍了在 Xcode 中为不同的目标使用相同的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 Xcode 中为不同的目标使用相同的代码.我可以使用 Duplicate 方法创建目标,然后我也可以更改方案名称.

I want to use the same code for different target in Xcode. I am able to create the target using the Duplicate method and then I am able to change scheme name as well.

现在真正的场景来了,我想以集中方式使用我的代码,比如新目标,我不想复制和粘贴 Main.storyboard 和 xib,所以,理想情况下会发生什么,如果我会在一个地方更改任何内容,所有目标都会共享.但问题来了,``ViewControllerinMain.Storyboard` 持有主项目模块",因此,当我运行子目标时,它无法运行.

Now the real scenario comes, I want to be use my code in centralised way like for new target, I don't want to copy and paste the Main.storyboard and xib as well, so, ideally what would happen, if I would change anything in one place, all target would share that.But the issue comes, that ``ViewControllerinMain.Storyboard` holds the master project "module" so, when I run the child target, it could not run.

推荐答案

您可以打开实用工具"面板,选择文件"检查器选项卡,然后为您要共享的每个文件标记必要的目标.请参阅附图作为参考.

You can open Utilities panel, select File inspector tab and mark necessary targets for every file you want to share. See attached image as a reference.

这篇关于在 Xcode 中为不同的目标使用相同的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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