I am getting an error when trying to run or build my React Native Expo app. The issue is coming from an SVG that I am using.
At first I thought it was to do with SVGs in general, but I have found out that it is with a particular SVG.
I downloaded the SVG from Apple directly (here). I am using the 'Add to Apple Wallet Badges/US_UK/RGB/US-UK_Add_to_Apple_Wallet_RGB_101421.svg'
SVG. When I run the app with npx expo run:ios
or I try to build my app for both Android and iOS, I get an error:
error: assets/wallet/addToAppleWalletSVG.svg: Cannot set properties of undefined (setting 'shouldTestNextSiblings')
I have tried altering my metro.config.js
but wasn't sure if this was necessary given the other SVGs I am using are fine. I also saw recommendations to use and SVG optimiser, I did try this and it still resulted in the same error, plus I didn't want to opt for that as Apple are pretty strict with using their assets.
EDIT
Within the SVG file, there is a <style>
tag, I tried removing this and the error was fixed. However I feel like this isn't a great solution.
EDIT 2
As expected, removing the <style>
tag is an awful solution. It completely changes the SVG.
I am getting an error when trying to run or build my React Native Expo app. The issue is coming from an SVG that I am using.
At first I thought it was to do with SVGs in general, but I have found out that it is with a particular SVG.
I downloaded the SVG from Apple directly (here). I am using the 'Add to Apple Wallet Badges/US_UK/RGB/US-UK_Add_to_Apple_Wallet_RGB_101421.svg'
SVG. When I run the app with npx expo run:ios
or I try to build my app for both Android and iOS, I get an error:
error: assets/wallet/addToAppleWalletSVG.svg: Cannot set properties of undefined (setting 'shouldTestNextSiblings')
I have tried altering my metro.config.js
but wasn't sure if this was necessary given the other SVGs I am using are fine. I also saw recommendations to use and SVG optimiser, I did try this and it still resulted in the same error, plus I didn't want to opt for that as Apple are pretty strict with using their assets.
EDIT
Within the SVG file, there is a <style>
tag, I tried removing this and the error was fixed. However I feel like this isn't a great solution.
EDIT 2
As expected, removing the <style>
tag is an awful solution. It completely changes the SVG.
I checked the documentation for the SVG packages I am using but couldn't find any explanation to the cause of my problem.
I noticed the following in the SVG file:
<style type="text/css">
.st0{fill:#A6A6A6;}
.st1{clip-path:url(#SVGID_2_);fill:#DEDBCE;}
.st2{clip-path:url(#SVGID_2_);fill-rule:evenodd;clip-rule:evenodd;fill:#40A5D9;}
.st3{clip-path:url(#SVGID_2_);}
.st4{fill-rule:evenodd;clip-rule:evenodd;fill:#FFB003;}
.st5{fill-rule:evenodd;clip-rule:evenodd;fill:#40C740;}
.st6{fill-rule:evenodd;clip-rule:evenodd;fill:#F26D5F;}
.st7{clip-path:url(#SVGID_2_);fill-rule:evenodd;clip-rule:evenodd;fill:#D9D6CC;}
.st8{fill-rule:evenodd;clip-rule:evenodd;fill:#DEDBCE;}
.st9{fill:#FFFFFF;}
</style>
I am not familiar with SVGs, but this to me looks like styles are being mapped to classes. I discovered this block of code was causing the problem, so I simply added the styles inline opposed to using the classes, and this resolved my issue.
I appreciate this is not an optimal solution, but maybe someone that knows more about this could expand.