xml - 使用 XML 解析 Swift 库时,Playgrounds 崩溃并显示 "unknown error"

标签 xml xcode frameworks swift-playground

我正在开发一个涉及一些 XML 解析的自定义框架,使用 Kanna框架。每当我尝试将我的框架导入 playground 时,playground 就会崩溃并出现以下错误:

Playground execution failed: expression failed to parse, unknown error
* thread #1: tid = 0x4e9448, 0x00000001074bf360 com.apple.dt.Xcode.PlaygroundStub-macosx`executePlayground, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
  * frame #0: 0x00000001074bf360 com.apple.dt.Xcode.PlaygroundStub-macosx`executePlayground
    frame #1: 0x00000001074bd22a com.apple.dt.Xcode.PlaygroundStub-macosx`-[PlaygroundViewBridgeService execute] + 90
    frame #2: 0x00007fffb4fc03ec CoreFoundation`__invoking___ + 140
    frame #3: 0x00007fffb4fc0271 CoreFoundation`-[NSInvocation invoke] + 289
    frame #4: 0x00007fffb4fd97a6 CoreFoundation`-[NSInvocation invokeWithTarget:] + 54
    frame #5: 0x00007fffc86ca95b ViewBridge`__68-[NSVB_ViewServiceImplicitAnimationDecodingProxy forwardInvocation:]_block_invoke + 47
    frame #6: 0x00007fffc86e9f4c ViewBridge`__runAnimationGroup_block_invoke + 21
...

我正在开发的框架运行良好(它按预期构建和运行单元测试),但无法在 Playground 上使用它是一种痛苦。

我已经在 GitHub 上提供了一个示例项目,其中包含有关复制问题的说明以及完整的堆栈跟踪:https://github.com/noahcgreen/XMLTest .如果从“XMLTest.swift”源文件中删除 import Kanna,错误就会消失。

到目前为止我已经尝试过:

  • 使用Fuzi框架而不是 Kanna,
  • 安装 CocoaPods 而不是 Carthage,
  • 在我的设备上更新 libxml2(使用 Homebrew),以及
  • 在不同的(和新的)设备上重新安装 XCode,

全部失败。我在这里束手无策。我做错了什么?

最佳答案

可能会对想要将 libxml2 库添加到 Xcode Playground 的人有所帮助。

请按照以下步骤操作:

  1. 创建一个空的工作区。
  2. 在工作区中添加一个 Playground 。
  3. 向工作区添加一个空框架,并将 "$(SDKROOT)/usr/include/libxml2" 添加到 'SWIFT_INCLUDE_PATHS' 中的 'Build设置的
  4. 在 playground 页面上添加 'import libxml2'

关于xml - 使用 XML 解析 Swift 库时,Playgrounds 崩溃并显示 "unknown error",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41679487/

相关文章:

xml - 如何在 XML 中转义 "&"?

ios - XCode 自动交付包含许多文件的构建交付

ios - 使用 Xcode 7.1 的 iOS 9 中的 NSURLSession/NSURLConnection HTTP 加载失败(kCFStreamErrorDomainSSL,-9813)

objective-c - 带有捆绑自定义框架的 Cocoa 屏幕保护程序插件

web-services - Web 框架在读取正文之前是否检查授权 header ?

python - 在 Python 中解析大型 XML 文件时出现内存错误

iphone - "Refreshing"iPhone/Mac OSX 上的 XML feed

java - 如何在android studio中的imageview上添加半透明覆盖并正确显示它

ios - UITextView - 在 XCode 5 上设置字体不适用于 iOS 6

javascript - 构建我的 JS 库,几个问题