简体   繁体   English

如何将 pod(第三方框架)添加到我的自定义可可触摸框架中?

[英]How can i add pod(third party framework) into my custom cocoa touch framework?

I'm creating a new Cocoa Touch Framework (MyFramework.framework), which will have a dependency on Alamofire.我正在创建一个新的 Cocoa Touch 框架 (MyFramework.framework),它将依赖于 Alamofire。 This framework will be written in Swift.这个框架将用 Swift 编写。 As a test I started a new Cocoa Touch Framework project:作为测试,我开始了一个新的 Cocoa Touch Framework 项目:

File > New > Project > Framework & Library > Cocoa Touch Framework

Then, in the terminal I performed:然后,在我执行的终端中:

pod init

under this projects directory.在这个项目目录下。 In the newly created Podfile I added the following:在新创建的 Podfile 中,我添加了以下内容:

// Uncomment this line to define a global platform for your project // 取消注释这一行,为您的项目定义一个全球平台

platform :ios, '9.0'

// Uncomment this line if you're using Swift // 如果您使用 Swift,请取消注释此行

use_frameworks!使用_框架!

pod 'Alamofire'

Once again, in the Terminal I performed:再一次,在终端中,我执行了:

pod install吊舱安装

and started coding away.并开始编码。

Everything seemed well and good till I used the MyFramework.framework Product in a Single View Project.在我在单视图项目中使用 MyFramework.framework 产品之前,一切看起来都很好。 When I attempt to run the project I get the following issue:当我尝试运行该项目时,出现以下问题:

dyld: Library not loaded: @rpath/testfm.framework/MyFramework
  Referenced from: /var/containers/Bundle/Application/D4456F6A-2EBB-4AF9-B974-37A66E42D374/test.app/test

Reason: image not found原因:找不到图片

please let me know if you need more information.如果您需要更多信息,请告诉我。

Try to Embed MyFramework.framework into Build phase -> Embed Framework.尝试将 MyFramework.framework 嵌入到构建阶段 -> 嵌入框架。 like @Vishnu suggested.就像@Vishnu 建议的那样。

Following Steps May be Help.以下步骤可能会有所帮助。

  • Delete the current .xcworkspace File删除当前的.xcworkspace文件
  • Open the .xcodeproj Just remove the pod from the project打开.xcodeproj只需从项目中删除 pod
  • Delete the current Pod file From the project and Clean the Project从项目中删除当前 Pod 文件并清理项目
  • Now go to file File -> New -> File -> Select the Empty File.现在转到文件File -> New -> File -> Select the Empty File. save File with Podfile name.使用Podfile名称保存文件。 (Must save the Project in main Directory). (必须将项目保存在主目录中)。
  • Open the Terminal and Drag and drop Podfile and install the pod again.打开Terminal并拖放Podfile并再次安装 Pod。
  • now close the .xcodeproj and open the .xcworkspace file.现在关闭.xcodeproj并打开.xcworkspace文件。

Hope this Works.希望这有效。

Hope you must have found the answer by now.希望你现在一定已经找到了答案。 For anyone else, make sure your custom framework setting is configured to "Embed & Sign" (As in image attached)对于其他任何人,请确保您的自定义框架设置配置为“嵌入和签名”(如附图所示)

Then run your app.然后运行您的应用程序。

在此处输入图片说明

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

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