美文网首页
Swift和oc CocoPods Podfile文件区别

Swift和oc CocoPods Podfile文件区别

作者: heremakono | 来源:发表于2017-05-15 11:22 被阅读0次

oc的Cocopods Podfile 文件.


platform :ios, "8.0"

target :MammothService do

end

swift 的Cocopods Podfile 文件.

platform :ios, "8.0"

use_frameworks!

target :MammothService do

end


两者相差一句user_frameworks!

swift 不添加会导致一下错误

[!] 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

需要注意的是user_frameworks! 中的感叹号必须是英文状态下的.


以下是官方解释为什么要使用user_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.

相关文章

  • Swift和oc CocoPods Podfile文件区别

    oc的Cocopods Podfile 文件. swift 的Cocopods Podfile 文件. 两者相差一...

  • iOS开发:CocoaPods的使用-swift和oc

    最近手里有swift项目和oc项目,发现CocoaPods的Podfile文件在oc和swift中的编写还不很一样...

  • swift填坑记录

    使用Cocoapods时,Swift无法同时在podfile文件中使用OC和Swift的SDK 【引用】https...

  • OC与swift的区别

    OC与Swift的区别一(文件结构) OC与Swift的区别一(常量、变量、运算符) OC与Swift的区别三(条...

  • swift5版本学习

    swift与OC区别:swift与OC1、Swift容易阅读,语法和文件结构简易化。2、Swift更易于维护,文件...

  • OC转Swift

    记录下OC转Swift的一些经历 文件区别 OC:.h声明 .m实现 Swift:.swift 声明+实现 参数...

  • Cocoapods之Podfile

    OC创建Podfile的时候,官网推荐用这种格式使用, Swift创建Podfile

  • OC和Swift混编

    OC和Swift的混编,分为两种情况: OC项目中嵌入Swift文件 Swift项目中嵌入OC文件 先来看OC项目...

  • Swift与OC区别

    一,区别 1,最明显的区别:OC一个类由.h和.m两个文件组成,而swift只有.swift一个文件,所以整体的文...

  • swift 与 OC 的区别 2021-02-24

    一,区别 1,最明显的区别:OC一个类由.h和.m两个文件组成,而swift只有.swift一个文件,所以整体的文...

网友评论

      本文标题:Swift和oc CocoPods Podfile文件区别

      本文链接:https://www.haomeiwen.com/subject/thxhxxtx.html