xcode Cocoapods 使用_frameworks!进口问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34429793/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 08:20:40  来源:igfitidea点击:

Cocoapods use_frameworks! import issue

objective-cxcodecocoapodsfacebook-ios-sdk

提问by Ponf

I want to use some Swift pods in my Objective-C app, so I need to use frameworks instead of static libraries. But enabling use_frameworks!in my Podfile causes tones of #importerrors.

我想在我的 Objective-C 应用程序中使用一些 Swift pod,所以我需要使用框架而不是静态库。但是use_frameworks!在我的 Podfile 中启用会导致#import错误的音调。

My Podfile:

我的播客文件:

platform :ios, '8.0'
use_frameworks!

pod 'AFNetworking', '2.6.0'
pod 'Typhoon'
pod 'SSKeychain'
pod 'JBWebViewController'
pod 'TTTAttributedLabel'
pod 'HockeySDK'
pod 'GoogleAnalytics'
pod 'Intercom'
pod 'FBSDKCoreKit'
pod 'FBSDKLoginKit'
pod 'UIButton+Activity'
pod 'HexColors'
pod 'AFNetworkActivityLogger'
pod 'HCSStarRatingView', :git => 'https://github.com/hsousa/HCSStarRatingView.git'
pod 'LGSideMenuController'
pod 'DateTools'
pod 'SDWebImage'
pod 'SSCWhatsAppActivity'
pod 'UIViewController+BlockSegue'

The first problem was with SSKeychainpod:

第一个问题是SSKeychainpod:

SSKeychain Error

SS钥匙串错误

In code I'm including SSKeychain using "quotes" #import "SSKeychain/SSKeychain.h", but if I understand right, I need to use <angle>from now #import <SSKeychain/SSKeychain.h>? But in this case I receive same error, but in my code.

在代码中,我使用 "quotes" 包含 SSKeychain #import "SSKeychain/SSKeychain.h",但如果我理解正确,我需要<angle>从现在开始使用#import <SSKeychain/SSKeychain.h>? 但在这种情况下,我收到相同的错误,但在我的代码中。

My Build Phases:

我的构建阶段:

Build Phases

构建阶段

Anyway I have found fork of SSKeychain with "quotes" import (https://github.com/adamwulf/sskeychain/commit/2b7fd878415e8e4f23f74636cdd8c993466d0749) and switched to those version.

无论如何,我找到了带有“引号”导入的 SSKeychain 分支(https://github.com/adamwulf/sskeychain/commit/2b7fd878415e8e4f23f74636cdd8c993466d0749)并切换到这些版本。

But now I have same issue with many other pods (almost with all of them):

但是现在我对许多其他豆荚(几乎所有豆荚)都有同样的问题:

FBSDKCoreKit error

FBSDKCoreKit 错误

Import in app: #import "FBSDKCoreKit/FBSDKCoreKit.h"

在应用程序中导入: #import "FBSDKCoreKit/FBSDKCoreKit.h"

Do I really need to fork each repo and change import statements?? Or I'm including pods in wrong way?

我真的需要 fork 每个 repo 并更改 import 语句吗?或者我以错误的方式包含豆荚?

PS: I'm cleaning derived data and project before each build attempt.

PS:我在每次构建尝试之前清理派生数据和项目。

Cocoapods Version: 0.39.0

Cocoapods 版本:0.39.0

回答by Diego Freniche

As you've used Modulesin your Podfile, why don't you just:

当您在 Podfile 中使用模块时,为什么不:

@import SSKeychain;

instead of:

代替:

#import <SSKeychain/SSKeychain.h>

To test that:

要测试:

  • create a simple iOS project, just with one ViewController
  • create a Podfile using your code above
  • run pod install
  • open the Workspace
  • build & run: it compiles OK
  • 创建一个简单的 iOS 项目,只需一个 ViewController
  • 使用上面的代码创建一个 Podfile
  • 运行 pod 安装
  • 打开工作区
  • 构建并运行:它编译正常

回答by Ponf

I have finally figured out it! The problem was fixed by removing Pods.frameworkfrom Link Binary With Librariesand adding them again manually.

我终于想通了!该问题已通过Pods.frameworkLink Binary With Libraries 中删除并再次手动添加来解决。

Thanks for help!

感谢帮助!

回答by HotFudgeSunday

Also check error messages on pod install.

还要检查 上的错误消息pod install

In my case I was using a custom import in FRAMEWORK_SEARCH_PATHS, and just because I was doing that, whenever I did pod installthe extra search paths that CocoaPods adds were not being added. So I had to remove my custom path and then they showed up. Then I added my custom path.

就我而言,我在 中使用了自定义导入FRAMEWORK_SEARCH_PATHS,仅仅因为我这样做,每当我pod install执行 CocoaPods 添加的额外搜索路径时,都不会添加。所以我不得不删除我的自定义路径,然后它们出现了。然后我添加了我的自定义路径。

Might be a good idea to do pod deintegrate, delete de xcworkspace file and do pod installonce more. Then add your custom build settings.

pod deintegrate删除 xcworkspace 文件并pod install再次执行可能是个好主意。然后添加您的自定义构建设置。

This is the error I was getting:

这是我得到的错误:

[!] The App [Debug] target overrides the FRAMEWORK_SEARCH_PATHS
build setting defined in Pods/Target Support Files/Pods-AppLib/Pods-AppLib.debug.xcconfig. 
This can lead to problems with the CocoaPods installation

回答by jayesh lathiya

In my case, what was an issue I already downloaded few ObjC Pods for my Objective C Project then I need one swift pod so I enable use_framworkin my pod file and install that swift pod, After installing that swift pod import issue arrives for ObjeC Libraries in many classes, So

就我而言,我已经为我的 Objective C 项目下载了几个 ObjC Pod,然后我需要一个 swift Pod,所以我use_framwork在我的 Pod 文件中启用并安装该 Swift Pod,安装该 Swift Pod 导入问题后,ObjeC 库出现了问题许多课程,所以

What I did to fix this issue?

我做了什么来解决这个问题?

  1. Cut all Objective C pods from pod file
  2. Open terminal and run command: cd path/myProject
  3. Terminal run command: pod install
  4. Past it (all Objective C pods) again in pod file and save it
  5. Terminal run command: pod install
  1. 从 pod 文件中剪切所有 Objective C pod
  2. 打开终端并运行命令: cd path/myProject
  3. 终端运行命令: pod install
  4. 在 pod 文件中再次传递它(所有 Objective C pod)并保存它
  5. 终端运行命令: pod install