当前位置: 首页>后端>正文

ios sdk(framework、.a)开发,静态库和动态库的创建。黑科技(workspace)。以及开发经验和问题总结

鍓嶈█锛氭湰绡囦富瑕佹槸璁茶В浠庢棤鍒版湁鐨剆dk寮€鍙戯紝浠ュ強瀵箂dk寮€鍙戣繃绋嬩腑閬囧埌鐨勯棶棰樿褰曪紝鏂逛究浠ュ悗閬囧埌鐩镐技闂鍙互杞绘澗瑙e喅銆傚鏈変笉瀵圭殑锛屾湡鏈涘ぇ瀹跺澶氭彁鍑?..鏈枃浼氫竴鐩存寔缁洿鏂?/p>

绗竴璁诧細杩樻槸鍏堜粠鏈€鍩虹鐨勫紑濮嬶紝鍒涘缓涓€涓紑鍙憇dk鐨勫伐绋嬶紝鏈€甯哥敤鐨勮繕鏄痜ramework銆?/h3>

璇存槑涓嬶紝鏈鍒涘缓鏄粨鍚堝疄闄呭紑鍙戞祦绋嬫潵鐨勶紝鍒涘缓demo璋冭瘯宸ョ▼锛屽皢涓昏鐨勫姛鑳藉啓鍦╢ramework閲岄潰锛屾渶缁堜氦浠榝ramework缁欏鎴枫€?/p>

涓€锛氭潵涓垵绾х増鏈殑锛屽彧鏈変竴涓猣ramework鐨勬儏鍐?/h6>
  1. 鍏堝湪妗岄潰鍒涘缓涓€涓┖鐨勬枃浠跺す锛岀敤鏉ユ斁demo鍜宖ramework
  2. 鍒涘缓涓€涓櫘鏅€氶€氱殑demo锛宒emo瀛樺偍浣嶇疆鏀惧湪鍒氬垰鍒涘缓鐨勬枃浠跺す閲岄潰
  3. 鏈€閲嶈鐨勶紝寮€濮嬪垱寤轰竴涓?code>闈欐€乫ramework
    ios sdk(framework、.a)开发,静态库和动态库的创建。黑科技(workspace)。以及开发经验和问题总结,第1张
    鎴睆2021-09-18 涓嬪崍3.47.54.png

    鍒涘缓濂藉悗锛屼綅缃拰demo骞崇骇銆傝繖鏍峰氨鏈変竴涓紑鍙戣皟璇昫emo锛屼竴涓墦鍖呯殑sdk銆傛垜杩欓噷鍒涘缓鐨刦ramework鍚嶇О鏄疓eneral銆?br>
    ios sdk(framework、.a)开发,静态库和动态库的创建。黑科技(workspace)。以及开发经验和问题总结,第2张
    1631951719770.jpg

    鐐瑰嚮鎵撳紑General锛屾垜浠幓鐪嬬湅鏋勯€狅紝鏈sdk鍙敮鎸乮os绯荤粺锛屾墍浠ュ厛鎶妋ac_os鍏堝垹鎺夈€?code>products鏂囦欢鐩綍涓嬶紝鏀剧殑灏辨槸鎴戜滑鎯宠鐨刦ramework锛屾垜浠寮€鍙戦渶瑕佸垱寤虹殑绫伙紝灏辨斁鍦?code>General鏂囦欢涓嬨€?br>
    ios sdk(framework、.a)开发,静态库和动态库的创建。黑科技(workspace)。以及开发经验和问题总结,第3张
    鎴睆2021-09-18 涓嬪崍3.50.24.png
鍐嶄慨鏀逛竴涓嬮厤缃弬鏁帮紝璇风Щ姝ョ浜岃锛宍鎵撳寘閰嶇疆鐨勫弬鏁癭
  1. 鎺ヤ笅鏉ュ湪General閲岄潰涓€涓被锛屾坊鍔犱竴涓柟娉曪紝娴嬭瘯涓?br>

    ios sdk(framework、.a)开发,静态库和动态库的创建。黑科技(workspace)。以及开发经验和问题总结,第4张
    1631957713135.jpg

    瑕佹兂澶栭儴鑳借闂埌杩欎釜绫伙紝杩橀渶瑕佸皢person绫荤殑.h鏂囦欢璁剧疆涓?code>public
    ios sdk(framework、.a)开发,静态库和动态库的创建。黑科技(workspace)。以及开发经验和问题总结,第5张
    1631957915771.jpg
  2. 灏?code>demo鍜?code>General鍏宠仈璧锋潵锛屾柟渚胯皟璇?code>Genera搴?/code>閲岄潰鐨勬柟娉?br> 杩欎釜鏃跺€欓渶瑕佹敞鎰忊殸锔忥紝鎴戜滑鍒涘缓鐨刣emo鍙槸涓€涓櫘閫氬伐绋嬶紝鏄棤娉曞拰鍏朵粬搴撳叧鑱旇捣鏉ョ殑锛岃繖涓椂鍊欐垜浠渶瑕佸垱寤轰竴涓?code>榛戠鎶€锛岄偅灏辨槸workspace銆傛渶绠€鍗曠殑鍒涘缓鏂瑰紡灏辨槸pods锛屾槸涓嶆槸绐佺劧鎯冲埌浜嗮煒勶紝褰撴垜浠娇鐢╟ocopods鐨勬椂鍊欙紝宸ョ▼pods鍚庝細鍑烘潵涓€涓甫鏈墂orkspace鍚庣紑鐨勬枃浠躲€傞偅缁欓」鐩坊鍔燾ocopods锛屾垜灏变笉璇翠簡锛岀偣鍑诲甫鏈?code>workspace鍚庣紑鐨勬枃浠讹紝閲嶆柊鎵撳紑宸ョ▼

    ios sdk(framework、.a)开发,静态库和动态库的创建。黑科技(workspace)。以及开发经验和问题总结,第6张
    1632731110189.jpg

鎵撳紑鍚庯紝杩欎釜鏃跺€欐墠鑳藉紑濮嬪叧鑱?General'锛屽湪宸﹁竟绌虹櫧澶勶紝鍙抽敭鐐瑰嚮Add Files to ...锛岃繘鍏ュ悗锛屾坊鍔?code>General鐨勫伐绋嬫枃浠讹紝涓€瀹氳鍙栨秷鍕鹃€?code>copy item into groups folder

ios sdk(framework、.a)开发,静态库和动态库的创建。黑科技(workspace)。以及开发经验和问题总结,第7张
鎴睆2021-09-27 涓嬪崍4.29.16.png

ios sdk(framework、.a)开发,静态库和动态库的创建。黑科技(workspace)。以及开发经验和问题总结,第8张
1632731644632.jpg

鐐瑰嚮'add'锛屾坊鍔犲悗锛岄噸鏂板洖鍒板伐绋嬶紝杩欎釜鏃跺€欎細鐪嬪埌General宸茬粡鏉ュ埌浜嗘垜浠殑宸ョ▼椤圭洰涓簡銆傜湅涓€涓嬪伐绋嬬洰褰曪紝鏄笉鏄竴鏍风殑

ios sdk(framework、.a)开发,静态库和动态库的创建。黑科技(workspace)。以及开发经验和问题总结,第9张
1632732151808.jpg

杩涜鍒拌繖閲岋紝鎴戜滑鍙畬鎴愪簡涓€鍗婏紝鎺ヤ笅鏉ユ槸灏?code>General鐨?code>framework锛屽叧鑱斿埌demo閲岄潰銆傜偣鍑籨emo宸ョ▼鐨則arget锛屽湪frameworks,libraies,and Embedded content閲岄潰娣诲姞锛岀偣鍑?code>General.framework,娣诲姞鍚?br>

ios sdk(framework、.a)开发,静态库和动态库的创建。黑科技(workspace)。以及开发经验和问题总结,第10张
1632732411937.jpg

ios sdk(framework、.a)开发,静态库和动态库的创建。黑科技(workspace)。以及开发经验和问题总结,第11张
1632732481001.jpg

娣诲姞瀹屾垚鍚庯紝杩橀渶瑕佹渶鍚庝竴姝ヨ缃紝灏唀mbed璁剧疆涓?code>Do Not Embed
ios sdk(framework、.a)开发,静态库和动态库的创建。黑科技(workspace)。以及开发经验和问题总结,第12张
1632732633155.jpg

