Use Swift 3 framework in Swift 4 project

Hello,
I have a framework in Swift 3, and i have a project swift 4, can i import this framework into project (not convert and not use cocoapods). If can, how to do it?
I try research in internet but i don't know exactly key word so can't solve this? Help me!!! =.=

I don't think this is possible, since Swift 3 and Swift 4 are not binary compatible. You'll need to try to find a Swift 4 version of your framework or rewrite your project to use Swift 3.

Yes, this is possible. The Swift 4 compiler has a Swift "3.2" mode where it parses the source code as Swift 3 but spits out a Swift 4 module. With SwiftPM you don't actually have to do anything. Just compiler the whole thing with any Swift 4 compiler and as long as your Swift 3 code works in the Swift 3.2 mode it should be all fine.
You will have to have the sources for everything though. One thing you cannot do is compile one library with a Swift 3 compiler and then link it with a binary compiled with any other compiler (such as a Swift 4 compiler).

Btw, the // swiftToolsVersion: ... comment at the top of a Package.swift tells SwiftPM automatically what Swift version it should default to. If there's no such comment, Swift 3 is assumed. For new packages created with a Swift 4 SwiftPM, you'll notice that the very first line of Package.swift reads // swiftToolsVersion: 4.0.

2 Likes

Weren't there source-breaking changes between 3.1 and 3.2?