Skip to content

Commit 09643c0

Browse files
committed
fixes for RN Firebase conflict
1 parent fcdcb64 commit 09643c0

10 files changed

Lines changed: 487 additions & 72 deletions

BiometricLogin.podspec

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ Pod::Spec.new do |s|
1313
s.platforms = { :ios => min_ios_version_supported }
1414
s.source = { :git => "https://github.com/thang2162/react-native-biometric-login.git", :tag => "#{s.version}" }
1515

16-
s.source_files = "ios/**/*.{h,m,mm,cp,swift}"
16+
# Updated source files to explicitly include Swift file
17+
s.source_files = "ios/**/*.{h,m,mm,cp,swift}", "ios/BiometricLoginImpl.swift"
1718
s.private_header_files = "ios/**/*.h"
1819

19-
# Add header search paths for generated files
20+
# Updated header search paths to include framework headers
2021
s.pod_target_xcconfig = {
21-
'HEADER_SEARCH_PATHS' => '"$(PODS_TARGET_SRCROOT)/ios/generated"',
22+
'HEADER_SEARCH_PATHS' => '"$(PODS_TARGET_SRCROOT)/ios/generated" "$(PODS_CONFIGURATION_BUILD_DIR)/BiometricLogin/BiometricLogin.framework/Headers"',
2223
'SWIFT_VERSION' => '5.0',
2324
'DEFINES_MODULE' => 'YES',
2425
'SWIFT_INSTALL_OBJC_HEADER' => 'YES',
2526
'SWIFT_OBJC_INTERFACE_HEADER_NAME' => 'BiometricLogin-Swift.h'
2627
}
2728

28-
2929
install_modules_dependencies(s)
3030
end

MIGRATION_GUIDE.md

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
# Migration Guide - React Native Biometric Login
2+
3+
## Overview
4+
This guide helps users migrate from older versions of `react-native-biometric-login` to version 2.0.22+ which includes Swift bridging header fixes and React Native 0.81.0+ compatibility.
5+
6+
## Breaking Changes
7+
8+
### React Native Version Requirement
9+
- **Before**: Compatible with React Native 0.70.0+
10+
- **After**: Requires React Native 0.81.0+
11+
12+
### iOS Framework Requirements
13+
- **Before**: Worked with both static and dynamic frameworks
14+
- **After**: Requires dynamic frameworks for Swift bridging header compatibility
15+
16+
## Migration Steps
17+
18+
### Step 1: Update React Native Version
19+
Ensure your project uses React Native 0.81.0+:
20+
21+
```bash
22+
# Check current version
23+
npx react-native --version
24+
25+
# Update if needed (follow React Native upgrade guide)
26+
npx react-native upgrade
27+
```
28+
29+
### Step 2: Update Library Version
30+
```bash
31+
# Using yarn (recommended)
32+
yarn add react-native-biometric-login@latest
33+
34+
# Using npm
35+
npm install react-native-biometric-login@latest
36+
```
37+
38+
### Step 3: Update iOS Configuration
39+
40+
#### Option A: Use Dynamic Frameworks (Recommended)
41+
Update your `ios/Podfile`:
42+
43+
```ruby
44+
# BEFORE (Old configuration)
45+
use_frameworks! :linkage => :static
46+
47+
# AFTER (New configuration)
48+
use_frameworks! :linkage => :dynamic
49+
```
50+
51+
#### Option B: Keep Static Frameworks with Selective Dynamic
52+
If you must keep static frameworks:
53+
54+
```ruby
55+
# Keep static frameworks by default
56+
use_frameworks! :linkage => :static
57+
58+
# Add post-install hook to make BiometricLogin dynamic
59+
post_install do |installer|
60+
installer.pods_project.targets.each do |target|
61+
if target.name == 'BiometricLogin'
62+
target.build_configurations.each do |config|
63+
config.build_settings['MACH_O_TYPE'] = 'mh_dylib'
64+
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
65+
config.build_settings['DEFINES_MODULE'] = 'YES'
66+
config.build_settings['SWIFT_INSTALL_OBJC_HEADER'] = 'YES'
67+
end
68+
end
69+
end
70+
end
71+
```
72+
73+
### Step 4: Clean and Reinstall
74+
```bash
75+
cd ios
76+
rm -rf Pods Podfile.lock build
77+
pod install
78+
```
79+
80+
### Step 5: Update Android Configuration
81+
Ensure your Android project has the React Native Gradle Plugin:
82+
83+
```gradle
84+
// android/settings.gradle
85+
apply from: file("../node_modules/@react-native/gradle-plugin/settings.gradle")
86+
```
87+
88+
```gradle
89+
// android/app/build.gradle
90+
apply from: file("../../node_modules/@react-native/gradle-plugin/libs/react.gradle")
91+
```
92+
93+
## Firebase Projects
94+
95+
### Before Migration
96+
Firebase projects typically used:
97+
```ruby
98+
use_frameworks! :linkage => :static
99+
$RNFirebaseAsStaticFramework = true
100+
```
101+
102+
### After Migration
103+
Update to:
104+
```ruby
105+
use_frameworks! :linkage => :dynamic
106+
$RNFirebaseAsStaticFramework = true
107+
```
108+
109+
Firebase will handle its own static linkage internally while allowing other frameworks to be dynamic.
110+
111+
## Common Migration Issues
112+
113+
### Issue 1: "BiometricLogin-Swift.h file not found"
114+
**Cause**: Still using static frameworks
115+
**Solution**: Switch to dynamic frameworks as shown above
116+
117+
### Issue 2: Build fails with React Native 0.81.0+
118+
**Cause**: Missing React Native Gradle Plugin
119+
**Solution**: Add the plugin configuration shown in Step 5
120+
121+
### Issue 3: Firebase compatibility issues
122+
**Cause**: Framework linkage conflicts
123+
**Solution**: Use the Firebase configuration shown above
124+
125+
## Verification
126+
127+
### iOS
128+
1. Clean build: `cd ios && xcodebuild clean`
129+
2. Install pods: `pod install`
130+
3. Build project in Xcode
131+
132+
### Android
133+
1. Clean build: `cd android && ./gradlew clean`
134+
2. Rebuild: `./gradlew assembleDebug`
135+
136+
## Rollback Plan
137+
138+
If migration causes issues, you can temporarily rollback:
139+
140+
```bash
141+
# Install previous version
142+
yarn add react-native-biometric-login@2.0.21
143+
144+
# Revert Podfile changes
145+
# Revert Android configuration changes
146+
```
147+
148+
**Note**: Rolling back will lose the Swift bridging header fixes and React Native 0.81.0+ compatibility.
149+
150+
## Support
151+
152+
If you encounter migration issues:
153+
154+
1. Check the [Swift Bridging Header Troubleshooting Guide](./SWIFT_BRIDGING_HEADER_TROUBLESHOOTING.md)
155+
2. Review the [Main Troubleshooting Guide](./TROUBLESHOOTING.md)
156+
3. Open an issue with your error logs and environment details
157+
158+
## What's New in 2.0.22+
159+
160+
- ✅ Swift bridging header compatibility fixes
161+
- ✅ React Native 0.81.0+ support
162+
- ✅ Improved Firebase compatibility
163+
- ✅ Better error handling and debugging
164+
- ✅ Enhanced TypeScript definitions
165+
- ✅ TurboModule architecture improvements
166+
167+
## Timeline
168+
169+
- **Immediate**: Update library and iOS configuration
170+
- **Short-term**: Test thoroughly in development
171+
- **Long-term**: Plan for React Native 0.81.0+ upgrade if not already done

