Steps to Install SwiftyJSON
Step 1: Install Cocoapods
Install cocoaPods, once that is ready, let’s create our Xcode project.
Step 2: Open Existing Project OR Create Project
Step 3: Add Project
Now navigate to your project folder and open a terminal window, also navigate the terminal window to the project location.
cd /Users/your account/Documents/w3wiki/How_To_Use_SwiftyJSON/
The above path may be different for you so Type “cd/ ” and paste that path.
Step 4: pod init
Navigate to your project folder using Terminal and type pod Init Once there you should do a “pod init” in your terminal:
pod init
It will then output a file named Podfile.
Step 5: Add the SwiftyJSON
Now navigate to the project using finder Open the profile and add the SwiftyJSON pod:
pod “SwiftyJSON”
pod ‘”Alamofire”
The code will look like
# Uncomment the next line to define a global platform for your project
# platform :ios, ‘9.0’
target ‘GFG’ do
# Comment the next line if you don’t want to use dynamic frameworks
use_frameworks!
pod ‘Alamofire’
# Pods for GFG
pod “SwiftyJSON”
end
Step 6: Run pod
Save the file and in your terminal run the following command:
pod install
Step 7: Import
Open the file named [projectname. xcworkspace] and your project should have SwiftyJSON installed and ready to go.
Step 8: Add SwiftyJSON Dependencies
Navigate to the “File” option in the top left corner and click on the Add Package Dependencies.
Now click on the search button and paste the GitHub link:
https://github.com/SwiftyJSON/SwiftyJSON
Now click on the Add Package.
Wait until it is finished.
Click on the Add Package.
If the package is visible in the Package Dependencies, you have successfully added the dependency.
Swift – SwiftyJSON
Swift is a powerful programming language for all Apple platforms. SwiftyJSON is an open-source and free-to-use library that helps to format JSON in an easy and usable format. It is a third-party Swift library that is used to read and process JSON data from an API/Server.
To use SwiftyJSON you just need to import that library:
import SwiftyJSON