构建纯 Swift Cocoa Touch 框架 [英] Building pure Swift Cocoa Touch Framework

查看:35
本文介绍了构建纯 Swift Cocoa Touch 框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Xcode-6 探索 Swift,到目前为止一切顺利,尽管我认为新的集合需要一些工作,因为我已经设法破坏了几次编译器.

I'm exploring Swift with Xcode-6 and so far so good although I think the new collections need a little bit of work as I've managed to break the compiler a few times.

问题是我现在一直在尝试创建框架包以然后在另一个项目中使用.项目构建没有问题,所有测试都成功通过.当我去创建存档(我认为这是必需的)时,我收到错误:

Problem is I'm now stuck trying to create the framework package to then use in another project. The project builds without issue and all tests pass successfully. When I go to create Archive (which I assume is what is required) I receive the error:

:0: 错误:未找到底层 Objective-C 模块示例"

:0: error: underlying Objective-C module 'Sample' not found

现在我假设这与我的 Sample.h 的内容有关,它告诉我

Now I assume this has something to do with the contents of my Sample.h which tells me

// In this header, you should import all the public headers of your framework using statements like #import <Sample/PublicHeader.h>

这很好,除了我只为这个框架使用了 swift 枚举、结构和类,因此不存在 .h 文件.

which is fine except I have only used swift enums, structs and classes for this framework so therefore no .h files exist.

因为我还找不到任何可用的文档,所以有人可以对此有所了解吗?

Can anyone shed some light on this one as I can't find any documentation available yet?

推荐答案

EDIT (7/27/2018)

以下答案中的信息可能不再准确.您的里程可能会有所不同.

The information in the answer below may no longer be accurate. Your mileage may vary.

我和一位工程师坐下来问了这个确切的问题.这是他们的回应:

I sat down with an engineer and asked this exact question. This was their response:

Xcode 6 目前不支持构建可分发的 Swift 框架,而且 Apple 可能不会将此功能构建到 Xcode 中,直到有利于他们这样做.现在,框架旨在嵌入到您的应用程序项目中,而不是分布式的.如果您观看任何会话视频或查看示例项目,这始终是安排.另一个原因是 Swift 非常新并且可能会发生变化.因此,您的基于 Swift 的框架不能保证在您最初构建它的平台上工作.

Xcode 6 does not support building distributable Swift frameworks at this time and that Apple likely won't build this functionality into Xcode until its advantageous for them to do so. Right now, Frameworks are meant to be embedded in your app's project, rather than distributed. If you watch any of the session videos or see the sample projects, this is always the arrangement. Another reason is that Swift is very new and likely to change. Thus your Swift-based framework is not guaranteed to work on the platform you originally built it on.

小幅更新

工程师提到做一个分发框架不是不可能,只是不支持.

The engineer mentioned that it's not impossible to make a framework for distribution, just that it's not supported.

这篇关于构建纯 Swift Cocoa Touch 框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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