Hey @bonnell! Thanks for reaching out!! I would like to highlight that this used to work in 2.2.0, but doesn’t work any more in 2.4.0 and 2.5.0
I narrowed it down to it being about frameworks, and you can replicate this using TwitterClient’s loadTweetWithId method. No static JSON needed!
I’ll start with the architecture of my app, I’ll give two examples of the crash: one with static json, and one using only methods available in TwitterKit. I’ll share my current workaround. I’ll also share some workarounds that didn’t work. And then close.
App Architecture
Here’s an overview of my app’s architecture: I have a framework of shared logic (because my app has a share extension, etc). The framework has all my models for Posts and Users, etc. And because the framework has all the models, I put in all my network loading code in there as well.
My Podfile has TwitterKit as a dependency of the framework. And the main app has the framework as a dependency in Xcode. TwitterKit is only in my main app at all because of this transitive dependency.
Static Json Example
So if I get some json from my server in the framework, and in the framework I initialize a tweet: TWTRTweet(jsonDictionary: tweetJson). And when I pass that TWTRTweet back to my main app, and configure a TWTRTweetView with it self.tweetView.configure(with: tweet), I now get a crash. exception 'NSInvalidArgumentException', reason: 'Invalid entity type found'
TwitterKit Native Example
So if i get a tweet ID from my server in the framework, and in the framework I call twitterClient.loadTweetWithId:tweetId, and then pass that loaded tweet back into my main app, and configure a TWTRTweetView with it, then I get the same exact crash. exception 'NSInvalidArgumentException', reason: 'Invalid entity type found'
Current work around
Currently, I get tweet json from my server in the framework. I pass the raw json from the framework to my main app, and then create the tweet TWTRTweet(jsonDictionary: tweetJson) in my main app, outside of the framework. And this works. I’m not happy with this workaround because I want my framework to handle all the data loading.
Failed work arounds
Because of this transitive dependency of my app on the framework, and the the framework on the Cocoapods framework, one of the things I tried was to put in the Fabric info.plist information in the info.plist of the framework. But TwitterKit did not pick up that info.
Another thing I tried was to instantiate Twitter() with the secret and consumer key inside of my framework, but I got the same crash.
Closing
In closing I would like to repeat that this used to work without a crash in 2.2.0, but crashes in 2.4.0 and 2.5.0 with exception 'NSInvalidArgumentException', reason: 'Invalid entity type found'