When trying to run the code in IOS using xcode its not working, but in andorid its working perfectly

The xcode is throwing error like this, and blank screen is visible in the IOS emulator

Warning: -[BETextInput attributedMarkedText] is unimplemented :zap: Loading app at capacitor://localhost… BlobWriter listening at http://localhost:58005/ Failed to request allowed query parameters from WebPrivacy.

:zap: ------ STARTUP JS ERROR ------

:zap: TypeError: undefined is not an object (evaluating ‘navigator.serviceWorker.addEventListener’) :zap: URL: capacitor://localhost/assets/index-AlBXg0s2.js :zap: index-AlBXg0s2.js:236:810

:zap: See above for help with debugging blank-screen issues :zap: [error] - {} :zap: WebView loaded

Service workers don’t work on the WKWebView when using custom schemes

https://bugs.webkit.org/show_bug.cgi?id=206741

1 Like

I am not loading any service worker from my end , capacitor is doing it automatically, and i don’t even know where this line of code is written in the project

Capacitor is not adding that code, your framework is probably doing it.

okay, i don’t know what is doing this process, to be clear i am using react js as front end from vite and using capacitor with it

here is package.json file have a look into it, as i don’t know how to fix this, and its very important for me to fix this code fast.

{
“name”: “realestate-crm”,
“version”: “0.1.0”,
“type”: “module”,
“scripts”: {
“dev”: “vite --host”,
“build”: “vite build”,
“preview”: “vite preview”
},
“dependencies”: {
@capacitor-community/file-opener”: “^6.0.0”,
@capacitor/android”: “^6.1.0”,
@capacitor/assets”: “^3.0.5”,
@capacitor/core”: “^6.1.0”,
@capacitor/filesystem”: “^6.0.0”,
@capacitor/haptics”: “^6.0.0”,
@capacitor/ios”: “^6.1.0”,
@capacitor/push-notifications”: “^6.0.1”,
@capacitor/status-bar”: “^6.0.0”,
@react-pdf/renderer”: “^3.3.8”,
@reduxjs/toolkit”: “^2.2.1”,
@tailwindcss/forms”: “^0.5.7”,
@tanstack/react-table”: “^8.19.2”,
“age-calculator”: “^1.0.0”,
“axios”: “^1.6.7”,
“capacitor-blob-writer”: “^1.1.16”,
“capacitor-plugin-safe-area”: “^3.0.1”,
“chart.js”: “^4.4.1”,
“chartjs-adapter-moment”: “^1.0.1”,
“dateformat”: “^5.0.3”,
“firebase”: “^10.9.0”,
“html2canvas”: “^1.4.1”,
“jspdf”: “^2.5.1”,
“moment”: “^2.30.1”,
“react”: “^18.2.0”,
“react-accessible-accordion”: “^5.0.0”,
“react-dates”: “^21.8.0”,
“react-dom”: “^18.2.0”,
“react-export-table-to-excel”: “^1.0.6”,
“react-flatpickr”: “^3.10.13”,
“react-redux”: “^9.1.0”,
“react-router-dom”: “^6.20.1”,
“react-select”: “^5.8.0”,
“react-spinners”: “^0.13.8”,
“react-to-print”: “^2.15.1”,
“react-transition-group”: “^4.4.5”,
“sonner”: “^1.4.3”,
“to-words”: “^4.0.0”
},
“devDependencies”: {
@capacitor/cli”: “^6.1.0”,
@vitejs/plugin-react”: “^4.2.1”,
“autoprefixer”: “^10.4.16”,
“postcss”: “^8.4.32”,
“tailwindcss”: “^3.3.6”,
“vite”: “^5.0.6”
}
}

Use grep to find the node-module that uses serviceWorker, replace with another :slight_smile:

Hi there,

I’ve ran grep -r “serviceWorker” in the root of my project, and received I think thousands of lines of random code… lots of ./dist/assets/...., a big list of node-modules starting with the line
./node_modules/@stencil/core/.....

Not really sure where to go from here.

Update: I have fixed the issue, the issue was that, i was using firebase for the react web application which is specifically “npm i firebase” this package, so this initialized a a service worker when the capacitor code starts , which throws an error in xcode, this is was the issue, as soon as i removed all the files related to the firebase package that is all the initization code, and removed the package and uninstalled it too, the code start working fine as this should be wihtout any error.

1 Like