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)
- Workspace:
MSAL.xcworkspace(ALWAYS use .xcworkspace, NEVER .xcodeproj directly) - Main Project:
MSAL/MSAL.xcodeproj - Submodule:
MSAL/IdentityCore- shared common library (git submodule)
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/ # Utilities
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)
- 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
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)
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)
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;
}- 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)
- Edit appropriate
.xcconfigfile inMSAL/xcconfig/ - Settings cascade: specific → platform → common
- Test both Debug and Release configurations
Internal: Avoid. This library should be self-contained. External (IdentityCore): Coordinate with common library team.
- 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
MSAL/IdentityCore/- managed as submodulePackage.swift- auto-generated by release processMSAL.zip- binary distribution artifactbuild/- build artifacts directory.xcuserdata/- user-specific Xcode settings
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