iOS.StaticLibrary.1-avoid-duplicate-symbol-in-static-library[draft]

來源:互聯網
上載者:User

標籤:

Avoid duplicate symbol in static library and its customer

發布static library給使用者使用。在實際的工程實踐中,iOS靜態庫一般會在對外/對內提供SDK時出現。

靜態庫(SDK)本身可能依賴一些第三方的庫,當使用該SDK的App也依賴了同樣的第三方庫,那麼問題就來啦。

 

Figure: SDK 和 SDK Customer 依賴相同的3rd library

 

 

 

1. static library如何避免和使用者的代碼有重複符號 

Ref[1] Ref[4]

 

 

2. 從iOS的靜態庫中抽取出object file

Ref[5]

1 $ lipo libXXXSDK.a -thin armv7 -output libXXXSDK-armv7.a2 $ ar -x libXXXSDK-armv7.a

 

3. 發布靜態庫3.1 發布支援模擬器和真機的靜態庫

Ref[6] Ref[7]

 

3.2 debug編譯和release編譯的靜態庫區別

A: NSLog

debug: NSLog會輸出 

release: NSLog不會輸出

 

3.3 如何strip靜態庫的符號表

A) 隱藏靜態庫的符號

Ref[17]

" Hiding internal names requires a few simple Xcode build settings, and it is not generally

necessary to modify source or change the type of the built product.

1. Eliminate any internal symbols required between modules by performing a single-object prelink.

Set the Xcode build setting named "Perform Single-Object Prelink" to Yes (GENERATE_MASTER_OBJECT_FILE=YES).

This causes ld to be run with the "-r" flag.

2. Make sure that the setting "Strip Style" is set to "Non-global symbols" (STRIP_STYLE=non-global), this passes "-x" to ld.

Stripping is only actually performed on static libraries if post-processing is enabled (and this is not the default).

3. Set Xcode build setting "Deployment Postprocessing" to yes. (DEPLOYMENT_POSTPROCESSING=YES).

Also make sure that "Use separate strip" is set to Yes (not always the default).

4. If, in addition to local symbols, if you need to remove some of the global symbols you can supply additional

options to the strip command, under the Xcode build setting "Additional strip flags". E.g. I commonly

use the strip "-R somefile" option to provide a file with an additional list of symbols which I want removed

from the global symbol table." Ref[17]

關於"STRIP_SYTLE" 參考Ref[19]

B) 將靜態庫的符號表剔除後, 會出現這種情況: 靜態庫出現crash時,無法將地址符號化。Ref[18]

C) 那麼靜態庫的符號被strip掉後, 會不會像App被產生.dSYM檔案呢? 或者其他類似的東西?

 

3.4 自動構建多architecture的靜態庫

Ref[15] 

 

3.5 當發布商業的靜態庫時,選擇debug configuration 還是release configuration呢?

Ref[16]

 

 

Reference

1. Avoiding dependency collisions in iOS static library managed by CocoaPods  (AAAA+)

http://blog.sigmapoint.pl/avoiding-dependency-collisions-in-ios-static-library-managed-by-cocoapods/

2. Using Static Libraries in iOS

https://developer.apple.com/library/ios/technotes/iOSStaticLibraries/Articles/creating.html

3. UNIX ar Examples: How To Create, View, Extract, Modify C Archive Files (*.a)

http://www.thegeekstuff.com/2010/08/ar-command-examples/

4. Avoiding duplicate symbol errors during linking by removing classes from static libraries  (ToRead)

http://atnan.com/blog/2012/01/12/avoiding-duplicate-symbol-errors-during-linking-by-removing-classes-from-static-libraries

5. Extract object (*.o) files from an iPhone static library

6. How to build a library for both iPhone simulator and device? 

7. Build fat static library (device + simulator) using Xcode and SDK 4+

8. Distributing your Static Library

http://www.akitaonrails.com/2011/04/24/objective-c-distributing-your-static-library#.VZY4ShOqqko

9. Xcode 6 drops armv7s

https://www.cocoanetics.com/2014/10/xcode-6-drops-armv7s/

10. iOS Static Libraries Are, Like, Really Bad, And Stuff  (ToRead)

http://landonf.org/code/ios/Radar_15800975_iOS_Frameworks.20140112.html

11. Strip debug symbol from universal static libraries (tested for iOS only)

https://gist.github.com/neonichu/1662881

12. An XCode project template to build universal frameworks (arm7, arm7s, and simulator) for iOS / iPhone.

https://github.com/kstenerud/iOS-Universal-Framework

13. http://www.raywenderlich.com/41377/creating-a-static-library-in-ios-tutorial (AAAA+)

14. strip nmeidt symbols: 編輯符號的工具

https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/symbols.1.html 

15. Automatic build of static library for iOS and many architectures (AAAA+)

http://blog.sigmapoint.pl/automatic-build-of-static-library-for-ios-for-many-architectures/

16. How to distribute Static libraries?

http://stackoverflow.com/questions/5730432/how-to-distribute-static-libraries/5778007#5778007

"So, long story short : just distribute a fat, release version of your library !" 

17. strip symbol in static library

17.1 Symbol hiding in static libraries built with Xcode/gcc

17.2 Symbolification: Shipping Symbols

http://bdunagan.com/2010/05/15/symbolification-shipping-symbols/

17.3 How to solve symbolication problems --> "Build settings for getting proper symbol data"

http://support.hockeyapp.net/kb/client-integration-ios-mac-os-x/how-to-solve-symbolication-problems

17.4 xcode build settings for debug symbol

http://jonathanblog2000.blogspot.tw/2013/07/xcode-build-settings-for-debug-symbol.html

18. Symbolicating crash log for app with static library

19. Xcode Build Setting Reference

https://developer.apple.com/library/ios/documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html

https://developer.apple.com/library/mac/technotes/tn2004/tn2123.html#SECNOSYMBOLS

iOS.StaticLibrary.1-avoid-duplicate-symbol-in-static-library[draft]

相關文章

聯繫我們

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