iOS 打包靜態庫.a檔案(真機版 + 虛擬機器)

來源:互聯網
上載者:User

標籤:

我們以打包IOS開發中封裝的高地地圖基礎功能包 GDMap為例。

 1>我們需要準備好需要打包的GDMap

  

2>接下來我們開始建立一個工程檔案取名GDMap

 


 
 

3>刪掉無用自動產生的.h 和.m 檔案,把準備好的GDMap拖入工程中,注意檔案放在一級目錄下。

 

4>接下來我們選擇出來需要暴露出來的標頭檔.h

 

我選擇暴露出所有的標頭檔如

 

5>接下來我們配置下工程檔案,修改

 

Product->Scheme-> Edit Scheme下 為 Release 

 

 

6>配置完之後我們就可以選擇真機進行運行在運行後,再虛擬機器運行一次,我們找到產生的.a檔案右鍵選擇show in finder就可以了。

 

7>合并兩個.a 檔案,使其能夠同時在模擬器及真機上使用

lipo -create 要合的兩個檔案1路徑 要合的兩個檔案2路徑 -output .../Desktop/GDMap.a(產生路徑)

注意:

選擇 編譯的裝置,iOS Device 編譯出來的是真機的,選擇  模擬器 編譯出來的是模擬器版本

如果使用別人的,不知道他是通過什麼方式編譯來的。可以通過 終端命令列來查看


lipo -info  要查看的檔案的路徑(直接拖過來)

armv7 arm64 真機

i386 模擬器


使用的時候:

添加靜態庫.a檔案到工程中去,同時添加.h檔案

通過查看.h檔案來使用這個靜態庫

 

出現如下靜態庫錯誤:使用的靜態庫的架構不對

Undefined symbols for architecture i386:

  "_OBJC_CLASS_$_StaticLibrary", referenced from:

      objc-class-ref in ViewController.o

ld: symbol(s) not found for architecture i386

clang: error: linker command failed with exit code 1 (use -v to see invocation)

錯誤:

xcrun: error: active developer path ("/Users/XJW/Desktop/Xcode.app/Contents/Developer") does not exist, use `xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools (or see `man xcode-select`)  

解決方案:

sudo xcode-select --switch /Applications/Xcode.app

 

iOS 打包靜態庫.a檔案(真機版 + 虛擬機器)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.