Use CocoaPods in your project
AppCode: 2019.3 or later
Xcode: 11 or later
Initial project: iOSConferences
Final project: iOSConferences
In this tutorial you'll elaborate the iOSConferences application (see Create a SwiftUI application in AppCode) by making it load the up-to-date list of iOS/macOS conferences from the remote YAML file used for the cocoaconferences.com website.
To parse the YAML file, you'll use the Yams library which will be added into the project by means of the CocoaPods dependency manager.
Step 1. Install CocoaPods
Download the iOSConferences project and open it in AppCode.
Select Tools | CocoaPods | Select Ruby SDK from the main menu. Alternatively, in the Preference dialog ⌃ ⌥ S, go to Tools | CocoaPods.
note
The CocoaPods menu item is grayed out while the project is being indexed.
In the Preferences dialog, click Add Ruby SDK, and specify the path to the Ruby SDK that will be used with CocoaPods, by default,
/usr :/bin /ruby Click the Install CocoaPods button.
After the CocoaPods gem is installed, the list of pods is displayed on the Tools | CocoaPods page of the Preferences dialog:

note
If you are using the CDN specs repo (default for CocoaPods 1.8 and later), the pods summary and description are unavailable.
Step 2. Add the Yams pod to the project
From the main menu, select Tools | CocoaPods | Create CocoaPods Podfile. The Podfile will be created in the same directory with the .xcodeproj file and opened in the editor.
tip
You can open the created Podfile by selecting Tools | CocoaPods | Edit Podfile from the main menu.
In the Podfile, add the
Yams
pod under theiOSConferences
target:project 'iOSConferences.xcodeproj' target 'iOSConferences' do use_frameworks! pod 'Yams' end
tip
Code completion is available while you are editing the Podfile:
After you have added the
pod 'Yams'
code line, AppCode notifies you that the Podfile contains pods not installed yet. To install theYams
pod, click the Install pods link in the top-right corner of the editor. Alternatively, with the caret placed atpod 'Yams'
, press ⌥ ⏎, select Install, and press ⏎.
When the library is installed, AppCode automatically reloads the project as a workspace.
Step 3. Load data from the remote YAML
In our application, the conference data model already exists — iOSConferences
However, you need to change the current code used for loading and parsing the data. For handling the results of the URL session, you'll use the Combine framework, for parsing the data — a dedicated YAMLDecoder
.
Step 4. Pass data to the view
Go to iOSConferences/ConferenceList.swift.
Inside the
ConferenceList
view, add an@ObservedObject
property wrapper with an instance of theConferencesLoader
class:struct ConferenceList: View { @ObservedObject var conferenceLoader = ConferencesLoader() var body: some View { // ... } }
Pass the list of the loaded conferences (
conferenceLoader.conferences
) to theList
initializer:struct ConferenceList: View { @ObservedObject var conferenceLoader = ConferencesLoader() var body: some View { NavigationView { List(conferenceLoader.conferences) { // ... } } }
Run ⇧ F10 the application. Now the list consists of all conferences available in the remote YAML file: