watson-developer-cloud / swift-sdk

:iphone: The Watson Swift SDK enables developers to quickly add Watson Cognitive Computing services to their Swift applications.
https://watson-developer-cloud.github.io/swift-sdk/
Apache License 2.0
877 stars 222 forks source link

Module compiled with Swift 3.1 cannot be imported in Swift 4.0 #640

Closed joseph-francis closed 7 years ago

joseph-francis commented 7 years ago

I updated my swift version to 4.0. After that, I'm seeing this error. "Module compiled with Swift 3.1 cannot be imported in Swift 4.0: /Users/joseph/Desktop/News/Carthage/Build/iOS/TextToSpeechV1.framework.." I'm not sure what's going on.

glennrfisher commented 7 years ago

You're ahead of the curve, @joseph-francis! :)

We provide precompiled binaries with each GitHub release of the Swift SDK. That saves time for our users, since Carthage will just download the binaries instead of building each one. In your case, though, the binaries (which were built with Swift 3.1) are incompatible with Swift 4.0.

To skip the precompiled binaries and build them on your machine instead, run: carthage update --platform iOS --no-use-binaries

We haven't tried to build the SDK with Swift 4.0 yet. Hopefully it works for you. If not, feel free to open an issue and we'll try to fix it as soon as we can!

joseph-francis commented 7 years ago

I tried doing that, but it still shows me the error. Should I wait till you guys build the SDK with Swift 4.0? If so, what should I do when you guys finish building it? Also, is there anything else I could try? Thank you for your help. JF

MatthewWaller commented 7 years ago

Hi @joseph-francis, I just got my Watson set up working by adding files manually. By adding manually I mean you can add the repository as a git submodule, drag the .xcodeproj file into your Xcode project, and then add the framework you want into the embedded binaries section. You may have to remove your Carthage references, but it's working for me :) More on this style of adding dependencies here: https://www.raywenderlich.com/155150/dependency-management-using-git-submodules

glennrfisher commented 7 years ago

Thanks for the recommendation, @MatthewWaller!

Here's another approach, too. By default, running Xcode 9 does not change the version of the command-line tools that are being used. Since you still ran into that issue when using the --no-use-binaries option, @joseph-francis, your command line tools may still be set to Xcode 8.

To change them, open the Xcode Preferences and select the Locations tab. Then from the drop-down next to "Command Line Tools" choose "Xcode 9.0".

image

I downloaded the Xcode 9 Beta 2, set my command line tools, and tried carthage update --platform iOS --no-use-binaries. That seemed to successfully build most of the service SDKs with Xcode 9 / Swift 3.2 (which is compatible in a Swift 4.0 project).

However, there was an error with the TextToSpeech framework--which seems to be the framework you'd like to use. Xcode 9 has changed some of the behavior around C imports, which we use for the Opus library. I opened #641 to track that particular issue.

Hopefully that helps you build the other service frameworks. We'll try to fix that issue with Text to Speech soon.

joseph-francis commented 7 years ago

@glennrfisher @MatthewWaller Thanks for replying to my issue. I tried doing both ways, but it didn't work. In location->Command Line Tool, it was Xcode 9. hello theone

glennrfisher commented 7 years ago

Sorry to hear that, @joseph-francis. It worked okay on my machine, so there might be something different about our environments. Here are a few ideas that come to mind:

Hope that helps! Curious to hear about the results.

glennrfisher commented 7 years ago

Any luck, @joseph-francis?

joseph-francis commented 7 years ago

@glennrfisher Currently I downgraded Swift, Xcode and iOS version. It should be fine when swift 4 is officially released. Thank you for helping me and sorry for late reply.

glennrfisher commented 7 years ago

Oh, no worries! Just wanted to make sure that things were working for you. Glad it's building, although I wish we didn't have to put you through the trouble of downgrading. Sorry for that!

krishnagniyes commented 7 years ago

Thanks glennrfisher Your suggestion works for me. We provide precompiled binaries with each GitHub release of the Swift SDK. That saves time for our users, since Carthage will just download the binaries instead of building each one. In your case, though, the binaries (which were built with Swift 3.1) are incompatible with Swift 4.0.

To skip the precompiled binaries and build them on your machine instead, run: carthage update --platform iOS --no-use-binaries

We haven't tried to build the SDK with Swift 4.0 yet. Hopefully it works for you. If not, feel free to open an issue and we'll try to fix it as soon as we can!

gaoml0904 commented 7 years ago

if I use cocopods how to solve this problem?

glennrfisher commented 7 years ago

@gaoml0904 The SDK doesn't currently support CocoaPods (planning to add this soon). To install via Carthage, please check the readme or quick-start guide.