How to update swift 2.3 project to latest swift 4 - ios

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

Related

ios - Xcode 10: Razorpay pod "module compiled with Swift 4.1 cannot be imported by the Swift 4.2 compiler"

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

Pod is built for newer version of

After changing both the deployment target of my project and targets from IOS 10.3 to 9.0 I am receiving the following errors. What am I doing wrong?
edit: These errors only show up when running my code in release not debug
Paste this at the end of your podfile
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
end
end
end
First try cleaning the project (shift+command+K). This likely won’t help but is always worth a try.
If/when cleaning does not work, check that the desired iOS version is in podfile, and then navigate to the project directory in Terminal and run pod update.

Error compiling RealmSwift with Xcode 8.2.1 and Swift 3

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. :)

XCode 8: Can't find AFNetworking header files and Swift pods errors

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

Converting from Swift 2.3 to 3.0

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.

Resources