菜鸟教程小白 发表于 2022-12-12 16:25:01

ios - 静态库在 Xcode 上给出奇怪的错误


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

<p> <a href="/image/tI3qO.png" rel="noreferrer noopener nofollow"><img src="/image/tI3qO.png" alt="error screenshot"/></a> </p>

<pre><code>/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 &#39;(&#39;
/Users/.../PruebaInsights/PruebaInsights/libInsightsLib.a:2:3: Invalid filename for line marker directive
/Users/.../PruebaInsights/PruebaInsights/libInsightsLib.a:3:10: Null character ignored
</code></pre>

<p>如果编译正确,为什么会在库中出现这些错误?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>这是完全错误的:</p>

<pre><code>#import &#34;libInsightsLib.a&#34;
</code></pre>

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

<p>您需要将 <code>#import</code> 与 .h 一起用于您尝试从该库中使用的任何内容。 .a 进入应用程序构建目标的链接阶段。回到 Ray 的教程,我相信它会有这些细节。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 静态库在 Xcode 上给出奇怪的错误,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/32763558/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/32763558/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 静态库在 Xcode 上给出奇怪的错误