Search code examples
iosswiftcocoapodsswift-package-manager

Migrate module from Cocoa Pods to Swift Package Manager


I am using this git library but unfortunately I am getting this error when trying to build the app on another Simulator that I haven't used before:

Module compiled with Swift 5.1.2 cannot be imported by the Swift 5.2 compiler

I opened an issue and the creator told me to install the Module with Swift Package Manager.

Never done before so I uninstalled it from CocoaPods and followed this tutorial to install the module.

After the installation I am getting this error message and I can't run my app:

Packages are not supported when using the legacy build system, but the current workspace has it enabled

Does anyone have any idea how I can fix this issue?


Solution

  • Usually it's a workspace setting: select File > Workspace Settings and see what it says. When selected options are like shown below, it means workspace is not using legacy build system:

    enter image description here

    Now, if your workspace is using legacy build system, there could be a good reason for that, and by changing it you may break other things. So you really need to know what your project is doing.

    To your original issue:

    Module compiled with Swift 5.1.2 cannot be imported by the Swift 5.2 compiler

    Generally that means that POD was compiled on Xcode 11.2, while you are using Xcode 11.4. So you could install XCode 11.2 (in parallel with Xcode 11.4, they co-exist just fine) and use it for now for that particular project, until developers of the framework provide compatible version. Again, you need to know if you actually can downgrade your workspace to earlier XCode, or something else will break.