I have developed iOS application using Swift 2.3. and I have put the application to the app store in review process, apparently they have rejected it due to crash in iOS 10 .
Then in order to fix it I have downloaded the Xcode 8 and tried to build the app without converting code in to swift 3 using legacy setting
But I couldn't build the app. There was few compile errors in pods that I have used. (Alamofire framework)
error :- and there will more
private func trustIsValid(trust: SecTrust) -> Bool {
var isValid = false
var result = SecTrustResultType(kSecTrustResultInvalid)
let status = SecTrustEvaluate(trust, &result)
if status == errSecSuccess {
let unspecified = SecTrustResultType(kSecTrustResultUnspecified)
let proceed = SecTrustResultType(kSecTrustResultProceed)
isValid = result == unspecified || result == proceed
}
return isValid
}
So I did a small digging apparently Alamofire has released a new version for Xcode 8 so i have put that version, apparently I can't integrate that version in to my source code since it's in Swift 2.3.
Can someone help me to get over with this issue, problem was I can't release the app to App store since there is a crash in iOS 10 and I can't check it since I don't have iOS 10.
Related
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
My App is using CoreLocation and CLLocationManager and is working fine in iOS 13 and iOS 12.
I have implemented new feature of Precise Location in iOS 14 using Xcode 12 and its working fine in iOS 14, iOS 13, iOS 12.
But When I execute ths Xcode 12 code in Xcode 11 version (Xcode 11.7) then I am getting error
Cannot infer contextual base in reference to member 'reducedAccuracy'
Value of type 'CLLocationManager' has no member 'accuracyAuthorization'
if #available(iOS 14.0, *) {
if authorizationStatus.accessLevel == .granted && locationManager.accuracyAuthorization == .reducedAccuracy {
return .locationAlwaysAllowPreciseLocationOff
}
if authorizationStatus.accessLevel == .denied && locationManager.accuracyAuthorization == .fullAccuracy {
return .locationDeniedPreciseLocationON
}
}
// MARK: iOS 14 location function.
#available(iOS 14.0, *)
func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {
// iOS 14 Location Delegate method, not available in iOS 13 version
}
and here the error is
Static member 'authorizationStatus' cannot be used on instance of type 'CLLocationManager'
As i Know Precise Location is feature of iOS 14 and its not available in below versions and "accuracyAuthorization", ".reducedAccuracy", ".fullAccuracy" is not available in iOS 13 versions.
My Question is how can i make my code run in Xcode 11 versions. I have already added the isAvailable check to check the device version.
Thanks in advance :)
No amount of #available or #available marking is going to help you in this situation.
Why not? Well, you're doing an unexpected thing: you are opening an Xcode 12 project in Xcode 11. Your code was compiled originally in Xcode 12, where iOS 14 is a thing. So it compiled successfully. But now you open the same project in Xcode 11, where iOS 14 is not a thing. Nothing about this environment has the slightest idea that it exists. Therefore, code that involves something unique to iOS 14 will not compile. If the compiler sees that code, you are toast.
So is all hope lost? Not quite! Suppose we were to hide the code from the compiler. If we do that — if we can arrange things so that, in Xcode 11, the compiler never sees this code at all — then we will be able to compile in Xcode 11.
Well, we can do that! We can use a compilation condition. All we need is some condition that we are allowed to check against, that will distinguish what version of Xcode this is. And there is such a condition — the Swift version.
So, we can write this, for example:
class ViewController: UIViewController {
let manager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
#if swift(>=5.3)
let status = manager.authorizationStatus
print(status.rawValue)
#endif
}
}
That code compiles in both Xcode 12 and Xcode 11, because in Xcode 11 the compilation condition fails, and the compiler never even looks inside the #if block.
In fact, we can provide an alternative version of the code, to be used in Xcode 11. In order to make this work as we desire, we will also have to restore your #available check, because we have to make the project's deployment target iOS 13, and the Xcode 12 compiler will complain if we don't protect the iOS 14 code:
class ViewController: UIViewController {
let manager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
#if swift(>=5.3)
if #available(iOS 14.0, *) {
let status = manager.authorizationStatus
print(status.rawValue)
}
#else
let status = CLLocationManager.authorizationStatus()
print(status.rawValue)
#endif
}
}
That code compiles and behaves correctly in either Xcode 11 or Xcode 12. Do you understand why? Let's review, because it's a bit tricky.
In Xcode 11, the whole #if section is never seen by the compiler. It sees only this:
let status = CLLocationManager.authorizationStatus()
print(status.rawValue)
That's good iOS 13 code, so all is well.
In Xcode 12, the whole #else section is never seen by the compiler. It sees only this:
if #available(iOS 14.0, *) {
let status = manager.authorizationStatus
print(status.rawValue)
}
That's good iOS 14 code, because, even though our project's deployment target is iOS 13, we have calmed the compiler's nerves by guaranteeing that this code won't execute in iOS 13 (where it would crash if it did execute).
Having said all that, the real answer is: don't. Everything I just did is way too much trouble! Once you've written code under Xcode 12, don't try to open that project in Xcode 11. That's not the way to test for backward compatibility.
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
On the previous version of xcode ( Xcode 8 beta 6 ) , my app running fine without errors. I updated xcode this morning, I run my app and now, I have 400 errors !
Pods installed not working and on my code all is on red !
I'm a bit frustrated to have made an update and this has resulted to demolish my application.
How can I resolve my situation ?
Example of code not working now :
if UserDefaults.standard.string(forKey: "token") != nil => Use of unresolved identifier
if( CLLocationManager.authorizationStatus() == CLAuthorizationStatus.authorizedWhenInUse => Type CLAuthorizationStatus has no member authorizedWhenInUse
No luck, I had to quickly add an update that corrects a version of the app store that crash at startup ...
The newest version of Xcode, Xcode 8 beta or Xcode 8 GM seed, runs on an updated and swifter version of Swift. Likely your errors are because your command strings are now too long. If you cannot convert the files, you may need to go in and edit each command line. Refer to the release notes for the newest version of Xcode you have to find these new statements.
Example:
// old code (Swift 2.2)
let content = text.stringByTrimmingCharactersInSet(NSCharacterSet.newlineCharacterSet())
// new code (Swift 3.0)
let content2 = text.trimmingCharacters(in: .newlines)
resource:
https://developer.apple.com/swift/
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
}