将Objective C框架连接到Swift iOS 8应用程序(Parse框架) [英] Connect Objective C framework to Swift iOS 8 app (Parse framework)

查看:92
本文介绍了将Objective C框架连接到Swift iOS 8应用程序(Parse框架)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用带有Swift编程语言的Objective C框架进行iOS 8开发。这是导入的特定情况,但一般问题是:

I am trying to use an Objective C framework with the Swift programming language for iOS 8 development. This is a specific case of an import but the general problem is:

如何将Objective C框架导入swift并获得导入识别?

我正在尝试使用iOS 8和Xcode 6测试版将Parse框架集成到一个快速的应用程序中。

I am trying to integrate the Parse framework into a swift application using the iOS 8 and Xcode 6 betas.

以下是Objective C中Parse框架集成的技术:

Here is the technique for Parse framework integration in Objective C:

https://www.parse.com/apps/quickstart#social/mobile/ios/native/existing

我已将Parse框架作为压缩存档下载,解压缩并将其导入Xcode 6而没有任何问题。在我的应用程序中,它显示为名为Parse.framework的格式正确的框架。

I have downloaded the Parse framework as a compressed archive, extracted it, and imported it into Xcode 6 without any problems. Within my application it appears as a properly formatted framework under the name Parse.framework.

我目前的思考过程是修改项目根目录中的 AppDelegate.swift 文件。这是当前没有修改的文件(在快速项目创建时由Xcode自动生成):

My current thought process is to modify the AppDelegate.swift file in the root directory of my project. Here is the current file without modifications (automatically generated by Xcode upon swift project creation):

https://gist.github.com/fconcklin/e8ef7d8b056105a04161

我试图通过添加行来导入解析导入Parse import UIKit 。但是,Xcode发出警告,发现没有找到这样的模块,并且构建失败。

I have tried to import parse by adding the line import Parse below the line import UIKit. However, Xcode issues a warning that there is no such module found and the build fails.

我还尝试创建文件 $ {PROJ_NAME_HERE} - Bridging-Header.h 包含使用 import< Parse / Parse.h> 的Parse的Objective C导入。这条线不会引发错误,但似乎最终没有任何区别。

I also tried creating a file ${PROJ_NAME_HERE}-Bridging-Header.h that contains the Objective C import of Parse using import <Parse/Parse.h>. This line doesn't throw an error but appears to ultimately make no difference.

提前致谢。
如果您需要更多信息,请告诉我。

Thanks in advance. Let me know if you need any more info.

推荐答案

添加桥接头的傻瓜证明方式如下:

A "Fool Proof" way of adding a bridging header is as follows:

如果您有一个 Swift 项目,请在项目中添加一个新的 Objective-C文件,如果您想通过桥接配置项目,Xcode会提示头。按是。

If you have a Swift project, add a new Objective-C File to your project and Xcode will prompt if you want to configure your project with a bridging header. Press yes.

如果您有 Objective-C 项目,请向其添加新的 Swift文件会得到相同的提示。按是。

If you have a Objective-C project, add a new Swift File to it and you will get the same prompt. Press yes.

获得桥接标题后,如果需要,可以删除刚刚添加的文件。

After you get the bridging header, you can delete the file you just added if you want to.

这篇关于将Objective C框架连接到Swift iOS 8应用程序(Parse框架)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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