Xcode 13 and Cocoapods, how to disable assertions? - swift

I want to disable assertions to avoid asserts failures from third part libraries installed with Cocoapods also for the debug phase, not only release.
To reach this goal I've disabled Enable Foundation Assertions from my project section as showed in this image:
and for my target section:
For Pods I've changed my Podfile adding to the bottom part before the end statement this code:
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
config.build_settings['ENABLE_NS_ASSERTIONS'] = 'NO'
end
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_NS_ASSERTIONS'] = 'NO'
end
end
end
When I open my project workspace on Xcode , I see that also Pods project section and all target section have the same parameter turned to NO for both debug and release.
Now I'm in DEBUG mode with my simulator, when I launch my app assertions still works and my app still stops to assertion failure:
assert(false,"warning, change your file name with this...")
Are there any other parameters to turn off that I have forgotten?
P.S.:
Xcode 13 final version (13A233)
Cocoapods v1.11.2

Related

Flutter iOS build warnings

When I try to archive my flutter product for release I am getting lot of warnings as shown below.
Minimum deployment iOS version: 12
Xcode version: 14.2
My POD file for installation as below:
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
end
end
end
You have to change this line in your podfile at root/ios/Podfile to the desired target version.
Then you'd ideally reinstall all pods or do a repo update
Happy coding :)

Can't run IOS application in Flutter

Here is the image of error code i already try with pod update and repo pod update and clean derived data
Just add this lines to your Podfile
post_install do |installer_representation|
installer_representation.project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ARCHS'] = 'armv7 armv7s'
end
end
end
Flutter
ios
Podfile
First Delete ios Folder in your project
flutter create .
in terminal
then change ios version in your podfile to 10
then try to run it again and please backup ios folder if you have created or added files in ios

M1 MacBook Pro Flutter App : Command PhaseScriptExecution failed with a nonzero exit code

Command PhaseScriptExecution failed with a nonzero exit code
When running the Flutter project from VS Code it works fine. When trying to run it from Xcode getting this error.
I have done everything mentioned here
As this is a Flutter project the Script is:
/Users/aby/Development/flutter/packages/flutter_tools/bin/xcode_backend.sh
I've come across the same issue, and I noticed that when running via vscode, I hit no issues. Then I tried running the app from within Xcode but in Rosetta mode (simulator running as x86, as running via vscode does). This seemed to work.
To do so, I added this to my Podfile (to make pods compile in x86 mode)
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
# This is to remove arm64 from the available archs:
installer.pods_project.build_configurations.each do |config|
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
end
end
You must manually do this on the EXCLUDED_ARCHS of your project as well. After that, it all worked out fine. I think that Flutter is still not running on native M1 Macs.

How to fix cocoapod .modulemap file not found

