简体   繁体   English

在iOS7 Swift项目中包含来自Swift Sources的Pod

[英]Include Pods from Swift Sources in iOS7 Swift Project

I have a iOS7 Swift project and want to use a pod like this which is based on Swift code. 我有一个iOS7 Swift项目,并希望使用基于Swift代码的这样的pod。

In my pod file I can include the pod like this: 在我的pod文件中,我可以像这样包含pod:

platform :ios, "7.0"
pod "Timepiece"

Assume that the project runs on iOS.How can I include pods from Swift sources? 假设项目在iOS上运行。如何从Swift源中包含pod?

Your only choice is to manually insert source code into your project, because: 您唯一的选择是手动将源代码插入到项目中,因为:

  1. It is not possible to build static libraries from Swift code. 无法从Swift代码构建静态库。
  2. Thus Pods written in Swift can only be integrated as dynamic frameworks 因此,用Swift编写的Pod只能作为动态框架集成
  3. You cannot have dynamic frameworks before iOS 8. 在iOS 8之前,您不能拥有动态框架。

I think you should do same as iOS pod , just #import all .h files in bridge.h file and Use Objective-C bridging header by selecting your Target - >Build Setting -> Swift compiler - code generation . 我认为你应该像iOS pod ,只需#importbridge.h文件中的所有.h文件,并通过选择你的Target - >Build Setting -> Swift compiler - code generation来使用Objective-C bridging header

Just drag you bridge.h file from your project to Swift compiler - code generation section. 只需将bridge.h文件从项目拖到Swift compiler - code generation部分。

Check out THIS standard tutorial for more details. 查看标准教程以获取更多详细信息。 May this help you !! 愿这对你有所帮助!!

I am not sure this is what you are trying to. 我不确定这是你想要的。 Cocoapod is a dependency manager. Cocoapod是一名依赖经理。 When you create a pod file in the same folder of your .xcodeproj, and run "pod install" at the the folder through the terminal, an .xcworkspace will be crated. 当您在.xcodeproj的同一文件夹中创建一个pod文件,并通过终端在该文件夹中运行“pod install”时,将会创建一个.xcworkspace。 Then you can use the pod project with your project by opening the .xcworkspace file instead of .xcodeproj 然后,您可以通过打开.xcworkspace文件而不是.xcodeproj来将pod项目与项目一起使用

reference: https://guides.cocoapods.org/using/using-cocoapods.html 参考: https//guides.cocoapods.org/using/using-cocoapods.html

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM