I am not sure if this is a capacitor question or Xcode question. In localhost on web, I am seeing all the updated UI. When I build for mobile purposes, I do not see any changes.
Following:
ionic build
npx cap copy ios (also tried npx cap sync iOS)
npx cap open ios
When I look at the public folder under iOS app/public to search my update, I can see the changes in main.js file.
Yes, I cleared build folder under product. I also restarted Xcode. I also removed app on physical device and also tried on different simulators. Nothing changed.
Xcode version: 12.4
ionic 6.12.4
getting a bit frustrated with this, has been weeks.
So I just tried going into the iOS folder and do pod install, it worked the first time around. (Also surprised why cap sync didnât âinstallâ) After the following build, it reverted back to old version on next sync.
in case anyone runs into this trouble.
You need to delete the iOS folder and restart everything, it seems. This isnât great though since all the configuration I had under iOS gets removed. So do keep a copy/reference of your old files.
Thanks. You are correct and thatâs also what I was doing too but nothing changed. (This started happening recently.)
I honestly cannot figure out why it wasnât updating. Deleting the folder and restarting all over was my last resort.
Iâm seeing the same thing happen with my current setup. I would rather not delete my iOS folder and restart this so I was wondering if you figured out where some files may be cached.
Itâs like the JavaScript files are not being updated on new native builds to the device.
Once you deleted the iOS folder did your builds work correctly going forward?
close your editor(s) clean all build folders (no need to delete anything) and then build again (in vscode in my case) and ionic cap sync again. Worked for me
This is happening for me, and deleting the ios folder and clearing all build folders isnât working. The javascript build folder has the latest code which I confirmed by running it using a local web server, but the ios build is always an older version.
If you update something in the code after that you have run the app via XCode on your phone or the simulator, and you want to see the change, you have to build first:
Using Ionic CLI: ionic build
Using Vite: npm run build
(npx cap build ios did not work for me)
Same issue here. I canât find absolutely no way to make the native app reflect latest code changes in the PWA.
I updated the version number of my MainPage.js and in xCode, if I search in App/App/public/static/js/main.something.js I can find it there. However, the code of the native App didnât change after build (I also added a simple âhelloâ to a text field).
Struggling with this for hours now I already did (some steps multiple times):
rm -rf ~/Library/Developer/Xcode/DerivedData
rm -rf ~/Library/Caches/com.apple.dt.Xcode
rm -rf ~/Library/Developer/Xcode/UserData
I reset the simulator
I did âClean build folderâ in xCode
I removed the full ios folder in my app folder - and I checked by doing npx cap open ios and receiving an error
then:
npm run build
npx cap add ios
npx cap open ios
And I am back to where I started. In fact I can see it right away because if behaves like running in a browser, so this:
const isIosNative = deviceInfo ? (deviceInfo.device === âiPhoneâ && deviceInfo.engine === âWebKitâ && deviceInfo.browser?.startsWith(âWebKitâ)) : false;
doesnât become true, because I added this code after building the native app for the very first time.
But also my âhelloâ doesnât show up.
I even thought xCode might do something stupid and checks if the code I try to run got committed. Created a branch, commited code there, xCode sees the new branch, nothing changedâŚ
If you configure server: {} in capacitor.config.json and provide the url key pointing to your dev environment there, the native app will do nothing with the code you generated running npm run build or similar. It will copy it into your xCode project and it will sit there. But it doesnât work like one would expect it - like a replacement for the service-worker cache. It just doesnât do anything with it. It will use whatever is in the public folder and from there directly talk to the url configured in the value of server.url key.
Now, if you started the implementation of capacitor on a new branch of your existing web-app (because you wanted to make sure not to break the web-app), did code changes there, etc. your web-app test env will most likely still serve the code of your main branch - so the native app will show the main branch, no matter how many nice and fancy things you added locally to your web-app code to improve the native app.
I found this out checking the nginx access logs of my dev environment.
So I guess this may bite anyone already having a proper dev env running and using relative path inside the app (fetch /api/my-endpoint).
E.g. my API runs under the same domain name that also serves out the web-app (e.g. https://myapp.test and https://myapp.test/api - not https://api.myapp.test). To make the native app find my api I configured https://myapp.test as the url. Unfortunately also the views and everything get loaded via this URL then, main.js bundled inside the native app package will get ignored.
Fix:
Create an env variable to configure the base_url and added it to all API calls (no relative any longer).
Remove url key from server object in capacitor.config.json.