簡體   English   中英

靜態庫在 Xcode 上出現奇怪的錯誤

[英]Static library gives strange errors on Xcode

我按照 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

如果我編譯正確,為什么會在庫中出現這些錯誤?

這是完全錯誤的:

#import "libInsightsLib.a"

#import用於導入頭文件,即源代碼聲明。 你告訴它導入一個編譯的二進制庫,然后編譯器就嚇壞了。

您需要將#import與 .h 一起用於您嘗試從該庫中使用的任何內容。 .a 進入應用程序構建目標的鏈接階段。 回到 Ray 的教程,我相信它會有這些細節。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM