I have a Flutter project that works fine on Android, but I can't run it on iOS. The build always fails.
SDWebImage shows an Arc Semantic Issue.
/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCoderHelper.m:31:40: No visible #interface for 'UIImage' declares the selector 'imageByPreparingForDisplay'
/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCoderHelper.m:48:40: No visible #interface for 'UIImage' declares the selector 'imageByPreparingThumbnailOfSize:'
What I've tried already:
Cleaned everything
deleted the DerivedData folder
closed Xcode
rm -rf Podfile.lock
rm -rf pubspec.lock
rm -rf Pods
pod repo update
pod cache clean --all
pod deintegrate
flutter clean
flutter pub get
pod setup
pod install --repo-update
Changed the iOS version
I can't go lower than iOS 13.0 because of some dependencies
Tried iOS 13, iOS 14, iOS 14.4, iOS 14.5
Tried on Xcode 12 and Xcode 13
Tried to change the targeted pod with errors to public instead of project
Tried to build for the simulator, Archive or just build (command + b)
The Flutter version I'm using is 3.0.4
Edit: This is my Podfile
platform :ios, '14.4'
use_modular_headers!
>
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
pod 'GeoFire', :git => 'https://github.com/heinzan/geofire-objc'
pod 'Firebase', :modular_headers => true
pod 'FirebaseCore', :modular_headers => true
pod 'GoogleUtilities', :modular_headers => true
$RNFirebaseAsStaticFramework = true
target 'Runner' do
use_frameworks!
#use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ARCHS[sdk=iphonesimulator*]'] = `uname -m`
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.4'
end
flutter_additional_ios_build_settings(target)
end
end
target 'OneSignalNotificationServiceExtension' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
pod 'OneSignalXCFramework', '>= 3.0.0', '< 4.0'
end
```
Try adding use framework in podfile like
target 'Runner' do
use_frameworks!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
You must already have Target runner do. Just as use frameworks
I ended up deleting the ios folder and recreating with flutter create .
Related
After upgrading react-native package from 0.63.4 to 0.64.4 I got following errors in Xcode (on MacBook Pro M1) while building and running the app on simulator and device:
I tried to it with and without using flipper, but nothing helped.
Also added CoreFoundation and Foundation Framework manually to the project and ran Xcode with and without Rosetta enabled.
This is my current PodFile:
source 'https://github.com/CocoaPods/Specs.git'
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/#react-native-community/cli-platform-ios/native_modules'
platform :ios, '12.0'
target 'MyApp' do
config = use_native_modules!
use_react_native!(
:path => config[:reactNativePath],
# to enable hermes on iOS, change `false` to `true` and then install pods
:hermes_enabled => false
)
pod 'react-native-netinfo', :path => '../node_modules/#react-native-community/netinfo'
pod 'RNGestureHandler', :path => '../node_modules/react-native-gesture-handler'
permissions_path = '../node_modules/react-native-permissions/ios'
pod 'Permission-Camera', :path => "#{permissions_path}/Camera"
pod 'Permission-AppTrackingTransparency', :path => "#{permissions_path}/AppTrackingTransparency"
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
#use_flipper!()
post_install do |installer|
react_native_post_install(installer)
end
end
My working solution for this is to create a new, clean project with the version you want to upgrade to.
Afterwards do following steps:
Open both .xcworkspace files in Xcode
Head over to your Targets Build Settings
Search for "Header Search Paths"
Copy all Header Search Paths from new Project to your project you want to upgrade
Remove DerivedData, Clean Build and Run again
Run pod install. Maybe you need to upgrade some packages
Additionally a nice npm script for rebuilding .xcworkspace (Replace "[PRJECT_NAME]" with your .xcworkspace name):
"renew-pods-m1": "cd ios; rm -rf ~/Library/Caches/CocoaPods; rm -rf Pods; rm -rf [PROJECT_NAME].xcworkspace; rm -rf ~/Library/Developer/Xcode/DerivedData/*; pod deintegrate; pod setup; arch -x86_64 pod install;"
Note: Have a look at your PodFile. Maybe you need to change the use_react_native implementation and add the post_install script
use_react_native!(
:path => config[:reactNativePath],
# to enable hermes on iOS, change `false` to `true` and then install pods
:hermes_enabled => false
)
At the end of the PodFile
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
#use_flipper!()
post_install do |installer|
react_native_post_install(installer)
end
For me it was Flipper. I wasn't using it in my old project, and it was automatically enabled in my new one. Just comment out the line in your Podfile if your project doesn't require it.
# :flipper_configuration => FlipperConfiguration.enabled,
I create an application using flutter but I am facing an issue when trying to run it IOS simulator
I am getting the following error
Error (Xcode): In /Users/user214711/Desktop/flutter_apps/guide/ios/Pods/Sodium/Sodium/libsodium/libsodium-ios.a(libsodium_la-aead_xchacha20poly1305.o), building for iOS Simulator, but linking in object file built for iOS, for
architecture arm64
Could not build the application for the simulator.
Error launching application on iPhone 13.
I tried many solution on the internet but unfortunately all solutions was related for. native IOS apps not flutter apps
here is my pod file
# Uncomment this line to define a global platform for your project
platform :ios, '10.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
Open your iOS workspace in Xcode and make sure under Debug you are running only the active architecture. Follow these steps:
After adding firebase dependency on iOS, when I want to run then I get this error
Xcode's output:
↳
../ios/Runner/GeneratedPluginRegistrant.m:10:9: fatal error: module
'firebase_analytics' not found
#import firebase_analytics;
~~~~~~~^~~~~~~~~~~~~~~~~~
1 error generated.
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description
Could not build the precompiled application for the device.
Error launching application on Abir's iPhone.
I already tried many way. like delete pod file, pod update, pod install etc.
Its problem with openning Runner. Open Runner.xcworkspace not Runner.xcodeproj.
I had this same error and here is how to solve it.
Delete the DerivedData from Xcode folder. Open Runner.xcworkspace inside the ios folder of your flutter project then click File -> Workspace Settings -> Click the grey arrow beside DerivedData path and delete the DerivedData inside the Xcode folder.
Delete both Podfile and Podfile.lock files inside ios folder of your flutter project.
Change the Deployment Target to 12.0. You will find the Deployment Target under General -> Deployment Info.
Clean your ios build folder.
Run your app (it will generate a new podfile, do not edit this podfile) It should work.
pod repo update or with pod install --repo-update
Matching the Deployment Target under General -> Deployment Info with the platform :ios, '11.0' version in Podfile solved the issue for me.
I was using a very old Mac mini with Catalina. I had to switch to Mac Mini M1 with latest XCode. Plus had make my Podfile looks like this.
# Uncomment this line to define a global platform for your project
platform :ios, '12.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
I am trying to build for app store. using command flutter build ipa and getting below error. Although the build works (when I run from Android studio)on debug mode and I can receive push notification.
warning: Multiple targets match implicit dependency for linker flags '-framework GoogleUtilities'. Consider adding an explicit dependency on the intended target to
resolve this ambiguity. (in target 'Runner' from project 'Runner')
warning: Multiple targets match implicit dependency for linker flags '-framework GoogleUtilities'.Consider adding an explicit dependency on the intended target to
resolve this ambiguity. (in target 'ImageNotification' from project 'Runner')
error: Multiple commands produce
'/Users/manu/Library/Developer/Xcode/DerivedData/Runner-csuwafuzvneucvdjlkobmosdwxae/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuild
FilesPath/UninstalledProducts/iphoneos/GoogleUtilities.framework':
1) Target 'GoogleUtilities-00567490' has create directory command with output
'/Users/manu/Library/Developer/Xcode/DerivedData/Runner-csuwafuzvneucvdjlkobmosdwxae/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuild
FilesPath/UninstalledProducts/iphoneos/GoogleUtilities.framework'
2) Target 'GoogleUtilities-54e75ca4' has create directory command with output
'/Users/manu/Library/Developer/Xcode/DerivedData/Runner-csuwafuzvneucvdjlkobmosdwxae/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuild
FilesPath/UninstalledProducts/iphoneos/GoogleUtilities.framework'
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description
I added a ImageNotification new target Notification Service extension for push image in push notifications
Here is my pod file :
# Uncomment this line to define a global platform for your project
platform :ios, '14.3'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), _FILE_)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(_FILE_))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
target 'ImageNotification' do
use_frameworks!
pod 'Firebase/Messaging'
end
ADD - pod 'GoogleUtilities' to ImageNotification target and Runner target in PodFile.
target 'ImageNotification' do
...
pod 'GoogleUtilities'
end
target 'Runner' do
...
pod 'GoogleUtilities'
end
then delete the PodFile.lock then run flutter clean, then flutter pub get, then flutter build ios.
After that open the ios module in Xcode and build archive.
it will work.
Comment the pod line:
target 'ImageNotification' do
use_frameworks!
#pod 'Firebase/Messaging'
end
Comment FirebaseMessaging import and Extension Helper line in didReceiveNotificationRequest
#import "NotificationService.h"
//#import "FirebaseMessaging.h"
#interface NotificationService ()
#property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver);
#property (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent;
#end
#implementation NotificationService
- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
self.contentHandler = contentHandler;
self.bestAttemptContent = [request.content mutableCopy];
// [[FIRMessaging extensionHelper] populateNotificationContent:self.bestAttemptContent withContentHandler:contentHandler];
}
- (void)serviceExtensionTimeWillExpire {
// Called just before the extension will be terminated by the system.
// Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
self.contentHandler(self.bestAttemptContent);
}
#end
And this worked for me!!
After trying number of efforts it build and archive successfully. I never know which settings are applicable, but few steps are as followed, let check with your settings.
In Podfile,
target 'Runner' do
pod 'GoogleUtilities'
use_frameworks!
#use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
#pod 'Firebase/Messaging'
end
target 'ImageNotification' do
use_frameworks!
pod 'GoogleUtilities'
pod 'Firebase/Messaging'
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
Run flutter build,
flutter build ios --release --verbose
As followed with FCM via APNs Integration,
Follow Step 1 to 4.
In Xcode Project,
Targets > Runner > Build Phases > Move Sequence
'Embed App Extensions' then
'[CP] Embed Pods Frameworks then
'[CP] Copy Pods Resources'
And Mark Checked(✅) 'Copy only when installing' in 'Embed App Extensions'
That's it try archive now,
Select 'Runner' > Any iOS Device
And
Product > Archive
Done!!
And not forgot to follow the Notification Payload request for FCM,
apns: {
payload: {
aps: {
'mutable-content': 1
}
},
fcm_options: {
image: 'https://foo.bar.pizza-monster.png'
}
},
All the best.👍
just remove 'use modular headers!' from podfile
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?