iOS - Bundle 資源檔包

來源:互聯網
上載者:User

標籤:style   mac   真機   find   dir   技術分享   修改   es2017   setting   

1、Bundle 檔案

Bundle 檔案,就是資源檔包。我們將許多圖片、XIB、文字檔組織在一起,打包成一個 Bundle 檔案。方便在其他項目中引用包內的資源。

Bundle 檔案是靜態,也就是說,我們包含到包中的資源檔作為一個資源套件是不參加項目編譯的。也就意味著,bundle 包中不能包含可執行檔檔案。它僅僅是作為資源,被解析成為特定的位元據。

2、製作 Bundle 檔案

1、建立 Bundle 項目

  • 建立名為 yooweiSourcesBundle(最後要產生的 Bundle 檔案名稱)的工程,注意 Bundle 預設是 macOS 系統的,Xcode 高版本中需要在 macOS => Framework & Library 選項下找到。

  • 開啟Xcode, 選擇File ----> New ---> Project。 

    選擇macOS ----> Framework & Library ---> Bundle。

 

2、修改 Bundle 配置資訊

  • 因為 Bundle 預設是 macOS 系統的,所以需要修改他的資訊,修改成 iOS 系統。

設定 Build Setting 中的 COMBINE_HIDPI_IMAGES 為 NO,否則 Bundle 中的圖片就是 tiff 格式了。

3、可選配置

  • 作為資源套件,僅僅需要編譯就好,無需安裝相關的配置,設定 Skip Install 為 YES。同樣要刪除安裝路徑 Installation Directory 的值。

該資源套件的 pch 檔案和 strings 檔案是可以刪除的。

4、添加檔案

  • 將資源檔或檔案夾拖動到工程中的 SourcesBundle 檔案夾下面。

 

5、編譯產生 Bundle 檔案

  • 我們分別選擇 Generic iOS Device 和任意一個模擬器各編譯一次,編譯完後,我們會看到工程中 Products 檔案夾下的 SourcesBundle.bundle 由紅色變成了黑色。

然後 show in finder,看看產生的檔案。我們看到它為真機和模擬器都產生了 .bundle 資源檔。

選中 .bundle 檔案右鍵 顯示包內容,我們可以看到之前拖拽到工程中的資源檔都在其中。

bundle的使用明日繼續。。。

iOS - Bundle 資源檔包

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.