1

I am trying to use SwiftyDropbox framework in a project which uses Swift 4.2, but SwiftyDropbox is still using Swift 3. How does one include libraries or frameworks using previous Swift versions?

Deepak Sharma
  • 5,577
  • 7
  • 55
  • 131

2 Answers2

2

Xcode doesn't provide default option to compile one module in particular Swift version. Either you can compile entire project in Swift 3 or 4+. So to solve your problem you must go with cocoapods. Once you have configure pod, you can make a single pod to compile with specific Swift version.

  1. Open .xcworkspace
  2. Select Pods.xcproj
  3. On RHS, under "Targets", select "SwiftyDropbox".
  4. Navigate to "Build Settings" and search for "Swift Language Version" enter image description here
  5. Change the version to "Swift 3".
  6. Delete "Derived Data" and "Clean Project".
  7. Lastly, build and you won't see any error.
Sohil R. Memon
  • 9,404
  • 1
  • 31
  • 57
0

I'm not an expert on this, nor have I tried it, but this is my understanding: If you split up your app into multiple frameworks, one or more of your frameworks can target Swift 3 while others target Swift 4.2. Your Swift 3 framework(s) can then reference the third party Swift 3 framework(s) you want to use.

I guess Xcode will take care of the bindings properly between your own frameworks that differ in Swift version, since you're compiling them yourself as target dependencies.

Finally, if the third party framework is open source, and reasonably small, consider just forking it and moving it up to Swift 4.2 yourself. I've taken this approach for some smaller frameworks I use (e.g. Netfox) - the larger ones like Realm I've just had to wait for them to do it.

Smartcat
  • 2,834
  • 1
  • 13
  • 25