Getting 'no such module' error when importing a Swift Package Manager dependency

前端 未结 8 2137
离开以前
离开以前 2021-01-30 14:37

I\'m running Xcode 11 Beta 4. I\'m using CocoaPods, and wanted to use one of my dependencies with Swift Package Manager as a static library instead of as a framework. On a fresh

相关标签:
8条回答
  • 2021-01-30 15:29

    It turned out that Swift Package Manager implicitly depends on the project's Configuration names. I had them at live/qa instead of Release/Debug, and changing them back resolved the issue. Very odd, but I hope it saves you some trouble dear reader.

    0 讨论(0)
  • 2021-01-30 15:31

    After a whole week fighting this issue, I developed a workaround using schemes and pre-actions.

    I have a configuration called "Beta", so Xcode can't compile SPM dependencies. I realised Xcode compile SPM dependencies as Swift modules and add the files in Build/Products/Release-iphoneos folder in DeriverData.

    So I created a scheme in Xcode and added this run script on build pre-actions:

    cp -f -R "${SYMROOT}/Release${EFFECTIVE_PLATFORM_NAME}/" "${SYMROOT}/${CONFIGURATION}${EFFECTIVE_PLATFORM_NAME}/"
    

    This script run before the build process, coping files and modules generated by Xcode on default Release-iphoneos folder to configuration folder, Beta-iphoneos, in my case.

    After coping the content from Release-iphoneos to your $configuration$-iphoneos folder Xcode should correctly compile, build and run your project.

    0 讨论(0)
提交回复
热议问题