Reputation: 955
After updating to Xcode 9, I tried to build one of my projects.
I use the FacebookLogin pod. I have a compiler error in FacebookLogin/LoginButton.swift
@testable import FacebookCore
❌ Module compiled with Swift 3.1 cannot be imported in Swift 4.0
In my target's build settings, the Swift language version is set to Swift 3.2.
I guess I need to wait for Facebook to update their pod ? Or any other suggestion ?
Thanks !
Upvotes: 80
Views: 37023
Reputation: 1634
Update:
Solution also tested and working in Swift 5 and Xcode 11.
Original:
I would like to add that if you are using Carthage to compile a module in Swift 3.2 you should go to a terminal and run:
sudo xcode-select --switch /Applications/Xcode-beta.app/Contents/Developer
To use the Xcode 9 command line tools, then you can run:
carthage update NameOfTheLibrary --platform iOS --no-use-binaries
This will compile the library with your current command line tools, it can be a bit slow but now the project should build.
Note
To revert and use your stable Xcode command line tools simply run:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
Upvotes: 73
Reputation: 59
I had the same problem with Xcode 9 GM and this solved my problem: Remove it from the project and drag it again into "Embedded Binaries".
Upvotes: 2
Reputation: 7370
If using Carthage , Open terminal and;
carthage update --platform iOS --no-use-binaries
If using Pod , Open terminal and;
pod update
(Also if don't work in pod, you can change SWIFT_VERSION in podfile Ex:
config.build_settings['SWIFT_VERSION'] = '3.2'
)
After;
Open Xcode and use;
Command+Option+Shift+K
Upvotes: 8
Reputation: 5249
For my case - the actual pod referenced a static zip with prebuilt binaries targeting swift 3.1. So only solution is to rebuild the framework with source from xcode 9.
https://github.com/AudioKit/AudioKit/issues/980
Upvotes: 0
Reputation: 1838
If you use from Pod:
Podfile
comment FacebookLogin podpod install
Podfile
uncomment FacebookLogin podpod install
Upvotes: 0
Reputation: 3940
I ran into the same issue on Xcode 9 Beta 3, which pointing to 'Alamofire' and tried a few different solutions, the easiest one i found is
1. CMD+SHIFT+K to clean the build
2. Restart Xcode 9 <-- make sure you do this step, that's critical. `
Upvotes: 11
Reputation: 305
goto xcode DerivedData directory then remove all file inside it and recompile your project . it work for me .
and default DerivedData directory is :~/Library/Developer/Xcode/DerivedData.
Upvotes: 8
Reputation: 1289
Xcode 9 comes with a Swift 4 compiler that understands both Swift 3.2 and swift 4, it even lets you mix and match between the 2 versions. Unfortunately, other versions aren't supported.
Even if you set your language to Swift 3.2, it uses the Swift 4 compiler.
If you're using cocoapods, you can add this to the end of your pod file to force the pods to use Swift 3.2 or 4.0:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.2'
end
end
end
Alternatively, you could put the files from the pod directly into your project temporarily, until FacebookLogin is updated to Swift 3.2 or 4.
Note: Edited based on Matt's feedback
Upvotes: 26
Reputation: 41
It works for me.
1.Clean your project in Xcode 8
2.Build or run your project in Xcode 9
Upvotes: 4
Reputation: 5406
Doing a "clean build folder" and restarting Xcode 9 cleaned up the error for me. Also the error didn't stop the app from running on my device or the simulator.
Upvotes: 10
Reputation: 1514
I have
pod 'FBSDKCoreKit'
pod 'FBSDKLoginKit'
pod 'FBSDKShareKit'
in my project and import FBSDKLoginKit
, after cleaning the target i didn't have any issue
Since the pod you are using is in swift and is a beta pod, it is likely that you would have some issues with the swift 4 compiler, you should use the objective-c version of the pod for the time being
Upvotes: 1
Reputation: 197
Maybe you can clean the target before you build it. It works fine for me.
Upvotes: 19