Xcode4.6建立和使用iOS的dylib動態庫(轉載)

來源:互聯網
上載者:User

標籤:c   class   blog   code   a   http   

此為xcode4的方法,xcode3的方法請查看 Xcode3建立和使用iOS的dylib動態庫

 

找到兩個目錄,最好用兩個finder視窗分別開啟:

目錄一:

 

[plain] view plaincopy 
  1. /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Specifications/  

 

目錄二:

 

[plain] view plaincopy 
  1. /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/Specifications/  

 

(這裡只說iOS真機版,模擬器版類似,/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform)

把目錄一下的iPhoneOSPackageTypes.xcspec和iPhoneOSProductTypes.xcspec拷貝到案頭(或者其它有寫入權限的地方),分別用xcode開啟。

再用xcode開啟目錄二下的MacOSX Package Types.xcspec和MacOSX Product Types.xcspec

把MacOSX Package Types.xcspec中Identifier為com.apple.package-type.mach-o-dylib的item拖到iPhoneOSPackageTypes.xcspec,令iPhoneOSPackageTypes.xcspec變成:

把MacOSX Product Types.xcspec中Identifier為com.apple.product-type.library.dynamic的item拖到iPhoneOSProductTypes.xcspec,令iPhoneOSProductTypes.xcspec變成:

儲存修改,把iPhoneOSPackageTypes.xcspec和iPhoneOSProductTypes.xcspec拷貝回去目錄一,此時會因為沒有寫入權限而提示需要評鑑,輸入密碼即可。

 

建立工程模板:

 

[plain] view plaincopy 
  1. /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/Framework & Library/Cocoa Touch Static Library.xctemplate  

 

把以上整個檔案夾複製到案頭,檔案夾改名為Cocoa Touch Dynamic Library.xctemplate,用xcode開啟裡面的TemplateInfo.plist,修改三個地方:

儲存,然後把Cocoa Touch Dynamic Library.xctemplate拷貝回去

 

[plain] view plaincopy 
  1. /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/Framework & Library/  

 

這時又需要評鑑。

重啟xcode,就能看到:

 

隨便建立一個app工程和一個dylib工程,做好編譯依賴以及copy dylib to bundle。(點擊查看大圖)

動態庫的工程要設定安裝目錄:(點擊查看大圖)

 

demo/sample和已經改好的模板 :http://download.csdn.net/detail/hursing/5416617

安裝好app後,運行。然後修改UIAlertView的message,編譯,用各種工具(我在Mac上用的是iPhone Explorer)把新的dylib覆蓋舊的,重啟程式,message成功改變! 驗證ok。

以上是直接連結靜態庫的方法,也可以用dyld函數動態載入。要把dylib放在Document檔案夾內的話,修改安裝目錄即可,第一次啟動要自己copy出去哦。

 

 

轉自: http://blog.csdn.net/hursing/article/details/8951958

相關文章

聯繫我們

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