ARSessionConfiguration unresolved in Xcode 9 GM - ios

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

Related

Building with Xcode 13 (iOS 15 SDK) is not longer backward compatible with iOS 14.x targets

Just found out that building an app with the new iOS 15 SDK (Xcode 13 RC) is no longer backward compatible with iOS 14.x targets when using CloudKit.
Steps to reproduce:
New project in Xcode 13 RC (check the Core Data + CloudKit options)
Set the iOS deployment target to 14.0
Modify the generated Persistence.swift file and add a private CK store like this:
let cloudStoreDescription = NSPersistentStoreDescription(url: url.appendingPathComponent("(privateCloudStoreName).sqlite"))
cloudStoreDescription.configuration = "privateCkStoreName"
var privateCloudKitContainerOptions = NSPersistentCloudKitContainerOptions(containerIdentifier: "CKIDENTIFIFER")
privateCloudKitContainerOptions.databaseScope = .private
cloudStoreDescription.cloudKitContainerOptions = privateCloudKitContainerOptions
Run on iPhone with iOS 15 -> will work
Download more simulator runtimes and add iOS 14.5
Run on iPhone with iOS 14.5 -> will fail with:
dyld: Library not loaded: /System/Library/Frameworks/_CoreData_CloudKit.framework/_CoreData_CloudKit
Referenced from: /Users/andrei/Library/Developer/CoreSimulator/Devices/8554B734-4894-4DD0-A8FA-6C20983F3A49/data/Containers/Bundle/Application/1317D63A-F14B-4EA2-8F18-8EA623D358AB/testapp.app/testapp
Reason: image not found
How can I mitigate this since next week iOS 15 will be released to the general public?
Reproducible example here.
Feedback assistant id: FB9630276
The solution was in front of my eyes the whole time:
Just remove the following line:
privateCloudKitContainerOptions.databaseScope = .private
Removing that line will have the same effect as the private scope is default and also will remove the need of importing CloudKit.
By doing this, there is no more crash on iOS 14.x
If you want to use the .public scope, according the Apple Frameworks Enginner, the fix is the following:
let options = NSPersistentCloudKitContainerOptions(containerIdentifier: id)
options.setValue(1, forKey: "databaseScope") // .public == 1 // options.databaseScope = CKDatabase.Scope.public
description.cloudKitContainerOptions = options

Use of undeclared type 'XCTestCaseEntry'

Hi I can't seem to figure out why I am Use of undeclared type 'XCTestCaseEntry'
when using the following code in my .xctest:
import XCTest
#if !os(macOS)
public func allTests() -> [XCTestCaseEntry] {
return [
testCase(TrakkproTests.allTests),
]
}
#endif
I just ran into the same issue while attempting to run unit tests for a custom framework I've built using the Swift Package Manager.
It turned out I had accidentally selected an iOS simulator in the Xcode scheme/device selector:
This compiled the code for iOS which satisfies the compilation condition of !os(macOS) and causes the error to occur. XCTestCaseEntry appears to be part of the swift-corelibs-xctest project which provides XCTest functionality to non-Apple platforms (i.e. linux) but is not the same implementation Apple uses... I think.
The solution for me was to select "My Mac" in the scheme/device selector:
looks like the typealias XCTestCaseEntry is added as part of the commit https://github.com/apple/swift-corelibs-xctest/commit/1c7fb283231ce53960a232aa7c771bb2d38dee62 on oct 2017.
I don't think the XCTestCase class as part of the XCode/XCTest has this change yet. Where are you checking this anyway ?

NSAttributedStringKey.attachment versus NSAttachmentAttributeName

I'm having problems with NSAttributedStringKey.attachment versus NSAttachmentAttributeName. Here's the relevant code:
var key: Any?
if #available(iOS 11, *) {
key = NSAttributedStringKey.attachment
}
else {
key = NSAttachmentAttributeName
}
One of two things are happening. In the actual place where I'm trying to use this code (a Cococapod of my own design, with a deployment target of iOS 8 and now building with Xcode 9), I get an error:
Type 'NSAttributedStringKey' (aka 'NSString') has no member 'attachment'
Or, if I just make a new example project and set the deployment target at iOS 8, I get:
'NSAttachmentAttributeName' has been renamed to 'NSAttributedStringKey.attachment'
This is not the behavior I'd expect with #available. Thoughts?
This String vs struct difference is between Swift 3 (uses Strings such as NSAttachmentAttributeName) and Swift 4 (uses struct static attributes such as NSAttributedStringKey.attachment), not between iOS <11 and iOS >=11. For instance, you can use NSAttributedStringKey.attachment and similar in any supporting version of iOS (e.g. .attachment is available since iOS 7) within a Swift 4 project. #available doesn't apply because it's a Swift language version difference rather than an OS version difference.
Ensure your pod is set to the correct Swift version and it should then work as expected. You can tell CocoaPods that by adding a .swift-version file at the top of your project:
$ echo 4.0 >.swift-version
This magical version file is mentioned in passing in a CocoaPods blog post from last year: http://blog.cocoapods.org/CocoaPods-1.1.0/

suddenly UIUserNotificationActionResponseTypedTextKey is unavailable

I don't understand this. Suddenly, I couldn't use the in iOS 9.0 introduced UIUserNotificationActionResponseTypedTextKey identifier for accessing text input messages in notifications. Xcode 7.1 says: "UIUserNotificationActionResponseTypedTextKey is unavailable".
But I can see this value in UIUserNotificationeSettings.h.
In Watchos2.0 I have this value.
Any Ideas?
I'm seeing the same exact thing in the release version of Xcode 7.2. Instead of using the key UIUserNotificationActionResponseTypedTextKey, I've gotten it working using the string version "UIUserNotificationActionResponseTypedTextKey".
So for me this is doing the trick:
if let response = responseInfo["UIUserNotificationActionResponseTypedTextKey"] as? String {
// Your code here
}

"dyld: Symbol not found:" for iOS 6-exclusive class in Static Library

NOTE: Yes, I know iOS 6 is under NDA. This question has nothing to do with iOS 6, expect for the fact that the class that I'm referencing is new in iOS 6.
I'm creating a static framework for use in several of my projects, which allows me to use a new API in iOS 6 if it's available, and if it's not it'll fall back to an iOS 5 equivalent. However, although I make sure to always check if a class is valid before using it like so:
if ([NewClass class]) {
NewClass *newClass = [[NewClass alloc] init];
// etc.
}
Whenever I launch my app in the iOS 5 Simulator, I get the following error:
dyld: Symbol not found: _OBJC_CLASS_$_NewClass
(where NewClass stands for the iOS 6 class).
This seems to be an issue just with using a static library, as if I include the certain files that reference the API directly in my project and reference them, it will launch with no issues. I've even tried weak-linking the static library, and it still crashes. The only option that works is weak-linking UIKit, but I would prefer to not have to do that due to UIKit being quite a large framework, and weak-linking takes extra time.
So basically, what can I do to weak link this class in the static library itself?
I guess your IPHONEOS_DEPLOYMENT_TARGET is not set to iOS 5? I just had the same error, because it was already on iOS 6. After setting it to iOS 5, everything was fine.
You can find the configuration both under Target->BuildSettings->IPHONEOS_DEPLOYMENT_TARGET and under Target->Summary->iOS Application Target.
Another approach to avoid this kind of error would be this:
Class myClass = NSClassFromString(#"NewClass")
if( myClass ) {
NSObject *myResult = [myClass aMethod:#"Hello World"];
}

Resources