I'm learning Swift now, and I found out that the swift build command is available only in the development version of Swift.
So when I invoke
swift build
...it returns:
swift build unable to invoke subcommand.
Can someone explain why?
In another answer I found the above command, but why is it only available in the development version?
Swift Package Manager is included with Swift 3.0 and above. You should be able to use it now with the released versions that are included with Xcode 8 or downloadable on swift.org.
Related
I am getting this popup when I open my project in XCode 12, but I can compile the app fine:
It says
The target contains source code developed with Swift
3.x. This version of Xcode does not support building or migrating Swift 3.x targets.
Use Xcode 10.1 to migrate the code to Swift 4.
I am using Cordova so perhaps there's some legacy Swift code somewhere.
My question is how do I find out what swift files Xcode means? Any way to search for them?
I tried the logging from XCode in Console.app but found nothing there.
We are creating a custom framework using CI Jenkins build which is having Xcode 12 and try to import in another project which is using Xcode 11.6 and that shows the above error.
I am getting the above error while I am importing the above framework created by Xcode 12 but not working on Xcode 11.5.
Please provide the solution.
Xcode 11.x uses different command tools which causes mentioned problem. You have to update the project to the 12.0 and then you can use your custom framework.
Or you can manually change Swift version in the project files of your framework project. However, there is no point why not update the project ¯_(ツ)_/¯.
I just updated to Xcode 9 last week, and I've been looking for a way to get around this error:
Module compiled with Swift 3.1 cannot be imported in Swift 4.0
Each time a new version of Xcode is released that includes a new version of Swift, I have to wait for the RealmSwift project to be updated in order to build and run my project. I am aware that this has to do with Swift's ABI stability, but I also see others who seem to know how to get around this until a compatible version of Realm comes out. Currently, I am running 2.8.0, which was the current release as of last night. My dependency manager of choice is Carthage, but similar questions usually involve CocoaPods, which does not help me very much.
Can anyone offer some clear instructions for unfamiliar ones like me so I can keep working on my project now and when future versions come out? Thank you.
When using beta versions of Xcode which there are not prebuilt binaries for you need to pass --no-use-binaries to carthage bootstrap so that Carthage builds all of the dependencies from source.
I downloaded the new xCode 8 beta. When i opened my old project(in swift 2.2), i clicked the convert to new swift syntax, and i clicked swift 3. The problem is that i use a framework downloaded with carthage (Kanna). I have tried to use the:
carthage update
but it doesn't work.
When i try to run the code on the new Xcode-beta, i get this error:
Module file was created by an older version of the compiler; rebuild 'Kanna' and try again:
Seems like i am very late to answer but there is update available for 'Kanna' framework supporting swift 3.0. You can add this to your podfile if you use CocoaPods
use_frameworks!
pod 'Kanna', '~> 2.0.0'
Or for Carthage you can install like
github "tid-kijyun/Kanna" ~> 2.0.0
First of all save a backup of your current project. Now!
Solution 1
Open your project with Xcode 7.3.1, it uses Swift 2.2 so it will signal you a bunch of errors. Since you know Swift 2.2 you should be able to fix the errors and make you project again compatible with Swift 2.2
Solution 2
In Xcode 8 beta you can choose the Swift versione (Swift 2.3 or Swift 3.0). Select Swift 2.3 (it's fully compatible with Swift 2.3 but does support the new iOS API). Then, again, fix the errors manually.
Solution 3
Open the library you are using and use Xcode 8 to upgrade that to Swift 3.0. This is a temporary solution until the developer of that library will provide the upgraded code
When you open your project with Xcode 8.0 for the first time, you will be prompted via the migration assistant to do a migration pass. The assistant can also be invoked manually from the menu
Edit -> Convert -> To Current Swift Syntax…
If you upgraded code e.g. 2.3 to 3.0 and now want downgrade to 2.3 you can use above. If any errors occur copy your code from last commit in your repository and it should work fine.
I'm working on a project in Xcode and am attempting to install and use the CryptoSwift package via the Swift Package Manager.
I read the documentation on SPM, but I don't see instructions on how to invoke the SPM through Xcode.
The examples often refer to calling $ swift build. Does this mean that the SPM is only accessible from the command line?
And if so, where exactly am I supposed to create the Package.swift file?
I'm reasonably familiar with Xcode, but I don't really understand the meaning of the build settings part of a project, or how Swift modules are used.
EDIT: This question was originally asked for Xcode 7.2, which shipped with Swift 2.1.1. Will gladly accept answers that explain how to do this with current/future versions of Xcode.
Swift Package Manager now support generating Xcode project with
swift package generate-xcodeproj
as mentioned in this answer, but this only works when developing a library, or a command line tool. Not (yet) for (iOS/OS X) graphical application developer:
Note that at this time the Package Manager has no support for iOS, watchOS, or tvOS platforms.
Note:
It might not work well if there is a space in your package name, i.e. change "App Store" to "AppStore".
At present, to use the Swift Package Manager aka SPM, you need to install the development version of Swift 2.2 provided by Apple here. Xcode 7.2 shipped with Swift 2.1.1 and does not work with the SPM unless Swift 2.2-dev is installed.
You can compile with Swift 2.2-dev but you will need to do the build of CryptoSwift on the command line using swift build. When the library and modulemaps are built, you can drag and drop them into Xcode 7.2 using the Finder. SPM puts the required files into a .build directory. But Xcode 7.2 needs to be started with the alternate toolchain. This can be done from the command-line using xcrun launch-with-toolchain /Library/Developer/Toolchains/swift-latest.xctoolchain You should be able to import from the modules/libraries built with the SPM.
Note though, that you cannot submit iOS apps to the Store at the moment that have been built with the 2.2 development version. You can build/run/test things generally without problem, although Playgrounds are not functional and there can be Xcode issues with the debugger.
June 4th, 2019 update. Swift 5 and SPM 5 has added this support and Xcode 11 integrates with SPM.