A modern SwiftUI login interface with support for traditional email/password authentication, Gmail, and Hotmail/Outlook sign-in.
- Clean and modern UI design
- Email/Password authentication
- Gmail OAuth integration (placeholder)
- Hotmail/Outlook OAuth integration (placeholder)
- Form validation
- Loading states
- Error handling
- Responsive design
Sources/
├── LoginApp.swift # Main app entry point
├── Models/
│ └── User.swift # User data model
├── ViewModels/
│ └── AuthenticationViewModel.swift # Authentication logic
└── Views/
├── ContentView.swift # Root view with auth state management
└── LoginView.swift # Login UI
- Open the project in Xcode
- Build and run on iOS 15.0 or later
To enable Gmail sign-in:
-
Add Google Sign-In SDK:
- Add package dependency:
https://github.com/google/GoogleSignIn-iOS
- Add package dependency:
-
Configure Google Cloud Console:
- Create a project at Google Cloud Console
- Enable Google Sign-In API
- Create OAuth 2.0 client ID (iOS)
- Note your client ID
-
Update Info.plist:
<key>GIDClientID</key> <string>YOUR_CLIENT_ID_HERE</string> <key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleURLSchemes</key> <array> <string>com.googleusercontent.apps.YOUR_CLIENT_ID</string> </array> </dict> </array>
-
Update AuthenticationViewModel.swift:
- Uncomment the Google Sign-In implementation code
- Import GoogleSignIn framework
To enable Hotmail/Outlook sign-in:
-
Add Microsoft Authentication Library (MSAL):
- Add package dependency:
https://github.com/AzureAD/microsoft-authentication-library-for-objc
- Add package dependency:
-
Register App in Azure Portal:
- Go to Azure Portal
- Register a new application
- Add iOS platform
- Configure redirect URI:
msauth.[BUNDLE_ID]://auth - Note your Application (client) ID
-
Update Info.plist:
<key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleURLSchemes</key> <array> <string>msauth.[BUNDLE_ID]</string> </array> </dict> </array> <key>LSApplicationQueriesSchemes</key> <array> <string>msauthv2</string> <string>msauthv3</string> </array>
-
Update AuthenticationViewModel.swift:
- Uncomment the MSAL implementation code
- Import MSAL framework
The current implementation includes:
- Fully functional UI components
- Mock authentication for demonstration
- Proper state management
- Error handling framework
The OAuth integrations are prepared with placeholder code and detailed TODO comments for actual implementation.
For testing purposes, use:
- Email: Any email containing "test"
- Password: Any password with 6+ characters
- iOS 15.0+
- Xcode 14.0+
- Swift 5.7+
- Implement actual backend authentication API
- Add Google Sign-In SDK and configure OAuth
- Add Microsoft MSAL and configure Azure AD
- Add secure token storage (Keychain)
- Implement password reset functionality
- Add biometric authentication (Face ID/Touch ID)
- Add sign-up flow
This is a sample project for demonstration purposes.