如何在Xcode 9中使用带有游乐场的自定义框架 [英] How to use a custom framework with a playground in Xcode 9

查看:112
本文介绍了如何在Xcode 9中使用带有游乐场的自定义框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在游乐场中使用自定义框架,如Apple文档中所述:





这实际上是在项目下面编译的,所以在此框架准备好导入游乐场之后。


I am trying to use a custom framework in a playground as described in this Apple documentation:

http://help.apple.com/xcode/mac/9.0/#/devc9b33111c

However, I am unable to get the playground to recognize the framework (https://github.com/gk-brown/MarkupKit). It is a 64-bit Objective-C framework that defines a module.

Here is what I have tried:

  • Create a new "single view" playground
  • As directed in the document, open the playground and choose File > Save As Workspace
  • Close the playground
  • Open the workspace containing the playground
  • Attempt to choose File > Add Files to [Workspace Name]

The menu item is actually named "Add Files..." and is disabled. I'm able to work around this by opening the Navigator panel and selecting Project Navigator. The menu item changes to "Add Files to TestPlayground" and becomes enabled.

Moving on, as directed in the document:

  • Navigate to the directory containing the framework, select the framework, and click "Add"
  • In the editor, open the desired playground source file
  • Add an import statement for the framework (e.g. "import MarkupKit")

The console displays the following error:

error: TestPlayground.playground:5:8: error: no such module 'MarkupKit'

The document additionally notes that the workspace must contain at least one active scheme that builds a target. However, adding a project to the workspace and building it does not resolve the problem. The playground is still unable to see the framework.

Based on what I've read elsewhere on SO, it seems like this should be possible. However, most of the information I have found is 2-3 years old and may be out of date. The framework is a universal binary, and I have tried trimming it using lipo as suggested in some other posts. Specifically, I did this:

https://github.com/gk-brown/MarkupKit/wiki/Deployment

Unfortunately, it didn't help.

Any suggestions would be very much appreciated.

解决方案

You steps looks okay but Only missing part I see here is adding a .swift Empty file in the project.

This actually compiles below project so after this framework will be ready to import into the playground.

这篇关于如何在Xcode 9中使用带有游乐场的自定义框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