绗簩璁?鎵撳寘閰嶇疆鐨勫弬鏁?/h3>
  1. 閰嶇疆鎴愰潤鎬佸簱锛屽湪bulild setting 閲岄潰淇敼銆?/li>
Mach-O Type      锛?璁剧疆涓篠tatic Library銆傝繖涓槸璁剧疆涓洪潤鎬佸簱
  1. 閰嶇疆Build Active Architecture銆傞€夋嫨NO锛岃〃绀轰笉浠呬粎鏋勫缓褰撳墠閫夋嫨璁惧鐨勬灦鏋?/li>
Build Active Architecture Only    =     NO
  1. 閰嶇疆 Strip Debug Symbols During Copy
Strip Debug Symbols During Copy 璁剧疆涓?NO锛屼笉鐒舵柇鐐逛笉浼氳蛋
  1. 璁剧疆Excluded Architecture锛堟帓闄ゆ灦鏋勶級
General -> XXSDK -> Build Settings -> Excluded Architectures -> Release -> 娣诲姞閫夋嫨Any iOS Simulator SDK -> 娣诲姞arm64

鍥犱负Xcode12浠ュ悗锛屾瀯寤烘ā鎷熷櫒鐨勫簱涔熼粯璁ゆ敮鎸乤rm64鏋舵瀯锛岃繖灏嗕細瀵艰嚧鐪熸満鍜屾ā鎷熷櫒鐨勫簱鍚堝苟鏃跺け璐ワ紙fatal error: xx1/XLTestFrame and xx2/XLTestFrame have the same architectures (arm64) and can't be in the same fat output file锛夛紝鎶ラ敊鍘熷洜锛氱湡鏈哄簱鍜屾ā鎷熷櫒搴撻兘鍖呭惈arm64鏋舵瀯

绗笁璁诧細鏈夋椂鎴戜滑鎯崇煡閬撳綋鍓嶇殑sdk鍖咃紝鏀寔鍦ㄥ摢浜涙墜鏈轰笂杩愯锛岃繖鏃跺氨闇€瑕佸幓鏌ョ湅銆傛煡鐪媠dk 鍖?鏀寔鐨勮澶囩増鏈?/h3>
  1. 鎵撳紑缁堢
cd  鎶婃闈笂鐨刦ramework鎷栬繘鏉ュ惂

2.1 浣跨敤 lipo -info 鍏抽敭瀛楁煡鐪媐ramework,鍚庨潰鍔犱笂浣爁ramework鍚嶅瓧

lipo -info frameworkName

2.2 浣跨敤 lipo -info 鍏抽敭瀛楁煡鐪?a鐨勯潤鎬佸簱锛屽悗闈㈠姞涓婂叏绉?/p>

lipo -info frameworkName.a
  1. 1 绀轰緥 opencv2.framework
cd /Users/zhangsan/Desktop/opencv2.framework 

lipo -info opencv2

3.2 绀轰緥 LibFaceRecognition.a

cd /Users/zhangsan/Desktop/MSRecordAVSDK

lipo -info LibFaceRecognition.a

鏍规嵁鏌ヨ鍑烘潵鐨勬寚浠ら泦锛屾煡鐪嬪搴旀敮鎸佺殑璁惧
iOS璁惧鏀寔鐨勬寚浠ら泦

armv6:

銆€銆€iPhone, iPhone 3G, iPod 1G/2G

armv7:

銆€銆€iPhone 3GS, iPhone 4, iPhone 4S, iPod 3G/4G/5G, iPad, iPad 2, iPad 3, iPad Mini

armv7s锛?

銆€銆€ iPhone 5, iPhone 5c, iPad 4

arm64:

銆€銆€iPhone X锛宨Phone 8(Plus)锛宨Phone 7(Plus)锛宨Phone 6(Plus)锛宨Phone 6s(Plus), iPhone 5s, iPad Air(2), Retina iPad Mini(2,3)

arm64e:

銆€銆€iPhone XS\XR\XS Max

绯荤粺榛樿鐨勬寚浠ら泦锛?
路 $(SDKROOT)=iphoneos: armv7 arm64 
路 $(SDKROOT)=iphonesimulator: i386 x86_64
路 $(SDKROOT)=macosx: x86_64

璁剧疆浣犵殑sdk鏀寔鐨勭増鏈?/h6>

濡傛灉浣犳兂璁剧疆浣犵殑sdk鏀寔鐨勭増鏈负armv7 arm64锛屼綘闇€瑕佸皢浣犵殑绯荤粺鐗堟湰璁剧疆涓?code>ios8銆?br> 濡傛灉浣犳兂璁剧疆浣犵殑sdk鏀寔鐨勭増鏈负arm64锛屼綘闇€瑕佸皢浣犵殑绯荤粺璁剧疆涓?code>ios11銆?/p>

绗洓璁诧細鐞嗚ВBuild Active Architecture Only

寰€寰€鎴戜滑鍦ㄦ墦鍖卻dk鐨勬椂鍊欙紝浼氳€冭檻鍏跺吋瀹规€э紝鎻愪緵缁欏鎴风殑鐗堟湰锛岃鍏煎锛屼笉鑳芥姤閿欍€傚摢鎬曟槸鍔熻兘涓嶆敮鎸佽繖涓増鏈紝浣嗘槸鑷冲皯缂栬瘧浣犲緱杩囷紝鐒跺悗鍐嶈€冭檻鎬庝箞閬垮紑浣庣郴缁熺増鏈殑銆?br> Build Active Architecture Only 涓€鍏辨湁涓や釜bool鍊硷紝YES銆?code>NO銆備粬浠殑鍚箟鍒嗗埆鏄細

璁剧疆涓簓es锛屾槸鍙紪璇戝綋鍓嶇殑architecture鐗堟湰锛屾槸涓轰簡缂栬瘧閫熷害鏇村揩銆?
涓€鑸垜浠湪release鐜涓嬭繖鏍疯缃€?
鑰岃缃负no鏃讹紝绯荤粺浼氱紪璇戞墍鏈塧rchitecture涓嬬殑鐗堟湰
涓€鑸垜浠湪debug鐜涓嬭繖鏍疯缃€?

鎵€浠ユ垜浠緱璁剧疆涓篘O锛屽悜涓嬪吋瀹逛綘鎵€鏈夋敮鎸佺殑鐗堟湰銆傛垜鍦ㄧ浜岃鐨勬椂鍊欙紝璁茶В浜嗘€庝箞璁剧疆鏀寔

绗簲璁?寮€鍙戜腑閬囧埌鐨勶紝瑙夊緱鍙互璁板綍涓嬬殑鐭ヨ瘑鐐?/h3>

1. 閰嶇疆浠g爜閫夋嫨鎬х紪璇?/h5>
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 90000
 // iOS9浠ュ悗 鎵ц杩欓噷
#else
//ios9浠ュ墠 鎵ц杩欓噷
#endif
2. 鎵撳寘闈欐€佸簱鏃讹紝xib涓嶄細琚紪璇戞垚nib锛岃€屽鏋滀綘鐩存帴鍦ㄤ富椤圭洰涓娇鐢▁ib锛岀紪璇戠殑鏃跺€欏氨浼氭妸xib缂栫▼nib銆傚洜姝ら渶瑕佹垜浠墜鍔ㄦ妸xib缂栫▼nib
浣跨敤鍛戒护琛岋細ibtool --errors --warnings --output-format human-readable-text --compile /Users/**/Desktop/ViewController.nib /Users/**/Desktop/ViewController.xib
3. 鏌ヨ涓€涓簱锛屾槸闈欐€佸簱杩樻槸鍔ㄦ€佸簱
  1. 棣栧厛鍦ㄥ伐绋嬩腑鎵惧埌褰撳墠搴擄紝榧犳爣鍙抽敭show in finder锛屾壘鍒版枃浠剁洰褰?br>

    ios sdk(framework、.a)开发,静态库和动态库的创建。黑科技(workspace)。以及开发经验和问题总结,第13张
    鏂囦欢鐩綍.png
  2. 鎵撳紑缁堢锛岃緭鍏ユ煡璇㈠懡浠?br> cd 灏嗗綋鍓嶇殑搴撴嫋杩涙潵
    file 搴撳悕

绀轰緥锛?AFNetworking.framework

cd  /Users/***/AFNetworking.framework
file AFNetworking

杈撳嚭

current ar archive:璇存槑鏄潤鎬佸簱
Mach-0 dynamically锛氳鏄庢槸鍔ㄦ€佸簱
4. 鏌ヨ鍔ㄦ€佸簱鏄惁绛惧悕

cd 灏嗗綋鍓嶇殑搴撴嫋杩涙潵
codesign -dv 搴撳悕

绀轰緥锛歓RTC.framework

cd /Users/***/ZRTC.framework
codesign -dv ZRTC

杈撳嚭锛?/p>

Signature size=4895,Signed Time=Mar 2, 2022 at 10:14:14 AM 锛氳鏄庡凡绛惧悕
code object is not signed at all 锛?璇存槑娌℃湁绛惧悕
5. 鍒╃敤鑴氭湰鑷姩蹇界暐x86妯℃嫙鍣ㄦ灦鏋?/h5>

鑳屾櫙锛氫负浜嗘柟渚挎ā鎷熷櫒杩愯缂栬緫锛屼竴鑸垜浠殑framework浼氬寘鍚玜rm64鍜寈86鏋舵瀯锛屼絾鏄痑rchive鎵撳寘涓婃灦鏃讹紝浼氭姤閿欙紝涓嶅厑璁稿彂甯冿紝闇€瑕佸皢x86鐨勬灦鏋勭粰鍒犻櫎鎺夈€傝繖涓椂鍊欏氨鍙互鍒╃敤xcode鑷甫鐨勮剼鏈伐鍏?/p>

  1. 鍏堝垱寤鸿剼鏈紪杈戝櫒 Target -> build Phaes -> + -> New Run Script Phases
    ios sdk(framework、.a)开发,静态库和动态库的创建。黑科技(workspace)。以及开发经验和问题总结,第14张
    鎴睆2024-01-16 20.00.08.png
  2. 鍦ㄧ紪杈戝櫒閲岄潰杈撳叆鑴氭湰浠g爜

#!/bin/sh

# Strip invalid architectures

strip_invalid_archs() {
binary=""
echo "current binary ${binary}"
# Get architectures for current file
archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)"
stripped=""
for arch in $archs; do
if ! [[ "${ARCHS}" == *"$arch"* ]]; then
if [ -f "$binary" ]; then
# Strip non-valid architectures in-place
lipo -remove "$arch" -output "$binary" "$binary" || exit 1
stripped="$stripped $arch"
fi
fi
done
if [[ "$stripped" ]]; then
echo "Stripped $binary of architectures:$stripped"
fi
}

APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"

# This script loops through the frameworks embedded in the application and
# removes unused architectures.
find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
do
FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"

strip_invalid_archs "$FRAMEWORK_EXECUTABLE_PATH"
done

ios sdk(framework、.a)开发,静态库和动态库的创建。黑科技(workspace)。以及开发经验和问题总结,第15张
WechatIMG146.jpg

鎶ラ敊鏁寸悊锛屽紑鍙戜腑閬囧埌鐨勬姤閿欙紝鎸佺画鏇存柊....

1. 寮曞叆鐨勫簱锛岃缃殑embed

bitcode_strip /Users/xx/Library/Developer/Xcode/DerivedData/xxx-
ageraaywrmdjawgxyquufnhwqqnf/Build/Products
/Debug-iphoneos/xxx.framework/xxx: /Applications/Xcode.app/Contents
/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/bitcode_strip exited with 1 

瑙e喅鏂规锛岃缃负 Do Not Embed锛屼富瑕佹槸鍥犱负褰撳墠framework鏄釜闈欐€佸簱銆傚鏋滄槸鍔ㄦ€佸簱锛岄偅涔堝氨闇€瑕佽缃负Embed & Sign锛岀洰鍓?code>appstore鏄彲浠ヤ笂绾垮姩鎬佸簱锛屼絾鏄繀椤婚厤缃簱鐨勭鍚嶅拰app鐨勭鍚嶄竴鑷?br>

