apple-signin
Skill4 starsChanged 6 months agoMITView on GitHub
Use when implementing Apple Sign-In. Covers entitlement setup, AuthenticationServices framework, SwiftUI SignInWithAppleButton, and credential state checking.
In this repository76 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/components.mdcCursor rule
- .cursor/rules/currency.mdcCursor rule
- .cursor/rules/design-system.mdcCursor rule
- .cursor/rules/file-structure.mdcCursor rule
- .cursor/rules/forbidden-patterns.mdcCursor rule
- .cursor/rules/mvvm-architecture.mdcCursor rule
- .cursor/rules/pricing-display.mdcCursor rule
- .cursor/rules/scope.mdcCursor rule
- .cursor/rules/swift-conventions.mdcCursor rule
- accessibilitySkill
- animationsSkill
- apple-developer-authSkill
- app-store-preflightSkill
- asc-app-create-uiSkill
- asc-aso-auditSkill
- asc-build-lifecycleSkill
- asc-cli-usageSkill
- asc-crash-triageSkill
- asc-id-resolverSkill
- asc-localize-metadataSkill
- asc-metadata-syncSkill
- asc-metadata-yamlSkill
- asc-notarizationSkill
- asc-ppp-pricingSkill
- asc-release-flowSkill
- asc-revenuecat-catalog-syncSkill
- asc-screenshot-resizeSkill
- asc-shots-pipelineSkill
- asc-signing-setupSkill
- ascSkill
- asc-submission-healthSkill
- asc-subscription-localizationSkill
- asc-testflight-orchestrationSkill
- asc-wall-submitSkill
- asc-whats-new-writerSkill
- asc-workflowSkill
- asc-xcode-buildSkill
- billing-finance-calculatorSkill
- buildSkill
- business-modelSkill
- chartsSkill
- consolidate-errorsSkill
- content-composerSkill
- crashSkill
- debuggingSkill
- feature-directory-structureSkill
- feedback-statesSkill
- fix-errorSkill
- formsSkill
- foundation-modelsSkill
- hapticsSkill
- healthkitSkill
- layoutSkill
- listsSkill
- navigationSkill
- notificationsSkill
- onboarding-questionnaireSkill
- onboardingSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 99
Call this in your app's .task or AppDelegate.didFinishLaunching.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Apple Sign-In
Implement Sign in with Apple using the native AuthenticationServices framework.
Step 1: Add Entitlement
Via xcodegen MCP:
mcp__xcodegen__add_entitlement with:
key: "com.apple.developer.applesignin"
value: ["Default"]Step 2: Add Capability in Developer Portal
- Go to developer.apple.com/account
- Certificates, Identifiers & Profiles → Identifiers
- Select your App ID
- Enable "Sign In with Apple" capability
Step 3: SwiftUI Sign-In Button
import AuthenticationServices
struct SignInView: View {
var body: some View {
SignInWithAppleButton(.signIn) { request in
request.requestedScopes = [.fullName, .email]
} onCompletion: { result in
switch result {
case .success(let authorization):
handleAuthorization(authorization)
case .failure(let error):
handleError(error)
}
}
.signInWithAppleButtonStyle(.black)
.frame(height: 50)
.clipShape(.rect(cornerRadius: AppTheme.Style.cornerRadius))
.padding(.horizontal, AppTheme.Spacing.md)
}
private func handleAuthorization(_ authorization: ASAuthorization) {
guard let credential = authorization.credential as? ASAuthorizationAppleIDCredential else {
return
}
let userID = credential.user
let identityToken = credential.identityToken
let email = credential.email // Only on first sign-in
let fullName = credential.fullName // Only on first sign-in
// Store userID in Keychain for future credential checks
// Send identityToken to your configured auth service if needed
}
private func handleError(_ error: Error) {
// Handle ASAuthorizationError
// .canceled — user dismissed
// .failed — authorization failed
// .invalidResponse — invalid response
// .notHandled — not handled
}
}Step 4: Check Credential State on Launch
func checkAppleSignInCredentialState() async {
let provider = ASAuthorizationAppleIDProvider()
do {
let state = try await provider.credentialState(forUserID: storedUserID)
switch state {
case .authorized:
// User is still signed in
break
case .revoked:
// User revoked — sign out locally
break
case .notFound:
// No credential found — show sign-in
break
default:
break
}
} catch {
// Handle error
}
}Call this in your app's .task or AppDelegate.didFinishLaunching.
Step 5: AuthService Pattern
import AuthenticationServices
@MainActor @Observable
final class AuthService {
var isSignedIn = false
var userID: String?
func signInWithApple(credential: ASAuthorizationAppleIDCredential) {
userID = credential.user
isSignedIn = true
// Store userID in Keychain
}
func checkCredentialState() async {
guard let userID else { return }
let provider = ASAuthorizationAppleIDProvider()
let state = try? await provider.credentialState(forUserID: userID)
isSignedIn = (state == .authorized)
}
func signOut() {
userID = nil
isSignedIn = false
// Remove from Keychain
}
}Notes
- Email and full name are only provided on the FIRST sign-in. Store them immediately.
- The
useridentifier is stable across sign-ins. Use it as the primary key. - For an external auth service, send the
identityTokenonly to that configured service. - Apple requires the sign-in button to follow their Human Interface Guidelines.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