When I try to build my project, I get a compile time error saying that a "Module map file" for my pod cannot be found and that I am missing a "SwiftShimes" module.
This is weird because all my modulemap files are where they should be when I install my pods.
I am using Xcode 10.2 and Cocoapods 1.6.1.
I have tried the following ->
deintegrating cocoapods from my project
cleaning the project
deleted ModuleCache and DerivedData
restarting my computer
This is the type of error I am getting ->
Module map file '/Users/kaunamohammed/Library/Developer/Xcode/DerivedData/OutNow-gxdxvzwmnijmrlajtbtyclkhrgqs/Build/Products/Debug-iphoneos/CodableFirebase/CodableFirebase.modulemap' not found
I expect my project to build properly but this is not the case and I am not sure what else to do.
This is what my Podfile looks like
platform :ios, '10.0'
workspace 'OutNow'
target 'OutNow' do
use_modular_headers!
#Pods for OutNow
pod 'Instabug'
pod 'SwiftMessages'
pod 'CodableFirebase'
pod 'Firebase/Core'
pod 'Firebase/Auth'
pod 'Firebase/Storage'
pod 'Firebase/Firestore'
pod 'Firebase/Messaging'
pod 'Firebase/DynamicLinks'
pod 'MarqueeLabel/Swift'
pod 'RxSwift', '4.4.2'
pod 'RxCocoa', '4.4.2'
pod 'Kingfisher', '5.3.1'
pod 'InstantSearchClient', '6.0'
pod 'CoordinatorLibrary', '1.0.5'
pod 'UIScrollView-InfiniteScroll', '1.1.0'
target 'OutNowTests' do
inherit! :search_paths
# Pods for testing
end
end
In case it helps anyone else, I was able to solve this issue a different way. I was accidentally opening up my .xcproject instead of my .xcworkspace. When I opened the correct file, the error went away.
I fixed this problem myself. I can tell you what I did. Not sure which steps did it exactly, but below are all steps:
Copy the contents of your Podfile somewhere safe
Run: pod cache clean --all
Remove "Podfile"-file from the dir.
Xcode: Product > Clean Build Folder
Run: pod init. A new "Podfile"-file is added to the dir
Start adding parts of your original Podfile to this file
Run: pod install
Try to build your project again
In my case, I think the row use_frameworks! in the "Podfile" did the trick.
Hope this help you guys out!
I had this issue only when I wanted to make an archive. On the other hand, debug worked fine. After a while I noticed that min iOS version was different between my Target, Project and Podfile min iOS version. After syncing them all to same value (iOS 11) Xcode offered me Validate Project Settings - Update to recommended settings option which I accepted and I was able to archive my project.
I spent a whole day trying to figure out how to solve this issue. I was facing issue in my project on M1 machine.
I enabled "Open using Rosetta" option in Xcode and worked for me.
Here is how you do that:
Open Finder --> Applications --> Right click "Xcode" --> Get Info --> check "Open using Rosetta"
I solve this issue by removing OTHER_SWIFT_FLAGS custom flag in Swift Compiler - Custom Flags
OTHER_SWIFT_FLAGS = "$(inherited) -D COCOAPODS -Xcc -fmodule-map-file=\"${PODS_ROOT}/modulePath/moduleName.modulemap\"";
I faced this same issue but with Fastlane using gym build_app.
I ensured that min iOS version was synched between my Target, Project, and Podfile as mentioned by Josip B. This allowed me to archive my app using XCode but it still failed using Fastlane.
After lots of searching, it was able to resolve my issue by ensuring the IPHONEOS_DEPLOYMENT_TARGET version for each of my installed Pods inherited the version from my Podfile using this Podfile post-install script:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
end
end
end
Reference this post: https://stackoverflow.com/a/63489366/10211406
In case you are building on command line with xcodebuild, make sure you are using
xcodebuild -workspace ...
instead of just xcodebuild or
xcodebuild -project ...
I had this issue too, I'm not very familiar with XCode, but I opened the .xcodeworkspace file and then clicked build, which was successful!
It´ s a bit of a hack but try adding this in your podfile:
post_install do |installer|
installer.pods_project.targets.each do |target|
if (target.name&.eql?('FBReactNativeSpec'))
target.build_phases.each do |build_phase|
if (build_phase.respond_to?(:name) && build_phase.name.eql?('[CP-User] Generate Specs'))
target.build_phases.move(build_phase, 0)
end
end
end
end
make sure you add it to your bridge file, and Try to add this at the end of your podfile:
post_install do |installer_representation|
installer_representation.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
end
end
end

Flutter ios build fails in xcode 10.1 with swift_version

I'm building a flutter app. everyting worked just fine. Then I think dart was upgraded and suddenly the build of the app fails with this error:
The “Swift Language Version” (SWIFT_VERSION) build setting must be set to a supported value for targets which use Swift. Supported values are: 3.0, 4.0, 4.2. This setting can be set in the build settings editor.
I don't see the setting in xcode and not sure what caused this error. Anyone else seen it?
For anyone else looking for the solution. You need to have XCode version higher than 10.0 before you can use Swift 4.2.
Open your podfile and make the following changes
target 'Runner' do
use_frameworks! # <---- // 1st add this right below above line
...
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
config.build_settings['SWIFT_VERSION'] = '4.2' # <--- // 2nd add this
end
end
end
After this, in terminal use flutter run. More info