cocoapods導致的符號重複問題分析和解決,cocoapods符號

來源:互聯網
上載者:User

cocoapods導致的符號重複問題分析和解決,cocoapods符號


xplayer工程用了Pods,xplayerdemo_pods工程引用xplayer時又用了Pods,導致如下的連結錯誤:
duplicate symbol _OBJC_METACLASS_$_PodsDummy_Pods

類似:

duplicate symbol _OBJC_METACLASS_$_PodsDummy_Pods in:    /Users/erikkerber/Dropbox/Projects/MillMain/MyLib.framework/BuddySDK(Pods-dummy.o)    /Users/erikkerber/Library/Developer/Xcode/DerivedData/MillMain-fngfqhlslygksgcfuciznkpqfrbr/Build/Products/Debug-iphonesimulator/libPods.a(Pods-dummy.o)duplicate symbol _OBJC_CLASS_$_PodsDummy_Pods in:    /Users/erikkerber/Dropbox/Projects/MillMain/MyLib.framework/BuddySDK(Pods-dummy.o)    /Users/erikkerber/Library/Developer/Xcode/DerivedData/MillMain-fngfqhlslygksgcfuciznkpqfrbr/Build/Products/Debug-iphonesimulator/libPods.a(Pods-dummy.o)ld: 2 duplicate symbols for architecture i386


**********************嘗試刪除**********************
一種辦法是把demo工程裡Link Binary with Libraries裡的libPods.a的引用刪除即可。
但是這個方法無法用於自動構建,得尋找其他方案。


我們來看符號重複的原因:
xplayer這個靜態庫工程用了Pods,所以編譯連結了Pods-dummy.m檔案。


而xplayerdemo_pods又用了Pods,又編譯連結了新的Pods-dummy.m檔案。
導致了PodsDummy_Pods這個類重複。
所以思路是想辦法移除或重新命名其中的一個Pods-dummy.m檔案。
發現移除是不可行的,會導致無法產生libPods.a。


**********************嘗試重新命名**********************
現在來試重新命名。
首先想到的是將xplayer裡的Pods-dummy.m檔案重新命名,方法如下:
修改xplayer的Podfiles檔案
platform :ios, ‘5.0'
target xplayer do
pod 'CocoaHTTPServer', '= 2.3'
pod 'Reachability', '~> 3.0
end


這樣xplayer工程產生的dummy類是PodsDummy_Pods_xplayer。
此時Build xplayerdemo_pods工程會報錯說PodsDummy_Pods_xplayer這個符號重複了: 這是因為xplayerdemo_pods的Pods包含了xplayer, 產生了第二個PodsDummy_Pods_xplayer類。
如果我們能修改target xplayer do裡的”xplayer”為其他字串就好了,但是目前沒有找到這種解決方案。


現在剩下的辦法是將xplayerdemo_pods裡的Pods-dummy.m檔案重新命名,方法如下:
修改xplayerdemo_pods的Podfiles檔案如下
platform :ios, '5.0'
target :xplayerdemo_pods do #增加target語句
  pod 'xplayer', :podspec => 'http://repo.xx.com/specs/xplayer/0.0.1/xplayer.podspec'
end
這樣xplayerdemo_pods工程產生的dummy類是PodsDummy_Pods_xplayerdemo_pods。
這樣就不會和xplayer包含的dummy類PodsDummy_Pods重名了。
問題解決。

聯繫我們

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