The first time, I go with the way from here: https://stackoverflow.com/a/62679942/1979190
But this way will lead to many issues as EXC_BAD_ACCESS
because some Cordova Plugins do not support that way.
My teammate found a way to resolve this issue.
The root cause is from Capacitor, I don't know why they set Compiler flags
to -fno-objc-arc
for all files from CordovaPlugins
.
We just need to revert the Compiler flags
to empty
like this image below to avoid all error messages related to ARC Weak References
.

But every time you run npx cap update
or npx cap sync
everything will be reset to -fno-objc-arc
^^.
So we need to write a script to set Compiler flags
to empty
for all files from CordovaPlugins
after we run these commands.
We will add this script below Podfile (ios/App/Podfile
) to do the job.
post_install do |installer|
installer.pods_project.targets.each do |target|
if ['CordovaPlugins'].include? target.name
target.build_phases.each do |build_phase|
if (build_phase.display_name.eql? "Sources")
build_phase.files.each do |file|
if (file.settings)
settings = file.settings
settings["COMPILER_FLAGS"] = ""
file.settings = settings
end
end
end
end
end
end
end
Hope it help!