ios sdk(framework、.a)开发,静态库和动态库的创建。黑科技(workspace)。以及开发经验和问题总结,第16张
鎴睆2021-10-21 涓嬪崍4.50.39.png

2. xcode15 杩愯ios12绯荤粺宕╂簝

dyld: Library not loaded: /System/Library/Frameworks/MetricKit.framework/MetricKit
  Referenced from: /var/containers/Bundle/Application/B5F01DF6-99FE-44C9-A4FB-C4D781FCAD66/ZKJAIRecord.app/ZKJAIRecord
  Reason: image not found

宕╂簝鍒嗘瀽锛氱敱浜嶮etricKit搴撴槸鍦↖os13绯荤粺鎵嶅嚭鐜扮殑锛屾墍浠ヤ細宕╂簝銆?br> 瑙e喅鍔炴硶锛氬鏋滄病鏈変娇鐢紝灏卞垹闄ゆ帀璇ュ簱銆傚鏋滆浣跨敤锛岄偅涔堝氨闇€瑕佹敼鏈€浣庢敮鎸佺増鏈€?/p>

3. framework寮€鍙戞椂锛屽穿婧冨埌category

*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
 reason: '-[__NSCFConstantString zkj_toTest]: unrecognized selector sent to instance 0x10455c4b8'

宕╂簝鍒嗘瀽锛?br> 鑻规灉瀹樻柟Q&A涓婃湁杩欎箞涓€娈佃瘽锛?/p>

The "selector not recognized" runtime exception occurs due to an issue between the implementation of standard UNIX static libraries, the linker and the dynamic nature of Objective-C. Objective-C does not define linker symbols for each function (or method, in Objective-C) - instead, linker symbols are only generated for each class. If you extend a pre-existing class with categories, the linker does not know to associate the object code of the core class implementation and the category implementation. This prevents objects created in the resulting application from responding to a selector that is defined in the category.

缈昏瘧杩囨潵锛屽ぇ姒傛剰鎬濆氨鏄疧bjective-C鐨勯摼鎺ュ櫒骞朵笉浼氫负姣忎釜鏂规硶寤虹珛绗﹀彿琛紝鑰屾槸浠呬粎涓虹被寤虹珛浜嗙鍙疯〃銆傝繖鏍风殑璇濓紝濡傛灉闈欐€佸簱涓畾涔変簡宸插瓨鍦ㄧ殑涓€涓被鐨勫垎绫伙紝閾炬帴鍣ㄥ氨浼氫互涓鸿繖涓被宸茬粡瀛樺湪锛屼笉浼氭妸鍒嗙被鍜屾牳蹇冪被鐨勪唬鐮佸悎璧锋潵銆傝繖鏍风殑璇濓紝鍦ㄦ渶鍚庣殑鍙墽琛屾枃浠朵腑锛屽氨浼氱己灏戝垎绫婚噷鐨勪唬鐮侊紝杩欐牱鍑芥暟璋冪敤灏卞け璐ヤ簡銆?br> 瑙e喅鏂规硶

瑙e喅鏂规硶锛屽湪Other Linker Flags閲屽姞涓婃墍闇€鐨勫弬鏁帮紝鐢ㄥ埌鐨勫弬鏁颁竴鑸湁浠ヤ笅3涓細

  • -ObjC : 閾炬帴鍣ㄤ細鎶婇潤鎬佸簱涓墍鏈夌殑Objective-C绫诲拰鍒嗙被閮藉姞杞藉埌鏈€鍚庣殑鍙墽琛屾枃浠朵腑锛岃櫧鐒惰繖鏍峰彲鑳戒細鍥犱负鍔犺浇浜嗗緢澶氫笉蹇呰鐨勬枃浠惰€屽鑷村彲鎵ц鏂囦欢鍙樺ぇ

  • -all_load : 浼氳閾炬帴鍣ㄦ妸鎵€鏈夋壘鍒扮殑鐩爣鏂囦欢閮藉姞杞藉埌鍙墽琛屾枃浠朵腑锛屼絾鏄崈涓囦笉瑕侀殢渚夸娇鐢ㄨ繖涓弬鏁帮紒鍋囧浣犱娇鐢ㄤ簡涓嶆涓€涓潤鎬佸簱鏂囦欢锛岀劧鍚庡張浣跨敤浜嗚繖涓弬鏁帮紝閭d箞浣犲緢鏈夊彲鑳戒細閬囧埌ld: duplicate symbol閿欒锛屽洜涓轰笉鍚岀殑搴撴枃浠堕噷闈㈠彲鑳戒細鏈夌浉鍚岀殑鐩爣鏂囦欢锛屾墍浠ュ缓璁湪閬囧埌-ObjC澶辨晥鐨勬儏鍐典笅浣跨敤-force_load鍙傛暟銆?/p>

  • -force_load : 鎵€鍋氱殑浜嬫儏璺?all_load鍏跺疄鏄竴鏍风殑锛屼絾鏄?force_load闇€瑕佹寚瀹氳杩涜鍏ㄩ儴鍔犺浇鐨勫簱鏂囦欢鐨勮矾寰勶紝杩欐牱鐨勮瘽锛屼綘灏卞彧鏄畬鍏ㄥ姞杞戒簡涓€涓簱鏂囦欢锛屼笉褰卞搷鍏朵綑搴撴枃浠剁殑鎸夐渶鍔犺浇銆?/p>

