如何安装仅包含swift文件的swift库 [英] How to install a swift library consisting just of swift files

查看:50
本文介绍了如何安装仅包含swift文件的swift库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个swift库,其中包含一个带子文件夹的大文件夹,这些子文件夹中的子文件夹都包含许多.swift文件,我希望自己的.swift项目能够知道这些-就像我自己编写了所有代码一样.

我的swift项目针对的是ios7 +,这意味着各种软件包系统存在一些问题-我正尝试通过添加的给定库建议使用上述方法.

目前,我已将swift-library-folder附加"到我自己的.swift文件旁边,在此期间,我检查了所有目标.

有趣的是,我无法更改/添加文件夹中任何文件的目标,因为单击xcode中的.swift文件时该选项不会显示自身()

无论如何,当尝试使用swift库中定义的类之一时,xcode无法识别它.

我在做什么错了?

解决方案

我的猜测是,将包含这些文件的文件夹拖到Xcode中,而不是单个文件中.那是第一个问题,因为这种事情具有特殊的意义.然后,您看到了这样的对话框:

我不确定您当时的行为,但是我认为您的设置看起来不像我的!他们需要.删除文件,然后再次执行此导入.

为获得最佳结果,请在Finder中仅选择 Swift文件,然后将它们拖到Xcode中. (您可以一次拖动所有文件;但是可以拖动文件,而不是文件夹.)但是,如果不能这样做,请确保要创建组- not 文件夹引用.

Suppose I have a swift library that consists of a large folder with subfolders with subfolders all containing many .swift files I would like my .swift project to be aware of - just as if I had written all that code myself.

My swift project targets ios7+ meaning there are some issues with various package systems - and the given library I am trying to add acually suggests using the above method.

Currenly I have "attached" the swift-library-folder next to my own .swift files and during this I checked all targets.

Interestingly, I can not change/add targets for any of the files in the folder since the option does not show itself when clicking the .swift files in xcode (!)

Anyhow, when trying to use one of the classes defined in he swift-library, xcode does not recognize it.

What am i doing wrong?

解决方案

My guess is that you dragg the folder containing these files into Xcode, rather than the individual files. That was the first issue, since that sort of thing has a special meaning. Then, you saw a dialog like this:

I'm not sure what you did at that moment, but I don't think your settings looked like mine! They need to. Delete the files and perform this import again.

For best results, select just the Swift files in the Finder and drag them into Xcode this time. (You can drag them all at once, in one move; but drag the files, not a folder.) But if you can't do that, make sure you are creating groups — not folder references.

这篇关于如何安装仅包含swift文件的swift库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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