Xcode 15 issue related to Flutter 3 — Fix
Hi everyone you might have updated to the latest version of mac OS Sonoma which forced the updated of Xcode. You are not the only enthusiasitc person in the world, we all are guilty of it.
But this update came with a lot of unnecessary bugs which caused a lot of panic and sleepless nights for Flutter developers.
In this short article i will list down the two common errors that every Flutter app developer will get once updated to the latest version of the app.
Bug 1
Folder name change issue
This issue will be the first one that pops up when you run your Flutter app in the newest version of Xcode.
Fix
In order to solve this you can either manually search for the folder and replace all instance with TOOLCHAIN_DIR or you can write a pod script to automatically do the change every time you do pod install.
post_install do |installer|
installer.aggregate_targets.each do |target|
target.xcconfigs.each do |variant, xcconfig|
xcconfig_path = target.client_root + target.xcconfig_relative_path(variant)
IO.write(xcconfig_path, IO.read(xcconfig_path).gsub("DT_TOOLCHAIN_DIR", "TOOLCHAIN_DIR"))
end
end
.......
end
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
if config.base_configuration_reference.is_a? Xcodeproj::Project::Object::PBXFileReference
xcconfig_path = config.base_configuration_reference.real_path
IO.write(xcconfig_path, IO.read(xcconfig_path).gsub("DT_TOOLCHAIN_DIR", "TOOLCHAIN_DIR"))
end
.....
end
end
Bug 2
Error with Web kit and and Objective C
This issue took me three days to figure out and with the help of the github community we have the solution for this.
Fix
In order to solve this we need to add another pod script to make it work.
post_integrate do |installer|
compiler_flags_key = 'COMPILER_FLAGS'
project_path = 'Pods/Pods.xcodeproj'
project = Xcodeproj::Project.open(project_path)
project.targets.each do |target|
target.build_phases.each do |build_phase|
if build_phase.is_a?(Xcodeproj::Project::Object::PBXSourcesBuildPhase)
build_phase.files.each do |file|
if !file.settings.nil? && file.settings.key?(compiler_flags_key)
compiler_flags = file.settings[compiler_flags_key]
file.settings[compiler_flags_key] = compiler_flags.gsub(/-DOS_OBJECT_USE_OBJC=0\s*/, '')
end
end
end
end
end
project.save()
end
Once you have added this run the following commands
cd ios
rm podfile.lock
pod deintegrate
pod install --repo-update
if all this commands work properly, you can easily run the app without any issues.
Thats it…
Now you can easily fix your app for the latest version of Xcode.
Thanks for reading this article ❤️
reach me at LinkedIn !!
Other links: https://bento.me/tanmoykarmakar
Book a call with me at : https://topmate.io/tanmoy_karmakar
Support me at,