microsoft-authentication-library-for-objc
CLAUDE.md347 starsChanged 12 months agoMITView on GitHub
This is the Microsoft Authentication Library (MSAL) for iOS and macOS - an authentication SDK for integrating Microsoft identity platform authentication into native Apple applications. The library supports OAuth2/OpenID Connect protocols for Microsoft Entra ID (workforce), External ID (customers), Azure AD B2C, and personal Microsoft accounts. Public headers MUST be in: Unit Tests: Located in MSAL/test/unit/ Integration Tests: Located in MSAL/test/integration/ Automation Tests: Located in MSAL/test/automation/ (requires conf.json - not in repo) Running Tests: In interactive sessions on a developer's…
We split this CLAUDE.md into the rules it gives an agent
18 rules. About 0 are common, 10 are distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈10
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 84
Error handling: Check return value, NEVER the error variable directly
- Very specific: line 86
Properties over ivars: Use @property declarations
- Distinctive: line 88
Comments: Only comment non-obvious rationale.
- Very specific: line 112
Add header to appropriate MSAL/src/public/ subdirectory
- Very specific: line 113
Import in MSAL/src/public/MSAL.h umbrella header
- Very specific: line 114
Update MSAL.podspec if needed (public_header_files)
- Very specific: line 115
Add to MSAL/module.modulemap if using native auth subspec
- Distinctive: line 116
Document in header comments (Jazzy-compatible)
- Distinctive: line 122
Test both Debug and Release configurations
- Distinctive: line 126
Internal: Avoid. This library should be self-contained.
- Very specific: line 132
Update submodule reference: cd MSAL/IdentityCore && git checkout <commit>
- Distinctive: line 133
Commit submodule update in MSAL repo
- Distinctive: line 134
Test thoroughly - affects BOTH MSAL and ADAL
- Distinctive: line 149
Only search for additional information if:
- Very specific: line 158
Check .clinerules/*.md for code style specifics, API usage, configuration steps and feature flag guidance.
- Distinctive: line 159
Check README.md for user-facing documentation
- Very specific: line 160
Check CHANGELOG.md for version history and breaking changes
- Distinctive: line 161
Check specific xcconfig files for build settings
≈ “Common” is an estimate: at least 1 in 5 of the 25,680 CLAUDE.md 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
Claude Instructions for MSAL iOS/macOS
Repository Overview
This is the Microsoft Authentication Library (MSAL) for iOS and macOS - an authentication SDK for integrating Microsoft identity platform authentication into native Apple applications. The library supports OAuth2/OpenID Connect protocols for Microsoft Entra ID (workforce), External ID (customers), Azure AD B2C, and personal Microsoft accounts.
Key Facts:
- Languages: Objective-C (primary), Swift (native auth APIs)
- Platforms: iOS 16+, macOS 11+, visionOS 1.2+
- Distribution: CocoaPods, Carthage, Swift Package Manager, Git submodule
- Submodule:
MSAL/IdentityCorecontains shared common code (do NOT make direct changes without understanding impact)
Critical: Architecture & Project Structure
Main Workspace & Targets
- Workspace:
MSAL.xcworkspace(ALWAYS use .xcworkspace, NEVER .xcodeproj directly) - Main Project:
MSAL/MSAL.xcodeproj - Submodule:
MSAL/IdentityCore- shared common library (git submodule)
Source Code Organization
MSAL/src/
├── public/ # Public API headers (MSAL prefix)
│ ├── MSAL.h # Main umbrella header
│ ├── ios/ # iOS-specific public headers
│ ├── mac/ # macOS-specific public headers
│ ├── configuration/ # Configuration classes
│ └── native_auth/public/ # Native auth public APIs (Swift)
├── MSALPublicClientApplication.m # Main SDK entry point
├── configuration/ # Internal configuration
├── instance/ # Authority/instance handling
├── native_auth/ # Native authentication (Swift + Obj-C bridge)
├── telemetry/ # Telemetry implementation
└── util/ # UtilitiesPublic API Files
Public headers MUST be in:
MSAL/src/public/*.h(shared)MSAL/src/public/ios/*.h(iOS only)MSAL/src/public/mac/*.h(macOS only)MSAL/src/public/configuration/*.h(config classes)MSAL/src/native_auth/public/(native auth - Swift)
Configuration Files
- Build configs:
MSAL/xcconfig/*.xcconfig- Xcode build settings - Swift lint:
MSAL/.swiftlint.yml- only applies tosrc/native_auth - CocoaPods:
MSAL.podspec- pod spec withapp-libandnative-authsubspecs - Swift PM:
Package.swift- binary framework distribution - Privacy:
MSAL/PrivacyInfo.xcprivacy- Apple privacy manifest
Testing
Unit Tests: Located in MSAL/test/unit/
Integration Tests: Located in MSAL/test/integration/
Automation Tests: Located in MSAL/test/automation/ (requires conf.json - not in repo)
Running Tests:
- Via Xcode: Select scheme and Cmd+U
- E2E tests require test configuration from Azure KeyVault (CI only)
AI Agent Build Safety
In interactive sessions on a developer's Mac, AI agents MUST NOT invoke build.py, xcodebuild, simctl, or any command that starts an Xcode build, test, or simulator. Ask the user to run the relevant scheme from MSAL.xcworkspace in Xcode and report the result instead.
If the user explicitly requests a local CLI command instead of using Xcode, require exactly one build.py --targets <target> value and prefer --no-clean for incremental validation. Never suggest bare ./build.py, multiple targets, concurrent/background builds, or ad-hoc xcodebuild commands for a developer's Mac. CI may continue using its repository-defined full validation matrix.
Code Style Guidelines
READ: .clinerules/04-Code-style-guidelines.md - Contains mandatory Objective-C style rules
Key Rules (Repository-Specific):
- Opening braces on NEW line (differs from most Obj-C guides)
- 4-space indentation (never tabs)
- Imports NOT grouped - list without organizing comments
- Error handling: Check return value, NEVER the error variable directly
- Prefixes:
MSALfor public classes,MSIDfor IdentityCore internal - Properties over ivars: Use
@propertydeclarations - Swift lint: Native auth code must pass SwiftLint (line length: 150)
- Comments: Only comment non-obvious rationale. Don't add comments that explain what the code already explains.
Example:
- (BOOL)performOperationWithError:(NSError **)error
{
NSError *internalError = nil;
BOOL result = [self doSomethingWithError:&internalError];
if (!result) // Check return value, not error
{
if (error) *error = internalError;
return NO;
}
return YES;
}Making Changes
Adding New Public API
- Add header to appropriate
MSAL/src/public/subdirectory - Import in
MSAL/src/public/MSAL.humbrella header - Update
MSAL.podspecif needed (public_header_files) - Add to
MSAL/module.modulemapif using native auth subspec - Document in header comments (Jazzy-compatible)
Modifying Build Settings
- Edit appropriate
.xcconfigfile inMSAL/xcconfig/ - Settings cascade: specific → platform → common
- Test both Debug and Release configurations
Adding Dependencies
Internal: Avoid. This library should be self-contained. External (IdentityCore): Coordinate with common library team.
Modifying IdentityCore Submodule
- Make changes in IdentityCore repo separately
- Update submodule reference:
cd MSAL/IdentityCore && git checkout <commit> - Commit submodule update in MSAL repo
- Test thoroughly - affects BOTH MSAL and ADAL
Key Files to Never Modify
MSAL/IdentityCore/- managed as submodulePackage.swift- auto-generated by release processMSAL.zip- binary distribution artifactbuild/- build artifacts directory.xcuserdata/- user-specific Xcode settings
Trust These Instructions
These instructions have been validated against the actual build system, CI pipelines, and codebase structure. If you encounter conflicts between these instructions and other information:
- Trust these instructions FIRST
- Only search for additional information if:
- Instructions are incomplete for your specific task
- You encounter an error not covered here
- You need API usage examples (see
.clinerules/03-MSAL-API-usage.mdfor MSAL API samples) - You need to create a new application with MSAL authentication (see
.clinerules/AGENTS.mdfor details about the different options the user can select) - You are implementing a new feature in MSAL library, it needs to be guarded by a feature flag (see
.clinerules/05-feature-gating.mdfor guidelines)
When searching:
- Check
.clinerules/*.mdfor code style specifics, API usage, configuration steps and feature flag guidance. - Check
README.mdfor user-facing documentation - Check
CHANGELOG.mdfor version history and breaking changes - Check specific xcconfig files for build settings
In this repository4 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .clinerules/AGENTS.mdAGENTS.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/ruler_cursor_instructions.mdcCursor rule
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
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.