鎵惧埌Build settings->Linking->Other Linker Flags锛屽皢姝ゅ睘鎬т慨鏀规垚-ObjC

3. framework寮€鍙戞椂锛岀紪璇戞姤閿?/h4>
Undefined symbols:
Linker command failed with exit code 1 (use -v to see invocation)

闂鎺掓煡鍒嗘瀽锛屾槸鍥犱负鍦ㄥ紑鍙慺ramework鏃讹紝涓讳綋璇█鏄疧C锛屼絾鏄祵鍏ヤ簡swift璇█绫汇€傚湪demo灞備篃鏄疧C璇█妗嗘灦锛屽鑷寸殑銆?/p>

瑙e喅鍔炴硶锛氬湪App宸ョ▼閲岄潰锛屾柊寤轰竴涓猻wift绫伙紝绌烘枃浠跺嵆鍙紝涓嶉渶瑕佷换浣曚唬鐮併€傚啀娆$紪杈戝畬缇庤В鍐炽€?/p>

PS: 涓€鑸嚭鐜拌繖涓棶棰橈紝杩樻湁灏辨槸鍦‵ramework寮曠敤浜嗙涓夋柟绫伙紝浣嗘槸鍦ㄥ閮ˋpp鏈紩鐢ㄨ绫?/h6>

4. Xcode鍗囩骇15

鎶ラ敊锛?code>Sandbox: rsync.samba(38011) deny(1) file-write-create
浣跨敤 Xcode15 鏂板缓椤圭洰鍚庯紝pod 寮曞叆閮ㄥ垎绗笁鏂逛細鎶ヤ笂闈㈢殑閿欒

瑙e喅鍔炴硶锛欱uild Settings 鎼滅储 sandbox锛屾妸 Build Options 涓殑 User Script Sandboxing鏀逛负 NO

5. Pod瀵煎叆涓夋柟搴撳悗锛屼娇鐢ㄦ椂宕╂簝

鍦ㄥ紑鍙慺ramework鏃讹紝鐢ㄥ埌浜嗕笁鏂?code>masonry锛孉pp宸ョ▼涓紩鐢ㄨframework锛宲od閲屾坊鍔?masonry',缁撴灉杩愯鏃讹紝宕╂簝鍦ㄤ簡masonry鐨勬柟娉曚笂銆?/p>

瑙e喅鍔炴硶锛欱uild Settings 鎼滅储 linker锛屽湪 Build setting 涓殑 Other Linker Flags,娣诲姞 $(inherited)

閫氳繃CocoaPods闆嗘垚鐨勯」鐩紝$(inherited)灏嗕細鍖呭惈Pods.xcodeproj涓殑閰嶇疆銆俰nherited 鏄户鎵跨殑鎰忔€濄€?/p>

SWift 寮€鍙慺ramework,閬囧埌鐨勯棶棰橈紝鍙傝€冮摼鎺ュ涓?/h3>

swift SDK寮€鍙戦亣鍒扮殑闂


https://www.xamrdz.com/backend/3xv1933862.html

相关文章: