An Expo Config Plugin that allows you to set specific iOS libraries to use static build type. This helps resolve issues with dynamic library dependencies in your iOS builds.
| Expo SDK | Supported |
|---|---|
| 54 | Yes |
| 53 | Yes |
| 52 | Yes |
| < 52 | No |
npm install expo-plugin-ios-static-libraries
# or
yarn add expo-plugin-ios-static-libraries
# or
bun add expo-plugin-ios-static-librariesAdd the plugin to your app.json or app.config.js:
For simple cases where modular headers are not needed:
{
"name": "my-app",
"expo": {
"plugins": [
[
"expo-plugin-ios-static-libraries",
{
"libraries": ["LibraryName", "AnotherLibraryName"]
}
]
]
}
}For Swift-based pods (like Firebase), you may need to enable modular headers to avoid '*-Swift.h' file not found errors:
{
"name": "my-app",
"expo": {
"plugins": [
[
"expo-plugin-ios-static-libraries",
{
"libraries": [
"BleManager",
{ "name": "Firebase", "modularHeaders": true },
{ "name": "FirebaseAuth", "modularHeaders": true },
{ "name": "GTMSessionFetcher", "modularHeaders": true }
]
}
]
]
}
}Enable modularHeaders: true when you see errors like:
'FirebaseAuth/FirebaseAuth-Swift.h' file not foundInclude of non-modular header inside framework module- Swift bridging header errors
Not all pods need modular headers. Only enable it for pods that:
- Are written in Swift, or
- Have Swift dependencies, or
- Show module-related build errors
Here's an example of how to set React-Native-BLE-PLX, react-native-permissions, and @op-engineering/op-sqlite to use static libraries:
{
"name": "my-app",
"expo": {
"plugins": [
[
"expo-plugin-ios-static-libraries",
{
"libraries": ["BleManager", "RNPermissions", "op-sqlite"]
}
]
]
}
}This plugin uses Expo Config Plugins to modify the Podfile during the build process. It adds a pre_install hook that:
- Sets static library build type for specified libraries
- Enables modular headers for libraries that need them (using CocoaPods'
set_use_modular_headers_for_podAPI)
The generated code looks like:
pre_install do |installer|
# Enable modular headers for Swift compatibility
['Firebase', 'FirebaseAuth'].each do |lib_name|
installer.podfile.target_definitions.each do |name, target_def|
target_def.set_use_modular_headers_for_pod(lib_name, true)
end
end
# Set static library build type
installer.pod_targets.each do |pod|
if pod.name.eql?('BleManager') || pod.name.eql?('Firebase') || pod.name.eql?('FirebaseAuth')
def pod.build_type
Pod::BuildType.static_library
end
end
end
endThis forces CocoaPods to build the specified libraries as static libraries instead of dynamic frameworks, which can help resolve dependency issues in some cases.
If you see errors like 'SomePod/SomePod-Swift.h' file not found, try enabling modular headers for that pod:
{ "name": "SomePod", "modularHeaders": true }If enabling modular headers causes gRPC-related errors, ensure you're only enabling modular headers for the specific pods that need it, not globally.
MIT