Swift 包管理器 ("Swift Build")在 xcode 中编译正常

标签 swift xcode swift3 swift-package-manager

当尝试通过包管理器安装模板时,它提示我的项目中导入模块 libxml2 中的一些现有源文件。

尽管该库已正确链接并且在 xcode 中编译良好。

有人可以解释一下我做错了什么吗?

下面是我的控制台输出

MacBook-Pro:XCUI-ReportGen zaid$ swift build -Xcc -fblocks -Xswiftc -I/usr/local/include -Xlinker -L/usr/local/lib
Fetching https://github.com/kylef/Stencil.git
Fetching https://github.com/kylef/PathKit.git
Fetching https://github.com/kylef/Spectre.git
Cloning https://github.com/kylef/Spectre.git
Resolving https://github.com/kylef/Spectre.git at 0.7.2
Cloning https://github.com/kylef/Stencil.git
Resolving https://github.com/kylef/Stencil.git at 0.8.0
Cloning https://github.com/kylef/PathKit.git
Resolving https://github.com/kylef/PathKit.git at 0.8.0
Compile Swift Module 'Spectre' (8 sources)
Compile Swift Module 'PathKit' (1 sources)
Compile Swift Module 'Stencil' (19 sources)
/Users/zaid/XCUI-ReportGen/.build/checkouts/Stencil.git-7635584243355970173/Sources/Context.swift:46:25: warning: expression implicitly coerced from 'Any?' to Any
    return dictionaries.popLast()
                        ^~~~~~~
/Users/zaid/XCUI-ReportGen/.build/checkouts/Stencil.git-7635584243355970173/Sources/Context.swift:46:25: note: provide a default value to avoid this warning
    return dictionaries.popLast()
                        ^~~~~~~
                                ?? <#default value#>
/Users/zaid/XCUI-ReportGen/.build/checkouts/Stencil.git-7635584243355970173/Sources/Context.swift:46:25: note: force-unwrap the value to avoid this warning
    return dictionaries.popLast()
                        ^~~~~~~
                               !
/Users/zaid/XCUI-ReportGen/.build/checkouts/Stencil.git-7635584243355970173/Sources/Context.swift:46:25: note: explicitly cast to Any with 'as Any' to silence this warning
    return dictionaries.popLast()
                        ^~~~~~~
                                as Any
/Users/zaid/XCUI-ReportGen/.build/checkouts/Stencil.git-7635584243355970173/Sources/Loader.swift:55:14: warning: no calls to throwing functions occur within 'try' expression
      return try environment.templateClass.init(templateString: content, environment: environment, name: name)
             ^
/Users/zaid/XCUI-ReportGen/.build/checkouts/Stencil.git-7635584243355970173/Sources/Loader.swift:68:18: warning: no calls to throwing functions occur within 'try' expression
          return try environment.templateClass.init(templateString: content, environment: environment, name: templateName)
                 ^
Compile Swift Module 'XCUIReportGenerator' (13 sources)
/Users/zaid/XCUI-ReportGen/XCUIReportGenerator/ExternalLibs/Fuzi/Document.swift:23:8: error: no such module 'libxml2'
import libxml2
       ^
/Users/zaid/XCUI-ReportGen/XCUIReportGenerator/ExternalLibs/Fuzi/Document.swift:23:8: error: no such module 'libxml2'
import libxml2
       ^
/Users/zaid/XCUI-ReportGen/XCUIReportGenerator/ExternalLibs/Fuzi/Document.swift:23:8: error: no such module 'libxml2'
import libxml2
       ^
/Users/zaid/XCUI-ReportGen/XCUIReportGenerator/ExternalLibs/Fuzi/Document.swift:23:8: error: no such module 'libxml2'
import libxml2
       ^
/Users/zaid/XCUI-ReportGen/XCUIReportGenerator/ExternalLibs/Fuzi/Document.swift:23:8: error: no such module 'libxml2'
import libxml2
       ^
/Users/zaid/XCUI-ReportGen/XCUIReportGenerator/ExternalLibs/Fuzi/Document.swift:23:8: error: no such module 'libxml2'
import libxml2
       ^
/Users/zaid/XCUI-ReportGen/XCUIReportGenerator/ExternalLibs/Fuzi/Document.swift:23:8: error: no such module 'libxml2'
import libxml2
       ^
/Users/zaid/XCUI-ReportGen/XCUIReportGenerator/ExternalLibs/Fuzi/Document.swift:23:8: error: no such module 'libxml2'
import libxml2
       ^
<unknown>:0: error: build had 1 command failures
error: exit(1): /Applications/Xcode8.3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-build-tool -f /Users/zaid/XCUI-ReportGen/.build/debug.yaml

Link to the output from my debug.yaml run

最佳答案

您似乎正在尝试使用 libxml。这是一个 C 库,如果没有所需的包装器库,它将无法在 Swift 中构建。另请参阅this question .

关于Swift 包管理器 ("Swift Build")在 xcode 中编译正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43197434/

相关文章:

ios - 更新到 swift 4 后 UNUserNotification 不起作用

swift - 在那里工作怎么样?

swift - Pickerview 选择行和 didSelectRowAt 函数

ios - 在 iOS 上的 applicationDidBecomeActive() 后 Unity3D 应用程序崩溃

ios - 自定义表格单元格重用/出队

iOS 8 共享扩展附件 - Xcode - Swift

IOS Swift 如何从不同的 Controller 重新加载 tableView

swift - NSuserdefaults 高分保存

iOS拖动UIView,布效果

ios - swift - 'PFObject is not convertible to NSString'