xcode编译Flutter IOS工程时找不到Swift库报错
为了在app中加入播放声音的功能,使用了audioplayers
插件,运行Android工程没有问题,但运行IOS工程时报错。
报错信息如下:
ld: warning: Could not find or use auto-linked library 'swiftObjectiveC'
ld: warning: Could not find or use auto-linked library 'swiftCoreGraphics'
ld: warning: Could not find or use auto-linked library 'swiftUIKit'
ld: warning: Could not find or use auto-linked library 'swiftMetal'
ld: warning: Could not find or use auto-linked library 'swiftCoreFoundation'
ld: warning: Could not find or use auto-linked library 'swiftCompatibility50'
ld: warning: Could not find or use auto-linked library 'swiftDispatch'
ld: warning: Could not find or use auto-linked library 'swiftAVFoundation'
ld: warning: Could not find or use auto-linked library 'swiftCoreMedia'
ld: warning: Could not find or use auto-linked library 'swiftCompatibilityDynamicReplacements'
ld: warning: Could not find or use auto-linked library 'swiftCoreImage'
ld: warning: Could not find or use auto-linked library 'swiftCoreAudio'
ld: warning: Could not find or use auto-linked library 'swiftCoreMIDI'
ld: warning: Could not find or use auto-linked library 'swiftUniformTypeIdentifiers'
ld: warning: Could not find or use auto-linked library 'swiftDarwin'
ld: warning: Could not find or use auto-linked library 'swiftMediaPlayer'
ld: warning: Could not find or use auto-linked library 'swiftSwiftOnoneSupport'
ld: warning: Could not find or use auto-linked library 'swiftQuartzCore'
ld: warning: Could not find or use auto-linked library 'swiftCore'
ld: warning: Could not find or use auto-linked library 'swiftsimd'
ld: warning: Could not find or use auto-linked library 'swiftCompatibility51'
ld: warning: Could not find or use auto-linked library 'swiftFoundation'
截图:
原因
在Xcode中混编OC和Swift需要Bridging Header桥接文件,而我的项目中没有这个文件。
解决方案:
1.在工程中任意创建一个Swift
文件,若无桥接文件Xcode会提示是否创建Bridging Header桥接文件,点击创建即可。
2.进入工程targets
中Build Settings
然后设置 Always Embed Swift Standard Libraries
为 YES
总结
造成这个问题的原因是工程要使用OC和Swift混编,但是并没有初始化,工程中没有桥接文件所导致的,只要在工程中创建桥接文件即可解决。