Cannot implement Swift SSLCreateContext - ios

I am new to iOS development, and am trying to implement an SSL connection to a custom port.
I found the code from this answer as the best/easiest implementation of a secure connection over a socket https://stackoverflow.com/a/30733961/2306428
However, I am getting these errors:
Use of unresolved identifier 'kSSLClientSide'
Use of unresolved identifier 'kSSLStreamType'
Use of unresolved identifier 'kSSLSessionOptionBreakOnClientAuth'
I have checked and I am running Swift version 2.1.1, using iOS 9.2 SDK and Xcode 7.2. I have even tried adding import Security but that has no effect.
What is the reason that these constants are not being found?
The line being tested is here: https://github.com/ksred/bank-ios/blob/master/Bank/TCPClient.swift#L209

Please use the identifiers declared in Swift:
if let sslContext = SSLCreateContext(kCFAllocatorDefault, SSLProtocolSide.ClientSide, SSLConnectionType.StreamType) {
SSLSetIOFuncs(sslContext, sslReadCallback, sslWriteCallback)
SSLSetConnection(sslContext, &socketfd)
SSLSetSessionOption(sslContext, SSLSessionOption.BreakOnClientAuth, true)
SSLHandshake(sslContext)
}

Related

os_log - use of unresolved identifier error

I'm trying to use the new os_log API, by logging a simple statement:
os_log("Hello")
And I get an error for os_log:
Use of unresolved identifier 'os_log'
I also tried wrapping it in a block, like this
if #available(iOS 10.0, *) {
let foo: StaticString = "Something happened."
os_log(foo)
}
And I still get the same error. I would like to use this in Swift 4.
I looked for possible frameworks that might be required, and found no likely candidates.
I found no solution from these links either:
https://developer.apple.com/documentation/os/logging
https://developer.apple.com/videos/play/wwdc2016/721/
Because you forgot to
import os
at the start of this file.

Initialization error with CDYelpFusionKit

Trying to use the CDYelpFusionKit api for an app, and I'm getting an error on the first step:
let yelpAPIClient = CDYelpAPIClient(apiKey: "myapikeyhere")
It's saying that it's an
Use of unresolved identifier 'CDYelpAPIClient'
but I have already installed the dependencies with cocoapods.
You also need to import the framework
import CDYelpFusionKit

ARSessionConfiguration unresolved in Xcode 9 GM

I have created an ARKit project using a beta version of Xcode 9, which I was able to run on my real device without issues.
Yesterday, I upgraded to Xcode 9 GM, and without touching anything, Xcode shows multiple errors, saying it does not know ARSessionConfiguration i.e.:
Use of undeclared type 'ARSessionConfiguration'
and:
Use of undeclared type 'ARWorldTrackingSessionConfiguration'
...for this code:
let session = ARSession()
var sessionConfig: ARSessionConfiguration = ARWorldTrackingSessionConfiguration()
I have imported ARKit and am using the ARSCNViewDelegate in my ViewController.
When opening the project from the beta version of Xcode, it does not show the errors and I can again run the app on my phone.
Any idea how I can fix this?
ARWorldTrackingSessionConfiguration has been deprecated and renamed to ARWorldTrackingConfiguration: See here
Also, ARSessionConfiguration has been deprecated and renamed to ARConfiguration, which is now an abstract base class.
Use AROrientationTrackingConfiguration when you don't want world tracking, instead of using a generic ARConfiguration. Thus:
let configuration = AROrientationTrackingConfiguration()
You can also check if world tracking is supported on a device:
if ARWorldTrackingConfiguration.isSupported {
configuration = ARWorldTrackingConfiguration()
}
else {
configuration = AROrientationTrackingConfiguration()
}
In Xcode 9 GM, looks like ARWorldTrackingSessionConfiguration has been renamed to ARWorldTrackingConfiguration:
https://developer.apple.com/documentation/arkit/arworldtrackingconfiguration
Reference to this change:
https://github.com/markdaws/arkit-by-example/issues/7
ARSessionConfiguration has been renamed to ARConfiguration:
https://developer.apple.com/documentation/arkit/arconfiguration

Use of unresolved identifier CNContact [swift 3]

In swift 2, this below line works
var contacts = [CNContact]()
But in swift 3 it's got 'Use of unresolved identifier CNContact' error message. I tried both insert and delete import Contacts since xcode 8 ignoring import because the viewcontroller is already part of module 'Contacts'. How to solve it?
It's perfectly working in Swift 3.0. I have just created a new project and I can freely use CNContact.
Possible Workaround:
Delete Derived Data
Clean your project
Now try to build your project.

Setting up Airbrake with a Swift Project

I'm new to Airbrake and I'm probably just doing something silly, but I've followed the steps outlined here to setup Airbrake in a Swift project: https://github.com/airbrake/airbrake-ios
Seems simple enough but I'm getting two errors I can't resolve:
1)
Use of unresolved identifier 'ABNotifier'
2)
Use of unresolved identifier 'ABNotifierAutomaticEngironment'
I removed all the files, frameworks and directories and tried again in case that was the issue but same errors occur. I'm guessing for some reason this ABNotifier class isn't being recognized/not in scope?
I'm wondering if others have had this problem and this is an easy fix. Below is my line throwing the error:
let key = "123456789"
ABNotifier.startNotifierWithAPIKey(key, environmentName: ABNotifierAutomaticEnvironment, useSSL: true, delegate: self)
Any ideas?
To fix this error you mentioned in the comment...
error: "This project uses features only available in iOS 4.0 and
later" in their file: GCAlertView.h
I ended up removing this line of code in GCAlertView.h in Airbrake. And it compiles fine. There's already minimum iOS version specified in the app bundle that prevents app installation. So I'd say checking this is pointless anyway.
#import <TargetConditionals.h>
#if TARGET_OS_IPHONE
//#ifndef __IPHONE_4_0 // hlung: this is not working correctly, remove for now
//#error This project uses features only available in iOS 4.0 and later
//#endif
#import <UIKit/UIKit.h>

Resources