简体   繁体   English

将Objective-C库和Swift库与Cocoapods一起使用时出现构建错误

[英]Build error when using both objective-c and swift libraries with Cocoapods

I have an Objective C project which has a podfile like this: 我有一个Objective C项目,该项目具有如下所示的podfile:

source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '8.0'
use_frameworks!
target 'Linbik' do
    pod 'AFNetworking', '~> 2.6.0'
    pod 'DateTools', '~> 1.6.1'
    pod 'Sentry', :git => 'https://github.com/getsentry/sentry-swift.git', :tag => '2.1.3'
end

DateTools is an Objective C library, and Sentry is a Swift one. DateTools是一个Objective C库,而Sentry是一个Swift库。 If I remove Sentry pod and use_frameworks! 如果我删除Sentry pod和use_frameworks! line, and then run pod install , pods are correctly installed and project builds just fine. 行,然后运行pod install ,正确安装了pod install ,项目构建就很好了。

But if I run pod install with the podfile above, pods are correctly installed but I can't build the project. 但是,如果我使用上面的podfile运行pod install ,就可以正确安装pod install ,但是无法构建项目。 It gives me an error like this: 它给我这样的错误:

'NSDate+DateTools.h' file not found with <angled> include; use "quotes" instead

The import is done like this: 导入是这样完成的:

#import <NSDate+DateTools.h>

This is just part of the code that gives me an error. 这只是给我一个错误的代码的一部分。 There are also some imports like this: 也有一些这样的进口:

#import <AFNetworking/UIImageView+AFNetworking.h>

That gives the same error. 那给出了同样的错误。

Xcode suggests me to use double quotes on import, but that doesn't help. Xcode建议我在导入时使用双引号,但这无济于事。 What can I do? 我能做什么?

Change pod 'AFNetworking', '~> 2.6.0' And use this 更改pod'AFNetworking','〜> 2.6.0'并使用它

pod 'AFNetworking', '~> 3.0
pod 'DateTools', '~> 1.6.1'
pod 'Sentry', :git => 'https://github.com/getsentry/sentry-swift.git', :tag => '2.1.3'

我通过删除派生数据找到了解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Swift库和Objective-C库通过Cocoapods一起使用 - Swift libraries and Objective-C libraries together via Cocoapods 在Swift项目中使用CocoaPods作为模块添加Objective-C框架项目时,找不到iOS模块错误 - IOS Module not found error when adding Objective-C framework projects using CocoaPods as a module in Swift project iOS - 在Swift Code中使用Cocoapods objective-C - iOS - Using Cocoapods objective-C within Swift Code 在 objective-c 模块中使用 swift 时无法构建 Objective-C 模块 - Could not build Objective-C module, when using swift in objective-c module 在Swift项目(Empatica)中使用Objective-C框架文件时出现奇怪的生成错误 - Strange build error when using Objective-C framework file in Swift project (Empatica) Objective-C 项目中的 Swift CocoaPods 库 - Swift CocoaPods Library in Objective-C Project 使用 Objective-C 中的 Swift ObservableObject 时出现链接器错误 - Linker error when using Swift ObservableObject from Objective-C 带有 Objective-C 文件的 Swift Cocoapods 给出了未定义的符号 - Swift Cocoapods with Objective-C files gives Undefined symbols 如何在快速项目中使用Objective-C类合作伙伴 - how to use objective-c category cocoapods in swift project 将cocoapods积分/安装到现有的xcode项目,objective-c或swift - Integarte/Install cocoapods to existing xcode project, objective-c or swift
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM