Unable to build project with Stream Chat iOS SDK - ios

I'm trying to use the new Stream iOS Chat SDK and am unable to get it to build after I install it via Cocoapods. The project was building with the other pods listed before we added StreamChat. I am using Xcode 10.2 (Does not work with 10.1), Swift 4.2, and Cocoapods version 1.7.4. We used the pod install command listed on Stream's website:
pod install --repo-update
Our Podfile looks like this:
platform :ios, '11.0'
inhibit_all_warnings!
target 'Project-iOS' do
use_frameworks!
# Pods for Project-iOS
pod 'ReachabilitySwift', '4.3.0'
pod 'SwiftKeychainWrapper', '3.2.0'
pod 'CropViewController'
pod 'StreamChat'
target 'Project-iOSTests' do
inherit! :search_paths
# Pods for testing
end
target 'Project-iOSUITests' do
inherit! :search_paths
# Pods for testing
end
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '4.2'
end
end
end
*Note that I tried this with and without the post_install bit at the end - but was having to manually change the pods to 4.2 since for many 5.0 isn't supported yet.
These are the errors I'm seeing when I try and build:
Edit: I also tried to get this running in a new blank project with just the StreamChat pod targeting iOS 11 (Basically just as the instructions on the site state for the ChatDemo) and ran into the same type of issues.

Related to your first question be sure to use Xcode 10.2 or later and Swift 5.
No need force pods to Swift 4.2. Try to remove these lines from your Podfile, then your project should compile without any errors:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '4.2'
end
end
end

Related

No such module FirebaseStorage

I am working on an iOS project in swift 5 in Xcode 11.6 using cocoapods. Whenever I try to build it fails with the error message 'No Such Module FirebaseStorage'. I have tried deintegrating and installing several times. Below is the pod file I'm using. If I looking in the pods directory in the project folder, I can see a firebasestorage folder. I have also attached my header search path under the build settings for the workspace. header search path
Uncomment the next line to define a global platform for your project
platform :ios, '13.6'
#install! 'cocoapods', :disable_input_output_paths => true
target 'project' do
# use_modular_headers!
# Comment the next line if you don't want to use dynamic frameworks
# use_frameworks!
pod 'Firebase/Core'
pod 'Firebase/Auth'
pod 'MessageKit'
pod 'Firebase/Firestore'
pod 'Firebase/Storage'
pod 'SDWebImage'
end
# Pods for project
target 'projectTests' do
inherit! :search_paths
# Pods for testing
end
target 'projectUITests' do
# Pods for testing
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
if Gem::Version.new('8.0') >
Gem::Version.new(config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'])
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '8.0'
end
end
end
end
I was wondering what might be causing this issue?

Change target ios version when installing new pod

Whenever I install a new pod project, and for example I install firebase libraries I always get installed libraries to be targeted for projects 8.0 or and I start changing them manually to be 9.0 or 14.0 because of the warning that I'm Getting.
Here it is the Podfile content:
platform :ios, '14.0'
target 'TestProject' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for TestProject
pod 'SDWebImageSwiftUI'
pod 'lottie-ios'
pod 'Firebase/Auth'
pod 'Firebase/Firestore'
end
How it is possible to update target iOS all at once, so I won't be updating all the libraries one by one?
Add this to your Podfile and then pod install.
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0'
end
end
end
This will update all the Pod targets at once to your desired version.
Depending on your Podfile, Warren's answer might not be enough to set all targets to the new deployment target. I recommend using this post-install handler:
deployment_target = '14.0'
post_install do |installer|
installer.generated_projects.each do |project|
project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = deployment_target
end
end
project.build_configurations.each do |bc|
bc.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = deployment_target
end
end
end
This addition becomes important when you use options like install! 'cocoapods', :generate_multiple_pod_projects => true

Realm app compiles on device but not on simulator on Xcode 12

I have a Realm app that was running fine in Xcode 11 in both, the device and the Simulator. I recently updated to Xcode 12 and now the app doesn't compile in any of the Simulators but works fine on physical devices. After researching I noticed that Realm suggests adding some build settings in your Podfile to exclude the arm64, so I went and added it but I'm still getting errors.
Here is what I have done in more detail.
Original Podfile looked like this:
def shared_pods
pod 'RealmSwift', '~> 3.18'
end
target 'MyApp' do
use_frameworks!
platform :ios, '10.0'
shared_pods
target 'MyAppTests' do
inherit! :search_paths
end
target 'MyAppUITests' do
inherit! :search_paths
end
end
target 'MyApp Watch App' do
use_frameworks!
platform :watchos, '3.1'
# Pods for MyApp Watch App
shared_pods
end
target 'MyApp Watch App Extension' do
use_frameworks!
platform :watchos, '3.1'
shared_pods
end
Here is what I did step by step.
I compiled my app for the first time in Xcode 12 and I got the following error.
I modified my PodFile to what Realm recommends adding the following code at the end of the Podfile.
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'
config.build_settings['EXCLUDED_ARCHS[sdk=watchsimulator*]'] = 'arm64'
config.build_settings['EXCLUDED_ARCHS[sdk=appletvsimulator*]'] = 'arm64'
end
end
end
In the terminal I entered pod install.
Recompiled my project and it got rid of the first error but it now shows the following error.
Any idea what could be wrong now?
In my case upgrading Realm to the latest version, 10.1.0 and updating cocoapods to 1.10.0 solved the issue, I can now compile on the Simulator.

Remove deprecated iOS framework warning in specific pod

I'm trying to not see this warning in the Atlas pod since its not my library.
'UIMutableUserNotificationCategory' is deprecated: first deprecated in
iOS 10.0 - Use UserNotifications Framework's UNNotificationCategory
I am using
inhibit_all_warnings!
in my pod file.
I also tried pod 'Atlas', '1.1.5', :inhibit_warnings => true which didn't work.
I'm thought if I change the platform from iOS 9 to iOS like this
platform :ios, '9.0'
It would no longer show the warning.
update
-Wno-deprecated worked when I put it in Atlas build settings under complier flags -> c++ flags.
Any way to do this in the podfile? so a pod install will not break it.
Add to your podfile the following statement, and then run pod install
pod 'YourPodToIgnore', :inhibit_warnings => true
Any way to do this in the podfile? so a pod install will not break it.
In this way you can set it the build_settings for every target:
post_install do |installer|
installer.pods_project.targets.each do |target|
installer.pods_project.build_configurations.each do |config|
config.build_settings['OTHER_CFLAGS'] = "-Wno-deprecated"
end
end
end

Set deployment target for CocoaPods's pod

I use CocoaPods to manage dependencies in my project. I've written Podfile:
target 'MyApp' do
platform :ios, '8.0'
# Uncomment this line if you're using Swift or would like to use dynamic frameworks
#use_frameworks!
# Pods for MyApp
pod 'KeepLayout', :git => 'https://github.com/iMartinKiss/KeepLayout', :tag => 'v1.6.0'
pod 'EasyMapping'
target 'MyAppTests' do
inherit! :search_paths
# Pods for testing
end
target 'MyAppUITests' do
inherit! :search_paths
# Pods for testing
end
end
This file works well with CocoaPods 0.x but I can't compile project after I've updated to CocoaPods 1.0. After I've run
pod update
I can't compile my project with error:
/Users/<...>/Pods/KeepLayout/Sources/KeepAttribute.m:195:1: Cannot synthesize weak property because the current deployment target does not support weak references
I've seen that every library is builded with different deployment target. For example KeepLayout is builded with 4.3 deployment target.
How I can determine build target for every pod dependency?
While some development versions of CocoaPods (as well as pre-1.0 versions) may have propagated the deployment target of the project down to the pods, this is no longer the case in 1.0. To work around this, the current developer recommends using a post-install hook.
Here's a brute force approach to force a hard-coded deployment target for every pod in the generated Pods project. Paste this at the end of your Podfile:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.2'
end
end
end
Since the Podfile uses a directive like platform :ios, '9.0' to specify "iOS Deployment Target" (aka IPHONEOS_DEPLOYMENT_TARGET) for the Pods/Pods.xcodeproj project, you just need to remove the Deployment Target info from each build target.
Do it by adding this to your Podfile
platform :ios, '9.0' # set IPHONEOS_DEPLOYMENT_TARGET for the pods project
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
Inspired by the github post and Alex Nauda's answer.
While the accepted answer by Alex Nauda is good, but letting the Pods inherit the target from the app might be a much better solution. 🚀
app_ios_deployment_target = Gem::Version.new('9.2') # Change to your current deployment target
platform :ios, app_ios_deployment_target.version
# Let Pods targets inherit deployment target from the app
# This solution is suggested here: https://github.com/CocoaPods/CocoaPods/issues/4859
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |configuration|
pod_ios_deployment_target = Gem::Version.new(configuration.build_settings['IPHONEOS_DEPLOYMENT_TARGET'])
if pod_ios_deployment_target <= app_ios_deployment_target
configuration.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
end
end
end
end
Here is the way to set deployment target permanently for pod targets.
Goto -> podfile -> Add below code
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = "12.0"
end
end
end
change target to "11.0"
platform :ios, '11.0'
1) Search for IPHONEOS_DEPLOYMENT_TARGET
2) Change the iOS Deployment Target

Resources