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

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

问题描述

我正在尝试使用带有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:

如何将Swift的Objective-C框架导入并获得认可?

我正在尝试使用iOS 8和Xcode 6 Beta将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

我试图通过在行import UIKit下添加行import Parse来导入解析.但是,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>的Objective-C导入的Parse.该行不会引发错误,但最终似乎没有任何区别.

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.

推荐答案

添加桥接标头的简单证明"方法如下:

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应用程序(解析框架)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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