Skip to content

[Valet 4.0] Adopt Swift 5 syntax, and enable support for SinglePromptSecureEnclaveValet on tvOS#191

Merged
dfed merged 2 commits intodevelop--4.0from
dfed--swift-5
Dec 31, 2019
Merged

[Valet 4.0] Adopt Swift 5 syntax, and enable support for SinglePromptSecureEnclaveValet on tvOS#191
dfed merged 2 commits intodevelop--4.0from
dfed--swift-5

Conversation

@dfed
Copy link
Copy Markdown
Collaborator

@dfed dfed commented Dec 22, 2019

Built on top of #190. This PR leans into Swift 5 syntax, and utilizes #canImport to bring SinglePromptSecureEnclaveValet to tvOS

import Foundation


@available(macOS 10.11, *)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our minimum supported target on macOS is macOS 10.11. So there is no need to specify availability in this case.

//

#if os(iOS) || os(macOS)
#if canImport(LocalAuthentication)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we're no longer supporting Xcode 9, we can use canImport to enable SinglePromptSecureEnclaveValet on tvOS 10+.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need the @available(tvOS 10.0, *) given the canImport here?

Copy link
Copy Markdown
Collaborator Author

@dfed dfed Dec 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. If I get rid of it we get build failures 🙂. Here's my understanding as to why:

  1. #if canImport is a compiler flag that enables a class for compilation in the case where the SDK has access to the library in question.
  2. @available is a SDK flag that makes a class as available on particular OS versions.

As such, when we're targeting a tvOS SDK on Xcode 11, LocalAuthentication can always be imported because Xcode 11's SDK has LocalAuthentication on tvOS. We still need to limit the availability of the class that is now bundled in our tvOS library to ensure there are no crashes when running this code on tvOS 9.

@dfed dfed mentioned this pull request Dec 22, 2019
10 tasks
@dfed dfed changed the title Adopt Swift 5 syntax, and enable support for SinglePromptSecureEnclaveValet on tvOS [Valet 4.0] Adopt Swift 5 syntax, and enable support for SinglePromptSecureEnclaveValet on tvOS Dec 22, 2019
@dfed dfed force-pushed the dfed--swift-5 branch 3 times, most recently from a1c30ff to 15935a3 Compare December 22, 2019 17:38
@dfed dfed marked this pull request as ready for review December 22, 2019 18:31
@dfed dfed force-pushed the dfed--simplify-ci-v4 branch from 921aa52 to f087d9e Compare December 23, 2019 00:14
@dfed dfed force-pushed the dfed--simplify-ci-v4 branch from f087d9e to e9848e0 Compare December 23, 2019 20:07
@dfed dfed force-pushed the dfed--swift-5 branch 2 times, most recently from 3d77f73 to 6c8e49b Compare December 23, 2019 20:32
@dfed dfed changed the base branch from dfed--simplify-ci-v4 to develop--4.0 December 24, 2019 03:28
@dfed dfed force-pushed the dfed--swift-5 branch 2 times, most recently from be69dc7 to 339a27d Compare December 24, 2019 22:05
//

#if os(iOS) || os(macOS)
#if canImport(LocalAuthentication)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need the @available(tvOS 10.0, *) given the canImport here?

return valet
CloudAccessibility.allValues().map { cloudAccessibility in
shared ? .iCloudSharedAccessGroupValet(with: identifier, accessibility: cloudAccessibility) : .iCloudValet(with: identifier, accessibility: cloudAccessibility)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: no newline here

@dfed dfed merged commit 90d7a3b into develop--4.0 Dec 31, 2019
@dfed dfed deleted the dfed--swift-5 branch December 31, 2019 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants