【问题标题】:Static library gives strange errors on Xcode静态库在 Xcode 上给出奇怪的错误
【发布时间】:2015-12-22 04:29:14
【问题描述】:

我按照 Ray Wenderlich 的说明制作了一个静态库 (.a),编译它没有错误和警告,然后我将它包含在一个新项目中。当我尝试构建新项目时,我收到了这个错误:

/Users/.../PruebaInsights/PruebaInsights/libInsightsLib.a:1:1: Source file is not valid UTF-8
/Users/.../PruebaInsights/PruebaInsights/libInsightsLib.a:1:5: Null character ignored
/Users/.../PruebaInsights/PruebaInsights/libInsightsLib.a:1:8: Expected identifier or '('
/Users/.../PruebaInsights/PruebaInsights/libInsightsLib.a:2:3: Invalid filename for line marker directive
/Users/.../PruebaInsights/PruebaInsights/libInsightsLib.a:3:10: Null character ignored

如果编译正确,为什么会在库中出现这些错误?

【问题讨论】:

    标签: ios xcode static-libraries .a


    【解决方案1】:

    这是完全错误的:

    #import "libInsightsLib.a"
    

    #import 用于导入头文件,即源代码声明。你告诉它导入一个已编译的二进制库,然后编译器就吓坏了。

    您需要使用带有 .h 的 #import 来处理您尝试从该库中使用的任何内容。 .a 进入应用构建目标的链接阶段。回到 Ray 的教程,我相信它会有这些细节。

    【讨论】:

    • 你能建议如何导入吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-18
    • 2017-11-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多