Should I convert all targets to latest Swift syntax? - ios

Xcode 7 Beta automatically selected all my targets for migrating to Swift 2. Is this correct? It seems to me that I should only select my app and test targets.

Yes, I needed to also convert Pod targets of other frameworks obviously. This seems like a silly question in retrospect. If I didn't convert the Pod targets, they wouldn't compile with Swift 2. The thing I don't like about it is that I had to modify these other frameworks' source code, but they were just simple syntax changes that should be fine until they officially upgrade.

I don't think Xcode 7 is yet accepted for App Store submissions. So you need to really, really make sure that this fits in with your plans, and keep a Swift 1.2 / Xcode 6 version around in case you need to release an urgent update.
Xcode 7 and Swift 2 are beta software.

Related

Swift framework for all Xcode versions

I provide a Swift framework for my customers.
It would only work in Xcode 10.3 (Or am I doing anything wrong?)
For other Xcode, it does have Swift compatibility issues.
So I am planning to release a series of versions of my framework so that a customer with a particular Xcode version can have the respective framework version of mine.
And it is pretty complex. Because for every release or bug fix I need to generate a bunch of versions.
I just want validation if this is the right approach.
How do I simplify this?
The compatibility issue you have is not from the version of the Xcode, is from the Swift version of the Framework. There is a difference.
In every project you can set the Swift version, but unfortunately you can't have more than one swift version per project. The current accepted ones are Swift 4, Swift 4.2 or Swift 5, as you can see in Xcode > Target > Build Settings:
Xcode 10.0 was the last version to support Swift 3 and is currently obsolete. I wouldn't create a framework version for it.
So, I would recommend you to either focus only on the latest Swift version and create a new Framework version every time a new Swift version appears (the most common approach), or start with the current three Swift versions and give them maintenance until the Swift version is deprecated.

Unsupported Swift Version 3.x in Xcode 10.3

I keep downloading sample codes and many times it says "Unsupported Swift Version 3.x...Use Xcode 10.1 to migrate the code to Swift 4".
Why is it not possible to migrate to Swift 4 using Xcode 10.3 or Xcode 11 beta?
More importantly, I am using Swift 4.2 in my own Project that has several dependancies as well through Pods. If I don't upgrade to Swift 5.1 or later, it seems my own project would start getting such errors in Xcode 12 or so, correct? While I can convert my own code to Swift 5.1, I have no idea if dependencies such as SwiftyDropbox would migrate to Swift 5.1 so easily. What implications it would have for my project in future and what could I do to future proof my project in that case?
Ask Apple. The company has decided – certainly for good reasons – to migrate files only to the Current Swift Syntax. Feel free to create legacy system partitions with older versions of Xcode to migrate code step by step.
The grace period to update the Swift version is long enough to ensure a smooth transition. At least Xcode allows to use the 3 most recent Swift versions in the same project. However you are responsible to maintain the version control. Check the dependencies periodically for updates. If a dependency is not able to release an update within the grace period it's not much good.

Why Projects made in Swift 3 or lower gives error new Xcode 9 supporting swift 4.1?

Its been a very tough for me to get a suitable answer for this Question as I know the solution but the reason is still unknown
Let me explain the question properly, when we make any projects like in swift 3 or lower version in lower versions of Xcode like 7 or 8
Its Doest run in new Xcode version like 9 we have to change the Swift_version in build settings to make it work.
Why doest it happen why Xcode doesn't support all versions of swift like I can show us deprecated warning rather then throwing error
for Obj c It works in all Xcode whatever Xcode you use it supports Obj c
Because Xcode 9 does not ship with older Swift versions. You need to update your Swift code.
Generally, Xcode also does not support older Obj-C versions, but Obj-C syntax hardly changes from year to year, that is why Obj-C code that you wrote in Xcode 7 runs in Xcode 9. But this was not the case for Obj-C code you wrote in say Xcode 2 or lower.

How can I use swift 2 and swift 3 at the same time?

Although swift 3 is released, I don't want to update my code just yet, because a lot of the CocoaPods I used are still in swift 2. I don't know what the migrator will do to those pods. Will they remain unchanged, causing the project to not build successfully? Or will they be migrated to Swift 3 as well? I don't know!
On the other hand, I really want to try out the new syntax and other new features in Swift 3. They seem really cool!
How can I continue developing my existing projects with Swift 2, but for other projects, compile with Swift 3?
In other words, how can I choose a compiler for a project?
How can I continue developing my existing projects with Swift 2, but for other projects, compile with Swift 3?
Install both Xcode 7 (which has Swift 2) and Xcode 8 (for Swift 3) and use the xcode-select command line tool to switch between them.

Can I use old frameworks when migrating to Swift 3?

I'm currently migrating my project to Swift3 as I know that there is one bug I have under iOS 10 that needs to be fixed.
So I installed iOS 10 on one of my devices.
Now I can't run my app on the device, getting the 'Could not find developer disk image' error.
So I downloaded the latest Xcode8-beta.
Now my code can't be compiled - I first have to convert it to the newest syntax.
So while fixing all the non auto-converted syntax issues, I'm getting errors for frameworks I'm importing, too:
"Module file was created by an older version of the compiler"
Which - to my understanding - means that this framework needs to be recompiled with the current version of XCode.
This would mean that I would have to cross my fingers that all the frameworks I use are up-to-date, or otherwise, fix those, too?
Is it not possible at all to use 'deprecated' frameworks?
Is this Apple being super strict to get rid of any Swift1/2 code as possible?
This would mean that I would have to cross my fingers that all the frameworks I use are up-to-date, or otherwise, fix those, too?
Is it not possible at all to use 'deprecated' frameworks?
Is this Apple being super strict to get rid of any Swift1/2 code as possible?
Yup. Swift 3 is it.
I feel bad for those that had to convert their C code to swift 2, and now swift 3 is coming xD
Hopefully they will make the transition easier with the final release version, and that shortly after that all of the major frameworks will have been updated (for you to recompile).
You need to recompile the frameworks. Even frameworks managed with dependency managers like Carthage (which recompile on each update command) are still having problems with XCode 8 Betas / Swift 3: https://github.com/Carthage/Carthage/issues/1440

Resources