README.md

Lines changed: 92 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
22

33
A React Native module that enables biometric authentication and securely stores user credentials using native APIs. This library provides a comprehensive solution for implementing biometric login functionality in React Native applications with support for both iOS and Android platforms.
44

5+
## Table of Contents
6+
7+
- [Features](#features)
8+
- [Installation](#installation)
9+
- [iOS Setup](#ios-setup)
10+
- [Swift Bridging Header Compatibility](#-swift-bridging-header-compatibility)
11+
- [Android Setup](#android-setup)
12+
- [API Reference](#api-reference)
13+
- [Usage](#usage)
14+
- [Troubleshooting](#troubleshooting)
15+
- [Development](#development)
16+
- [Architecture](#architecture)
17+
- [Contributing](#contributing)
18+
- [Code of Conduct](#code-of-conduct)
19+
- [License](#license)
20+
521
## Features
622

723
- 🔐 **Biometric Authentication**: Support for Touch ID, Face ID, and Android biometric sensors
@@ -25,6 +41,10 @@ yarn add react-native-biometric-login
2541
npm install react-native-biometric-login
2642
```
2743

44+
### 🔄 Upgrading from Older Versions?
45+
46+
If you're upgrading from a version before 2.0.22, see the [Migration Guide](./MIGRATION_GUIDE.md) for important changes related to Swift bridging headers and React Native 0.81.0+ compatibility.
47+
2848
### ⚠️ Important: Codegen Configuration
2949

3050
This library uses React Native's new architecture and requires proper codegen configuration in your consuming app. If you encounter build errors related to missing generated sources, please see the [TROUBLESHOOTING.md](./TROUBLESHOOTING.md) guide.
@@ -56,6 +76,54 @@ cd ios && pod install
5676

5777
**💡 Pro tip**: If you're building the example app and encounter Ruby/bundler issues, you may need to run `bundle install` first to install the required Ruby gems for CocoaPods.
5878

79+
### ⚠️ Swift Bridging Header Compatibility
80+
81+
This library contains Swift code that requires proper framework linkage configuration. If you encounter build errors related to missing `BiometricLogin-Swift.h` files, you need to configure your project to use dynamic frameworks.
82+
83+
#### For Projects Using Static Frameworks (e.g., with Firebase)
84+
85+
**Option 1: Use Dynamic Frameworks (Recommended)**
86+
Update your `ios/Podfile`:
87+
88+
```ruby
89+
# Use dynamic frameworks by default for Swift bridging header compatibility
90+
use_frameworks! :linkage => :dynamic
91+
92+
# Firebase configuration - Firebase will handle its own static linkage internally
93+
$RNFirebaseAsStaticFramework = true
94+
```
95+
96+
**Option 2: Selective Dynamic Frameworks**
97+
If you need to keep static frameworks for other reasons, you can configure only BiometricLogin to use dynamic linkage:
98+
99+
```ruby
100+
# Keep static frameworks by default
101+
use_frameworks! :linkage => :static
102+
103+
# Add post-install hook to make BiometricLogin dynamic
104+
post_install do |installer|
105+
installer.pods_project.targets.each do |target|
106+
if target.name == 'BiometricLogin'
107+
target.build_configurations.each do |config|
108+
config.build_settings['MACH_O_TYPE'] = 'mh_dylib'
109+
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
110+
config.build_settings['DEFINES_MODULE'] = 'YES'
111+
config.build_settings['SWIFT_INSTALL_OBJC_HEADER'] = 'YES'
112+
end
113+
end
114+
end
115+
end
116+
```
117+
118+
**Clean Installation Steps**
119+
After making changes to the Podfile:
120+
121+
```bash
122+
cd ios
123+
rm -rf Pods Podfile.lock build
124+
pod install
125+
```
126+
59127
### Android Setup
60128

61129
For Android, ensure you have the following permissions in your `AndroidManifest.xml`:
@@ -152,6 +220,27 @@ See the [example app](./example/src/App.tsx) for a full implementation demonstra
152220

153221
### Common Build Issues
154222

223+
#### iOS Build Issues
224+
225+
For iOS build issues, ensure you have:
226+
- Xcode 15+ installed
227+
- Proper pod installation: `cd ios && pod install`
228+
- Correct deployment target (iOS 13.0+)
229+
230+
**Swift Bridging Header Issues**
231+
If you encounter errors like `"BiometricLogin-Swift.h file not found"`:
232+
233+
1. **Check framework linkage**: Ensure your project uses dynamic frameworks
234+
2. **Clean and reinstall pods**:
235+
```bash
236+
cd ios
237+
rm -rf Pods Podfile.lock build
238+
pod install
239+
```
240+
3. **Verify Podfile configuration**: See the [Swift Bridging Header Compatibility](#-swift-bridging-header-compatibility) section above
241+
242+
📖 **For detailed Swift bridging header troubleshooting, see [SWIFT_BRIDGING_HEADER_TROUBLESHOOTING.md](./SWIFT_BRIDGING_HEADER_TROUBLESHOOTING.md)**
243+
155244
#### Android Build Fails with "Unresolved reference 'NativeBiometricLoginSpec'"
156245

157246
This error occurs when the React Native codegen doesn't properly generate the required spec files. Here's how to fix it:
@@ -197,25 +286,6 @@ This error occurs when the React Native codegen doesn't properly generate the re
197286
}
198287
```
199288

200-
#### iOS Build Issues
201-
202-
For iOS build issues, ensure you have:
203-
- Xcode 15+ installed
204-
- Proper pod installation: `cd ios && pod install`
205-
- Correct deployment target (iOS 13.0+)
206-
207-
### Common Issues & Quick Fixes
208-
209-
#### 🚨 "Library works in example but fails when installed via npm"
210-
211-
This is the most common issue with TurboModules. **Quick fix in 3 steps:**
212-
213-
1. **Add React Native Gradle Plugin** to your `android/build.gradle`
214-
2. **Enable autolinking** in your `android/app/build.gradle`
215-
3. **Force codegen regeneration** with `./gradlew generateCodegenArtifactsFromSchema`
216-
217-
📖 **See [QUICK_FIX.md](./QUICK_FIX.md) for the complete solution**
218-
219289
#### Other Common Errors
220290

221291
- **"Unresolved reference 'NativeBiometricLoginSpec'"** → Missing codegen, run the quick fix above
@@ -235,10 +305,12 @@ If you're still experiencing issues:
235305

236306
- Node.js 18+
237307
- Yarn 3.6.1+
238-
- React Native 0.81.0+
308+
- React Native 0.81.0+ (required for Swift bridging header compatibility)
239309
- Xcode 15+ (for iOS development)
240310
- Android Studio (for Android development)
241311

312+
**Note**: This library requires React Native 0.81.0+ due to Swift bridging header requirements and TurboModule architecture changes.
313+
242314
### Setup
243315

244316
1. Clone the repository:

0 commit comments

Comments
 (0)