CocoaPods Tutorial for Swift: Getting Started | raywenderlich.com

Use this CocoaPods Tutorial for Swift to learn how to install and manage third-party library dependencies in your Swift projects.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/7076593-cocoapods-tutorial-for-swift-getting-started

When I run the app after pasting Alamofire.request code, it throws below error

2020-02-04 14:45:41.583060+0530 IceCreamShop[40823:2181633] ATS failed system trust

2020-02-04 14:45:41.583145+0530 IceCreamShop[40823:2181633] Connection 1: system TLS Trust evaluation failed(-9802)

2020-02-04 14:45:41.583264+0530 IceCreamShop[40823:2181633] Connection 1: TLS Trust encountered error 3:-9802

2020-02-04 14:45:41.583341+0530 IceCreamShop[40823:2181633] Connection 1: encountered error(3:-9802)

2020-02-04 14:45:41.586956+0530 IceCreamShop[40823:2181633] Task <18F11594-D7BD-48ED-8A85-FD6FCCC49031>.<1> HTTP load failed, 0/0 bytes (error code: -1200 [3:-9802])

2020-02-04 14:45:41.594363+0530 IceCreamShop[40823:2181633] Task <18F11594-D7BD-48ED-8A85-FD6FCCC49031>.<1> finished with error [-1200] Error Domain=NSURLErrorDomain Code=-1200 “An SSL error has occurred and a secure connection to the server cannot be made.” UserInfo={NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, _kCFStreamErrorDomainKey=3, NSErrorPeerCertificateChainKey=(
.
.
.
_kCFStreamErrorCodeKey=-9802, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <18F11594-D7BD-48ED-8A85-FD6FCCC49031>.<1>, NSURLErrorFailingURLPeerTrustErrorKey=<SecTrustRef: 0x6000031b01b0>, NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made.}

Tried adding these to the info.plist. Still not resolved. Can you help me with this?

<key>NSAppTransportSecurity</key>
	<dict>
		<key>NSAllowsLocalNetworking</key><true/>
		<key>NSExceptionMinimumTLSVersion</key><string>TLSv1.2</string>
		<key>NSAllowsArbitraryLoads</key><true/>
</dict>
1 Like

Sorry for the delayed response. Were you able to resolve this?
Seems like you have an issue with your certificate. Check out this StackOverflow question that may be helpful for you:

2020-02-12T08:00:00Z
I am having a different issue with the CocoaPods tutorial. I started this yesterday and got as far as the ‘pod install’ command.

After adding:
pod ‘Alamofire’, ‘4.9.1’
to the Podfile, saving, and closing, and then running
pod install
I got the following output:

th-Kirk-143232073115:begin rjacoby$ pod install (>>My terminal line)

Analyzing dependencies
Adding spec repo trunk with CDN https://cdn.cocoapods.org/

CocoaPods 1.9.0.beta.3 is available.
To update use: sudo gem install cocoapods --pre
[!] This is a test version we’d love you to try.
For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.9.0.beta.3

[!] Unable to find a specification for alamofire (= 4.9.1)
You have either:

  • out-of-date source repos which you can update with pod repo update or with pod install --repo-update.
  • mistyped the name or version.
  • not added the source repo that hosts the Podspec to your Podfile.

I ignored the portion of the output about the CocoaPods 1.9.0.beta.3

I then tried the ‘pod repo update’ and got a promising response:
th-Kirk-143232073115:begin rjacoby$ pod repo update (>>My terminal line)

Updating spec repo trunk

CocoaPods 1.9.0.beta.3 is available.
To update use: sudo gem install cocoapods --pre
[!] This is a test version we’d love you to try.
For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.9.0.beta.3

but when when I again try either ‘pod install’ or ‘pod install --repo-update’ I still get the same error message:

[!] Unable to find a specification for alamofire (= 4.9.1)

Any ideas on what is going wrong. Thanks.

@ronyr Can you please help with this when you get a chance? Thank you - much appreciated! :]

I was able to get the app to run as expected using the Flavors.plist file located at “https://www.raywenderlich.com/downloads/Flavors.plist”. As a test, I copied that file to my SQL Server and am not able to download. I am new to iOS development, but it appears to be connection issue, so my question is, how do I grant access to server via code? Here’s the stack:
2020-07-29 11:59:33.177899-0500 IceCreamShop[2041:69486] [] nw_socket_handle_socket_event [C1.1:3] Socket SO_ERROR [61: Connection refused]

2020-07-29 11:59:33.178409-0500 IceCreamShop[2041:69486] [BoringSSL] nw_protocol_boringssl_handshake_negotiate_proceed(726) [0x7fc3894230c0] handshake failed at state 0

2020-07-29 11:59:33.180541-0500 IceCreamShop[2041:69486] Connection 1: received failure notification

2020-07-29 11:59:33.180707-0500 IceCreamShop[2041:69486] Connection 1: failed to connect 1:61, reason -1

2020-07-29 11:59:33.180851-0500 IceCreamShop[2041:69486] Connection 1: encountered error(1:61)

2020-07-29 11:59:33.191518-0500 IceCreamShop[2041:69486] Task .<1> HTTP load failed, 0/0 bytes (error code: -1004 [1:61])

2020-07-29 11:59:33.197970-0500 IceCreamShop[2041:69485] Task .<1> finished with error [-1004] Error Domain=NSURLErrorDomain Code=-1004 “Could not connect to the server.” UserInfo={_kCFStreamErrorCodeKey=61, NSUnderlyingError=0x600000db8900 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 “(null)” UserInfo={_kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask .<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(

"LocalDataTask .<1>"

), NSLocalizedDescription=Could not connect to the server., NSErrorFailingURLStringKey=https://eskimo2/Flavors.xml, NSErrorFailingURLKey=https://eskimo2/Flavors.xml, _kCFStreamErrorDomainKey=1}

I had to go to Project>Target>Info and add under Custom iOS Target Properties and add the keys.

@ronyr Do you have any feedback about this? Thank you - much appreciated! :]