Swift桥接头文件不适用于use_frameworks [英] Swift bridging header file won't work with use_frameworks

查看:203
本文介绍了Swift桥接头文件不适用于use_frameworks的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用GoogleidentityToolkit库来处理登录问题.我启用use_frameworks!在我的pod文件中,但是找不到模块GITkit.我试图弄清楚发生了什么.据我所知,如果您使用"use_frameworks",则无需创建任何桥接头文件,因为cocoapods将库向下编译为一个模块,因此以后您可以照常将其导入到* .swift文件中.

在Swift中使用Google Identity Toolkit库需要什么?


在发布CocoaPods 1.0.0(当时CocoaPods 0.39.0仍然很流行)和可用版本的解决方案

A)创建名为的桥接头文件 项目的根文件夹中的"ProjectName-Bridging-Header.h" .

B)转到项目构建设置并设置以下值:

  • 安装Objective-c兼容性标头" :
  • "Objective-C桥接标头" :桥接标头的路径(例如,"ProjectName/ProjectName-Bridging-Header.h"

之后,您可以使用头文件导入要在快速代码中使用的所有ObjectiveC文件.

注意:如果需要,请在资源标头和Swift编译器搜索部分中将路径设置为递归.

I'm trying to use GoogleidentityToolkit library to handle login an things. I enable use_frameworks! on my pod file, but the module GITkit can't be found. I'm trying to figure out what's going. As far as I know if you use "use_frameworks" you don't need to create any bridging header file, since cocoapods compiles down the library into a single module, so later you can imported as usual on your*.swift files.

What do I need to get using Google Identity Toolkit library in Swift?


This question was asked one week after the release of CocoaPods 1.0.0 (at a time where CocoaPods 0.39.0 was still popular), and available version of Google Identity Toolkit was 1.1.3 from 2015, but got deprecated in favor of Firebase Authentication (pod 'FirebaseUI/Auth') following Google I/O 2016.

解决方案

A) Create a Bridging Header file named "ProjectName-Bridging-Header.h" in the root folder of your project.

B) Go to the project build settings and set the following values:

  • "Install objective-c compatibility header" : YES
  • "Objective-C Bridging Header" : path of your bridging header (e.g. "ProjectName/ProjectName-Bridging-Header.h"

After that you can use the header file to import all your ObjectiveC files which you want use within swift code.

NOTE: if required set the path as a recursive both in the resource headers and the Swift compiler search section.

这篇关于Swift桥接头文件不适用于use_frameworks的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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