xcodebeautifulsoupcocoapodsswift4swiftsoup

SwiftSoup Support for Swift 4


Does SwiftSoup support Swift 4.0? I've initialized my Podfile and added pod "SwiftSoup" as instructed by the SwiftSoup GitHub repo https://github.com/scinfu/SwiftSoup before running pod install, but I'm not able to import it into my Swift files. I'm using the .xcworkspace file in XCode as the SwiftSoup README instructs, not the .xcodeproj workspace.

Podfile looks like:

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'httpget' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for httpget
  pod "SwiftSoup"

  target 'httpgetTests' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'httpgetUITests' do
    inherit! :search_paths
    # Pods for testing
  end

end

If SwiftSoup has no support for Swift 4.0, does anybody have any alternatives that I can use? I'm trying to parse a Swift String object containing HTML to remove all script tags and extract a div tag with a specific class.

Essentially I'm trying to do the equivalent of the Python BeautifulSoup commmand:

classInfo = html.find('div', class_='theClass').get_text()

in Swift.


Solution

  • Just kidding, I found that the problem was I didn't edit my Scheme. If I went under Product->Scheme->Pod-[projname] I could import SwiftSoup. However, after building my project I found that SwiftSoup does not have support for Swift 4, as it uses many functions that Swift 4 made obsolete.