Xcode 8 beta 4: Build fails with "The following binaries use incompatible versions of Swift:" error

21,489

Solution 1

I had the same problem, but managed to fix it by:

  1. Clean the project.
  2. Close project and quit Xcode.
  3. Clean derived data.
  4. Open the project again and it's there, all nice and working.

I did this on Xcode 8 using Swift 3.

Solution 2

You can also get this problem, if you have the scenario of your container app's code is Swift 2.3 and you're creating a new extension in Xcode 8.

To solve the above scenario...

Note: All code has to be in the same swift (compatible) version to compile without failure.

That being said, one way you could solve this problem is by sticking to Swift 2.3 and then setting your Extension Target's Use Legacy Swift Language Version to "Yes".

You can find that option while Xcode 8 is open as follows:

  1. Select your app project root in the Project Navigator (on the left-hand side)
  2. On the right-hand side, select your extension under the TARGETS section
  3. Once the extension is selected, click on the Build Settings tab
  4. Scroll down and find Use Legacy Swift Language Version and set it to Yes from its drop-down menu.
  5. You can now build the project

Note: You might need to fix the overridden code in the extension templates since they were originally in Swift 3.

Solution 3

Before doing anything...

(If you can use Xcode 8.0-compatible with your project)

By default your project is set to Xcode 3.2-compatible

  • Select your app project in the Navigator (on the left-hand side)
  • Select Project Document in the Utilities Panel (on the right-hand side)
  • Change Project Format to Xcode 8.0-compatible

Try to build your project.

If it doesn't work, try the other solutions proposed.

Note:You can even switch back to Xcode 3.2-compatible after fixing the error and it should work, but you "might" have other build problems later.

Recommendation: Before debugging an existing project. Close your project and zip a copy of your project file if you did not create a Git repository when you created your project.

Solution 4

I just had the same problem after updating Xcode to 9.3. I fixed the problem simply by just cleaning the build folder. You can do this with Command-Option-Shift-K or in the option menu "Product" -> "Clean" (see screenshot)

You can clean the build folder with Command-Option-Shift-K or in the option menu "Product" -> "Clean"

Solution 5

I fixed this by deleting the embedded binaries in the project. To do this:

  1. Open your workspace/ project in Xcode.
  2. Navigate to the actual project file (with the General, Capabilities, etc. ribbon).
  3. Go to General > Embedded Binaries, remove by selecting on the ones you don't want and then clicking the minus sign.

Note 1: You shouldn't have to delete them from the "Linked Frameworks and Libraries" section (they should automatically be removed when you remove them from the "Embedded Binaries").

Note 2: I have a lot of dependencies and am using CocoaPods. I have nothing in the "Embedded Binaries" and only the "Pods_[YourApplicationName].framework" in the "Linked Frameworks and Libraries" section.

Share:
21,489
Admin
Author by

Admin

Updated on March 28, 2020

Comments

  • Admin
    Admin about 4 years

    With new Xcode 8 beta 4 we started experiencing the following error during CopySwiftLibs build phase:

    Effective srcDirs: {(
    
        <DVTFilePath:0x7f865961e970:'/Volumes/Data/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator'>,
    
        <DVTFilePath:0x7f8657d02b20:'/Volumes/Data/Xcode-beta.app/Contents/Developer/Toolchains/Swift_2.3.xctoolchain/usr/lib/swift/iphonesimulator'>
    
    )}
    

    error: The following binaries use incompatible versions of Swift:

    /Users/user/Projects/git/iphone-swift-1/DerivedData/myApp/Build/Products/Debug-iphonesimulator/myApp.app/myApp

    /Users/user/Projects/git/iphone-swift-1/myApp/myAppApi.framework/myAppApi

    myAppApi is a subproject in the workspace that contains some shared code (it uses Alamofire).

    One thing to note: originally we converted project from Swift 2.2 to Swift 2.3, and then manually upgraded to 3.0.

    Does anyone have any idea what might be causing this error?

    Thanks!