I am trying to create Library which I can use into my Existing XCode Project (iOS App). I am aware that Swift Package Manager now support generating Xcode project with command
swift package generate-xcodeproj
But I am not creating new project. In my existing project having Objective C & Swift Files, How can I use newly created Swift Package?
How to add Package.swift file to my current Project?
When you read the term “Package Manifest”, it is referring to your Package. swift file. As of today 10/10/19, you cannot have mixed Swift and Objective-C files in the same package's source code. (They may exist in the same 'Source' directory since you can explicitly exclude files from being compiled)
Open your Xcode project, navigate the File tab within the macOS bar, and click on “Add Packages”. In the Add New Package window, you can select from recently used or Apple Swift Packages. Alternatively, you can search for a package via the name or the URL to the Github page.
The Swift Package Manager can be used to add external libraries in Xcode projects. This makes the tool a good alternative to Cocoapods and Carthage for managing the dependencies of an iOS project.
To use Swift (v4) Package Manager with iOS you have to jump through a couple of hoops.
Basically,
swift package generate-xcodeproj
, modified to work with iOS, as a subproject of your main App xcodeprojI have an example with reproduction steps
As far as I know you can't use SPM right now within iOS apps.
You can use it in hosted environments for example if you are hosting a web application with Vapor on a Mac or on Linux.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With