I'm trying to migrate my Swift project from Swift 2.3 to Swift 3.0. I'm using the Realm framework for data storage, and it's giving me a headache!
I have tried several times now, and i have manually migrated from Swift 2.2 to Swift 2.3.
But after i used the build in migration assistent, i'm getting the following error.
I can't see which binaries causing the issue this time, but earlier it came up with Realm and RealmSwift framework. I have upgraded the Realm pods to version 1.1.
I have tried Clean Build my folder several times, and i have deleted everthing inside DerivedData, but the same issue still persist.
Any suggestions?
In your Podfile, add use_frameworks! and pod 'RealmSwift' to your main and test targets. Paste the following at the bottom of your Podfile updating the Swift version to 3.0:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.0'
end
end
end
Source: https://realm.io/docs/swift/latest/#installation
Credit for this goes to jpsim.
Related
Earlier I was using Xcode 9.3 but yesterday I updated it to Xcode 10 and its giving me compiler error:
error: module compiled with Swift 4.1 cannot be imported by the Swift 4.2 compiler: /Users/viraj/Desktop/Vachan app/vachan-ios/Pods/razorpay-pod/Pod/Razorpay.framework/Modules/Razorpay.swiftmodule/x86_64.swiftmodule
things which I have tried to resolve it
pod update.
deleting all pods and reinstalling them.
deleting derived data.
In Xcode 10, I have the project setting, Swift Language
Version, set to Swift 4.Here is the image
clean ,build and relaunching xcode.
Does anyone have suggestions on how to resolve this? Am I missing something? Xcode bug?
If you wanna use pod with swift version 4.1 just write post install script in your Podfile or update to pod version which suppots swift 4.2.
# Post install script
post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == 'razorpay-pod'
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '4.1'
end
end
end
end
I am having too many cocoapods installed. It shows too many compile time errors. How to solve this?
I am new to swift so looking for help.
Thanks
Choose auto upgrade after opening the project in Xcode 9.
In Podfile refer to the framework built in swift 4. Add below script in your Podfile and do a pod install, which will set the swift version of all pod targets to 4.
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '4'
end
end
end
Hope this helps in proceeding in upgrading the application to swift4
I recently migrated my Swift 2.3 SDK Project to Swift 3 using the XCode Swift Migrator. After doing so, I updated my pod dependencies (AlamoFire - 4.4.0 and SwiftyJSON - 3.1.4) to use their respective Swift 3 Versions.
Unfortunately, after this, my project did not build. I am getting the following errors:
Module compiled with Swift 2.3 cannot be imported in Swift 3.0.2:
.../Alamofire.framework/Modules/Alamofire.swiftmodule/x86_64.swiftmodule
I've set all the "Use Legacy Swift Language Version" to "NO" but still nothing.
I've "clean & build" project and "closed & reopen" workspace to no avail.
What else could I be possibly missing? How can I fix this?
Thanks.
Delete the pods from the pod file.
Quit Xcode.
Try to uninstall them by using the command pod install. This will update your project and delete all of the existing pods correctly.
Open Xcode and clean your project (and eventually try to build it once) and make sure the pods are gone.
Add the pods again to your pods file and run pod install again.
This is a general fix that could do it. It worked for me several times.
Try adding this in your pod file after all the pods and run pod install again...
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.0'
end
end
end
I installed RealmSwift using Cocoapods. It installed successfully, but when compiling it shows 96 errors as shown below
I have tried every solution I found on the internet. I have deintegrated the pods and installed again, but I keep getting the same errors. Please help!
It looks like Xcode is trying to run Realm Swift against the wrong version of Swift. A couple of things that I recommend you try:
Make sure to run pod spec update to update your local copy of Realm to the latest version.
Make sure you've followed the Realm CocoaPods instructions and added this to the bottom of your podfile:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.0.2'
end
end
end
If that still doesn't fix it for you, please update your question with a copy of your podfile so we can review it. :)
Today I've upgraded my XCode to 8 version, but After this I got a lot of errors. Ex:
The targets “Charts” and “CircleProgressView” contain source code developed with an earlier version of Swift.
Choose “Convert” to update the source code in these targets to the
latest SDKs. You will be given the choice to use Swift 2.3 syntax or
update to Swift 3.
This action can be performed later using “Convert to Current Swift
Syntax” in the Edit menu.
And AFNetworking/AFNetworking.h file not found. The steps I made:
Added post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '2.3'
end
end
end to my Podfile
Updated my cocoapods gem to a latest version.
After the 1st step my error about swift module has left. But I still can't find header of my AFNetworking. Help me out please