Swift不能通过Xcode 8上的cocoapods导入Swift json和Alamofire。

时间:2023-01-17 22:19:29

I need use SwiftyJSON and Alamofire in my Swift project, so I use cocoapods.

在我的Swift项目中,我需要使用Swift json和Alamofire,所以我使用cocoapods。

My podfile is :

我的podfile是:

platform :ios, '9.0'
target 'SwiftSalt' do
    use_frameworks!
    pod 'SwiftyJSON'
    pod 'Alamofire', '~> 4.0'
end
post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['SWIFT_VERSION'] = '3.0'
        end
    end
end

Also, I did add a USER_HEADER_SEARCH_PATHS , $(PODS_ROOT)/**.

另外,我还添加了USER_HEADER_SEARCH_PATHS, $(PODS_ROOT)/**。

But, it still didn't work. It says "No such module 'SwiftyJSON'". What does module mean?

但是,它仍然不起作用。它说“没有这样的模块‘swift json’”。模块是什么意思?

3 个解决方案

#1


0  

Change config.build_settings to swift 2.3. Because swiftyJSON is still on swift 2.3

改变配置。build_settings迅速2.3。因为swift仍在swift 2.3中。

 post_install do |installer|
installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
        config.build_settings['SWIFT_VERSION'] = '2.3'
    end
end

end

结束

#2


0  

Used the following podfile to install the Swift 3 branch of SwiftyJSON, and it worked on the project:

使用下面的podfile安装Swift 3分支的Swift json,并在项目中工作:

  platform :ios, ’10.0’

  project ‘/Users/You/yourproject.xcodeproj’

  target 'yourproject' do
  use_frameworks!
  pod 'SwiftyJSON', :git => 'https://github.com/appsailor/SwiftyJSON.git', :branch => 'swift3'
  end

  post_install do |installer|
     installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
           config.build_settings['SWIFT_VERSION'] = '3.0'
           end
      end
  end

#3


0  

pod 'Alamofire', '~> 4.0'
pod 'SwiftyJSON', :git => 'https://github.com/appsailor/SwiftyJSON.git', :branch => 'swift3'

#1


0  

Change config.build_settings to swift 2.3. Because swiftyJSON is still on swift 2.3

改变配置。build_settings迅速2.3。因为swift仍在swift 2.3中。

 post_install do |installer|
installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
        config.build_settings['SWIFT_VERSION'] = '2.3'
    end
end

end

结束

#2


0  

Used the following podfile to install the Swift 3 branch of SwiftyJSON, and it worked on the project:

使用下面的podfile安装Swift 3分支的Swift json,并在项目中工作:

  platform :ios, ’10.0’

  project ‘/Users/You/yourproject.xcodeproj’

  target 'yourproject' do
  use_frameworks!
  pod 'SwiftyJSON', :git => 'https://github.com/appsailor/SwiftyJSON.git', :branch => 'swift3'
  end

  post_install do |installer|
     installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
           config.build_settings['SWIFT_VERSION'] = '3.0'
           end
      end
  end

#3


0  

pod 'Alamofire', '~> 4.0'
pod 'SwiftyJSON', :git => 'https://github.com/appsailor/SwiftyJSON.git', :branch => 'swift3'