[BUG]
BUG: Superwall iOS Crash with Uncaught Exception 'NSInvalidArgumentException'
In this article, we will delve into a critical issue affecting the Superwall iOS library, resulting in an uncaught exception 'NSInvalidArgumentException' when attempting to configure the API key. This bug has significant implications for developers utilizing Superwall in their applications, potentially leading to crashes and a poor user experience.
Before we proceed, let's ensure we have followed the standard checklist for reporting new issues:
- We have reviewed the official
README
and documentation for Superwall. - We have searched existing issues on the Superwall GitHub repository to confirm this is not a duplicate.
- We have attempted to reproduce the issue and include an example project.
To provide a comprehensive understanding of the issue, we need to gather some essential information:
- Superwall version: We are using the latest version of Superwall.
- iOS version(s): The issue is reproducible on iOS 18.3.1.
- CocoaPods/Carthage version (if applicable): We are using the latest version of CocoaPods.
- Xcode version: We are using Xcode 16.2.
- Devices/Simulators affected: The issue affects all devices and simulators.
- Reproducible in the demo project? (Yes/No): Unfortunately, we are unsure if the issue is reproducible in the demo project.
The issue arises when attempting to configure the Superwall API key using the Superwall.configure(apiKey: APIKeys.superwallKey)
method. This results in an uncaught exception 'NSInvalidArgumentException' with the reason '-[__NSDictionaryM length]'.
Upon further investigation, it appears that SuperwallKit is pushing an NSDictionary
into WebKit, where it expects a String
. This discrepancy in data types is likely the root cause of the issue.
To reproduce the issue, follow these steps:
- Create a new Swift project in Xcode.
- Add the Superwall library to your project using CocoaPods or Carthage.
- In your
App
struct, add the Superwall initializer:
init() Superwall.configure(apiKey
4. Run the build in the simulator.
**Other Information**
=====================
To provide further context, we have included two images that demonstrate the issue:
* <img width="706" alt="Image" src="https://github.com/user-attachments/assets/06d37ebb-132b-4ebd-a1d8-838cec2ed86b" />
* <img width="1131" alt="Image" src="https://github.com/user-attachments/assets/3d5e4841-532e-4794-8482-ece0680da9ba" />
**Conclusion**
==========
In conclusion, the Superwall iOS library is affected by a critical issue that results in an uncaught exception 'NSInvalidArgumentException' when configuring the API key. This bug is likely caused by SuperwallKit pushing an `NSDictionary` into WebKit, where it expects a `String`. To this issue, we need to investigate further and provide a fix to ensure a smooth user experience for developers utilizing Superwall in their applications.
**Recommendations**
================
Based on our findings, we recommend the following:
* Investigate the issue further to determine the root cause.
* Provide a fix to ensure that SuperwallKit pushes the correct data type into WebKit.
* Update the Superwall documentation to reflect the changes and provide guidance on how to configure the API key correctly.
By following these recommendations, we can ensure that the Superwall iOS library is stable and reliable, providing a seamless experience for developers and users alike.<br/>
**Superwall iOS Crash with Uncaught Exception 'NSInvalidArgumentException': Q&A**
**Introduction**
===============
In our previous article, we explored a critical issue affecting the Superwall iOS library, resulting in an uncaught exception 'NSInvalidArgumentException' when attempting to configure the API key. In this Q&A article, we will address some of the most frequently asked questions related to this issue.
**Q: What is the root cause of the issue?**
=====================================
A: The root cause of the issue is that SuperwallKit is pushing an `NSDictionary` into WebKit, where it expects a `String`. This discrepancy in data types is likely the cause of the uncaught exception 'NSInvalidArgumentException'.
**Q: How can I reproduce the issue?**
=====================================
A: To reproduce the issue, follow these steps:
1. Create a new Swift project in Xcode.
2. Add the Superwall library to your project using CocoaPods or Carthage.
3. In your `App` struct, add the Superwall initializer:
```swift
init() {
Superwall.configure(apiKey: APIKeys.superwallKey)
}
- Run the build in the simulator.
A: The issue affects all devices and simulators.
A: Unfortunately, we are unsure if the issue is reproducible in the demo project.
A: To fix the issue, you will need to investigate further and determine the root cause. Once you have identified the issue, you can provide a fix to ensure that SuperwallKit pushes the correct data type into WebKit.
A: Based on our findings, we recommend the following:
- Investigate the issue further to determine the root cause.
- Provide a fix to ensure that SuperwallKit pushes the correct data type into WebKit.
- Update the Superwall documentation to reflect the changes and provide guidance on how to configure the API key correctly.
A: The implications of this issue are significant, as it can result in crashes and a poor user experience for developers utilizing Superwall in their applications.
A: To stay up-to-date with the latest developments on this issue, we recommend:
- Following the Superwall GitHub repository for updates and patches.
- Checking the Superwall documentation for the latest information on configuring the API key.
- Joining the Superwall community to discuss the issue and share knowledge with other developers.
In conclusion, the Superwall iOS library is affected by a critical issue that results in an uncaught exception 'NSInvalidArgumentException' when configuring the API key. By understanding the root cause of the issue and following the recommended steps to resolve it, developers can ensure a smooth user experience for their applications.