Fully eradicating CocoaPods
Taking step one is all the time the toughest, however this time it is fairly a aid to do away with CocoaPods (you might need seen that I am not an enormous fan). So as to begin the entire process, you simply must run pod deintegrate
in your mission folder.
Yep, no traces left, however nonetheless, for those who go to the folder you will discover some remaining trash just like the .xcworkspace
file, the Podfile
and the Podfile.lock
. Merely delete these, since you will not want them anymore. Perhaps for those who want an inventory of your third-party libraries, you’ll be able to maintain your Podfile round for some time, so you’ll be able to make certain that you’ve migrated all the pieces. Other than these recordsdata, CocoaPods is now gone. Get pleasure from! 👍
Utilizing Swift Packages in Xcode 11
Many fashionable frameworks already assist SPM. For instance, Alamofire is able to use on iOS, macOS, tvOS, watchOS through the built-in Swift Package Manager. Let me present you the way to combine an present bundle first, then I am going to information you thru making your individual Swift bundle that may work on appleOS targets.
Triggering the movement is a bit of cake. Simply go to the File menu and choose Swift Packages, lastly click on on the Add Bundle Dependency… menu merchandise.
The one factor you have to do now could be to enter a legitimate Swift Bundle repository URL that you just’d like to make use of: often you’ll be able to copy & paste the github URL out of your browser. Legitimate implies that the git repo has to include a Bundle.swift
file.
You too can reset, resolve or replace your packages underneath the Swift Packages menu merchandise. It is actually good to have all the pieces in a single place.
In case you are unsure the place to search out the git repository URL, you’ll be able to go to cocoapods.org, enter your pod title and click on on the See Podspec menu merchandise on the proper aspect. The factor that you just want is underneath the supply key. 😉
You may choose the required model quantity, department and even commit message that you just’d like to make use of in the course of the checkout course of. This is available in extraordinarily useful in case you are utilizing some older model of a selected framework or library.
A Swift bundle can include a number of merchandise (a product is a framework or an executable), you’ll be able to choose and combine them individually in Xcode.
Lastly Xcode will do the required integration course of, like embedding the library into the mission and another construct configuration adjustments…
Now you’re able to import your framework in your goal. Nicely achieved. 👏
Tips on how to create a Swift Bundle for iOS?
The reply is sort of easy. Simply use Xcode’s File menu and choose: New > Swift Bundle…
Identify your library first, then put it aside someplace in your disk. Xcode will create nearly all the pieces for you that’s required to make use of a Swift bundle on Apple platforms.
Nonetheless, it’s a must to add just a few issues to the Bundle.swift
file, as a result of by default these Swift packages will not work in case you are planning to combine them with an iOS mission.
A very powerful factor is that it’s a must to configure your bundle to run on particular platforms. You are able to do this by including a brand new platforms part contained in the Bundle description object, proper after the title parameter. You may study extra in regards to the manifest format change from this Swift evolution proposal.
import PackageDescription
let bundle = Bundle(
title: "MyLibrary",
platforms: [
.iOS(.v12),
],
merchandise: [
.library(
name: "MyLibrary",
targets: ["MyLibrary"]),
],
dependencies: [
],
targets: [
.target(
name: "MyLibrary",
dependencies: []),
.testTarget(
title: "MyLibraryTests",
dependencies: ["MyLibrary"]),
]
)
Oh, by the best way SPM now helps target specific build settings if you have to configure a construct settings or hyperlink a selected dependency. I am not going into particulars, as a result of this may very well be a standalone tutorial, however if you wish to study extra in regards to the anatomy of Swift Bundle Supervisor you’ll be able to test all of the bundle associated evolution proposals here. These proposals are often rather well documented. 📖
As a final step you solely want a git repository populated with the supply recordsdata.
git init
git add .
git commit -m "preliminary"
git distant add origin [email protected]:<your-user>/MyLibrary.git
git push -u origin grasp
git tag 1.0.0
git push --tags
Now you’ll be able to add your library as I described it earlier than (remember to make use of git tags).