1、前言
前段時間,更新了 Xcode10 後,提供給第三方使用者的SDK,客戶回報說報錯:
ld: framework not found CoreServices for architecture armv7
為什麼 iOS SDK 拖入項目中就報錯"ld: framework not found IOSurface for architecture arm64"?
其實,翻開之前寫的文章已經說過解決方案:
Xcode8報錯:"Framework not found IOSurface for architecture arm64"或者 "Framework not found FileProvider for architecture x86_64/arm64". | iHTCboy's blog當時,反複确認後,網上有些第三方的SDK提供商說更新 Xcode10 吧!!!慌張~ 你們就隻能讓别人更新啦!解決不了,重新開機,更新!但,NO,最後發現是新項目是使用
CocoaPods
導緻的坑,一個地方進2次,還真不簡單!
其中,看到有贊雲這樣說:
我隻能說,坑的一個算一個,第三方使用者就是這樣,希望技術真的改變生活!包括技術的生活!
2、問題原因
因為我們新的項目使用
CocoaPods
元件化,是以最後打SDK的項目是CocoaPods內建的,問題就出在這裡!上一個文章說到解決方法很簡單:(
)
Build Settings 中 Link Frameworks Automatically 把預設Yes 改成 No
但是,如果用
CocoaPods
內建,預設是
Yes
!!! 尼瑪!!!
知道原因,解決就好辦啦!但是,突然想到,以後
pod install
或
pod update
時,難道要人工的設定一次??? 不可能!不可能!不可能!
最後,還是在
CocoaPods
官方文檔找到答案
CocoaPods Guides - post_install:
在
Podfile
檔案最後,添加下面代碼:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['CLANG_MODULES_AUTOLINK'] = 'NO'
end
end
end
這個是一個勾子
hook
,在pod安裝完成前,允許更改配置或做些别的事件!
3、總結
這個問題,2次進坑,解決的問題本質就是一個,隻是自己開始不相信!是以,遇到問題,還是要學會找到原因,隻是通往答案的道路各不相同,隻要不放棄,不抛棄,一定能為大家提供優質的服務!相信科技的力量!不然,隻能讓别人更新環境來适配你,這可不好哦!
參考
- SDK引入_常見問題 - 有贊雲
- Core Services | Apple Developer Documentation
- ios - Error when trying to link fat binary with 64-bit simulator target - Stack Overflow
- ld: framework not found CoreServices for architecture x86_64 · Issue #21768 · facebook/react-native
- XCode's New “Link Frameworks Automatically” & How to Fix “framework not found Metal for architecture armv7”
- Add option to set “LINK FRAMEWORKS AUTOMATICALLY” to NO · Issue #48 · CocoaPods/cocoapods-packager
- CocoaPods Guides - Podfile Syntax Reference v1.7.0.beta.2
- 如有疑問,歡迎在評論區一起讨論!
- 如有不正确的地方,歡迎指導!
注:本文首發于 iHTCboy's blog ,如若轉載,請注來源