扫一扫下方二维码,关注本站官方公众号
获取永久解锁本站全部文章的验证码
还能不定期领现金红包

芒果iOS开发之CocoaPods:Pods written in Swift can only be integrated as frameworks; add `use_frameworks!`-Go语言中文社区

芒果iOS开发之CocoaPods:Pods written in Swift can only be integrated as frameworks; add `use_frameworks!`


【主要内容:】


1. 错误起因

2. 错误提示

3. 解决问题办法


一、错误起因:

今天新创建了一个Xcode工程,准备安装CocoaPods,下边是我添加的库:


二、错误提示

然后pod install过程中出现如下问题:

[!] Pods written in Swift can only be integrated as frameworks; add `use_frameworks!` to your Podfile or target to opt into using it. The Swift Pods being used are: ReactiveCocoa and Result

如图:



三、 解决问题办法


根据错误提示说:Pod写入Swift的只能是一个完整的框架;在Podfile文件或目标来选择使用“use_frameworks!”。

那么按照错误提示打开打开Podfile,打开Podfile命令是:vim Podfile。然后按字母“i(nsert)”插入use_frameworks!

注意:

use_frameworks!中的“!"必须是英文状态的感叹号。


这有一写官方的解释,大家请自行翻译:

Because Apple doesn't let you build static libraries that contain Swift. Unlike Objective-C, Apple doesn't ship the Swift standard runtime libraries with iOS. This decouples the language version from the platform version. When you build an app with Swift, you're responsible yourself to ship them. By default, Xcode uses swift-stdlib-tool to handle copying the Swift runtime dylibs, but the tooling falls short when attempting to ship frameworks that use Swift with an app that is Objective-C only. Your app executable and the frameworks you ship will all use the same set of dylibs, which are embedded into the Frameworks subdirectory of the application bundle.


First, that's because you can't link against different versions of the standard libraries. Furthermore it is desirable to embed them only once and not multiple times, because of constraints to memory size and network speed, which are relevant for distribution. You can make CocoaPods integrate to your project via frameworks instead of static libraries by specifying use_frameworks!. If that's not present, you won't be able to integrate dependencies, if you depend on a pod which includes Swift source code.



然后就可以安装成功了:



  欢迎大家关注“芒果iOS”微信公众账号,芒果会经常为大家分享好的技术文章:


版权声明1:本文来源CSDN,感谢博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/CrazyZhang1990/article/details/52767825
站方申明:本站部分内容来自社区用户分享,若涉及侵权,请联系站方删除。
  • 发表于 2021-06-26 21:25
  • 阅读 ( 491 )

0 条评论

请先 登录 后评论

官方社群