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
Related
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 .
I cannot build my ios product when I using product > archive in xcode...
I used flutter to development and I had did run flutter ios build --release.
Then I go to xcode running product > archive, I get this error
Showing All Issues
Multiple commands produce '/Users/yomate/Library/Developer/Xcode/DerivedData/Runner-ddhhkruxpbzezodlfgvmogmaieov/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/GoogleUtilities.framework':
1) Target 'GoogleUtilities-00567490' has create directory command with output '/Users/yomate/Library/Developer/Xcode/DerivedData/Runner-ddhhkruxpbzezodlfgvmogmaieov/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/GoogleUtilities.framework'
2) Target 'GoogleUtilities-54e75ca4' has create directory command with output '/Users/yomate/Library/Developer/Xcode/DerivedData/Runner-ddhhkruxpbzezodlfgvmogmaieov/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/GoogleUtilities.framework'
Where has problem? I had did successful 2 days ago, but I need to update the version now, it was got error
tried to add it in pod
target 'Runner' do
use_frameworks!
use_modular_headers!
pod 'GoogleUtilities', '7.7.0'
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'
pod 'GoogleUtilities', '7.7.0'
end
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:
I wanted to implement image notification in a flutter app. I setup everything using this doc and when I run a real device, the image notification worked.
but, when i try to Archive the build i'm getting this error. I am able to take archive only if I delete the MyImageNotification target.
This is folder structure looks like once i completed setup of imagg notification
I got below message from the bottom of the error log
ld: warning: Could not find or use auto-linked framework 'Flutter'
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_FlutterError", referenced from:
objc-class-ref in firebase_core(FLTFirebasePlugin.o)
objc-class-ref in firebase_dynamic_links(FLTFirebaseDynamicLinksPlugin.o)
"_OBJC_CLASS_$_FlutterMethodChannel", referenced from:
objc-class-ref in firebase_core(FLTFirebaseCorePlugin.o)
objc-class-ref in firebase_dynamic_links(FLTFirebaseDynamicLinksPlugin.o)
objc-class-ref in firebase_messaging(FLTFirebaseMessagingPlugin.o)
"_FlutterMethodNotImplemented", referenced from:
-[FLTFirebaseCorePlugin handleMethodCall:result:] in firebase_core(FLTFirebaseCorePlugin.o)
-[FLTFirebaseDynamicLinksPlugin handleMethodCall:result:] in firebase_dynamic_links(FLTFirebaseDynamicLinksPlugin.o)
-[FLTFirebaseMessagingPlugin handleMethodCall:result:] in firebase_messaging(FLTFirebaseMessagingPlugin.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
My PodFile look like this
# Uncomment this line to define a global platform for your project
# platform :ios, '9.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
target 'MyImageNotification' do
use_frameworks!
pod 'Firebase/Messaging'
end
Possible solution #1
Try inside ios folder:
rm -rf Pods/ Podfile.lock .symlinks Flutter/Flutter.podspec Runner.xcworkspace
pod repo update
pod install
Run archive
Possible solution #2
If steps above won't help, please ensure that your "Build Active Architecture Only" for target flavor is set to "no"
Possible solution #3
The idea is to bump target ios version. In your podfile set:
platform :ios, '10.0'
And modify your post install script the next way:
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['IPHONEOS_DEPLOYMENT_TARGET'] = '10.0'
end
end
end
Then reinstall pods (pod deintegrate, pod install)
looks like similer issue please : https://github.com/flutter/flutter/issues/95256
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