Automattic / Gridicons-iOS

Gridicons is a tiny framework which generates Gridicon images at any resolution.
GNU General Public License v2.0
25 stars 12 forks source link

Fix import of `xcassets` to resources bundles in `podspec` #66

Closed pmusolino closed 2 years ago

pmusolino commented 2 years ago

In WCiOS during the last two years, we encountered a crash, that was happening during the first launch of the app on a new device (a new device, is that device that has never installed the application before). In particular, we encountered this crash https://github.com/woocommerce/woocommerce-ios/issues/2454 that can be easily reproducible following these steps:

  1. Launch the simulator where you want to run the app.
  2. Go on the Device menu, and click Erase All content and settings....
  3. Run WCiOS on that simulator.
  4. Try to log in, adding your credentials.
  5. After adding your email, you will encounter a crash on the Gridicons library.

After several investigations, it appears that the problem is caused by the way we import xcassets resources into the podspec file of Gridicons.

Basically, before we were integrating the xcassets like this

s.resource_bundles = {
    Gridicons: [
      'Gridicons/Gridicons/*.{xcassets}'
    ]
  }

using as bundle name Gridicons which create a conflict at runtime. For solving this issue, I modified the bundle for the resources to GridiconsAssets like this:

s.resource_bundles = {
    GridiconsAssets: [
      'Gridicons/Gridicons/*.{xcassets}'
    ]
  }

plus I edited the code where we use the old bundle name. The reason for this conflict is well explained in this post. After importing this branch in WCiOS, the issue was fixed and I'm no more able to reproduce the crash 🚀