Flutter: How to Solve Stuck in Running Pod Install Error? - xcode

I am developing a flutter project with VSCode. Today, I download my flutter project folder to Mac. I stuck in running pod install.
I deleted the pod file and run this code
Pod install
and I got this error.
No `Podfile' found in the project directory.
I also tried to set from Xcode runner target level to 8. However, it should be at least 11.
What can I do?
Thanks for helping.
(M2 Silicon Valley)
Here is my Podfile.
# Uncomment this line to define a global platform for your project
# platform :ios, '8.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

Merhaba, I recommend following the next steps;
1- Clear XCode's "Derived Data" from; /Users/YOURUSER/Library/Developer/Xcode/DerivedData.
2- Open the project again and remove the podfiles inside your ios folder.
3- Open project terminal and run; flutter clean && flutter pub get
4- Get inside the newly generated podfile and make your desired changes like min. platfrom etc..
5- Open project terminal again and run;
-cd ios
-sudo gem install cocoapods
-pod install
Now you can try again to see if it works.

Try the following commands:
sudo gem install cocoapods --user-install

Related

I have to import mediasoup to sdk and into the project

I have MySDK framework that contains mediasop. When i import SDK to my project, i have to duplicate mediasoup too. If i don't duplicate, there is an error: No such module ‘WebRTC’.
I'm using mediasoup 1.5.3 version from there: https://github.com/ethand91/mediasoup-ios-client
Ready to give any additional info.
Have been trying to solve it for week, but can't find a way to fix it.
here is SDK podfile:
target ‘MySDK’ do
use_frameworks!
pod “mediasoup_ios_client”, ‘1.5.3’
end
post_install do |pi|
pi.pods_project.targets.each do |t|
t.build_configurations.each do |config|
config.build_settings[‘BUILD_LIBRARY_FOR_DISTRIBUTION’] = ‘YES’
config.build_settings[‘ONLY_ACTIVE_ARCH’] = ‘NO’
end
end
end
here is project podfile:
platform :ios, ‘12.1’
target ‘MyProject’ do
use_frameworks!
pod ‘MySDK’
pod “mediasoup_ios_client”, ‘1.5.3’
end
tried to add mediasoup to SDK locally but without success

what should I do to change the MACOSX_DEPLOYMENT_TARGET when build flutter macos app

I am building flutter(v3.0.4) macos app in macOS(v12.4 M1 chip) using this command:
~/fvm/versions/3.0.4/bin/flutter build macos --release
shows error like this:
➜ macos git:(main) ✗ ~/fvm/versions/3.0.4/bin/flutter build macos --release --no-tree-shake-icons
Changing current working directory to: /Users/xiaoqiangjiang/source/reddwarf/frontend/tik
💪 Building with sound null safety 💪
Running pod install... 668ms
--- xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:macOS, arch:arm64, id:00006000-001248980AE2801E }
{ platform:macOS, arch:x86_64, id:00006000-001248980AE2801E }
/Users/xiaoqiangjiang/source/reddwarf/frontend/tik/macos/Pods/Pods.xcodeproj: warning: The macOS deployment target 'MACOSX_DEPLOYMENT_TARGET' is set to 10.6, but the range of supported deployment target versions is 10.9 to 12.3.99. (in target 'FMDB' from project 'Pods')
Building macOS application...
I have already change the Pods and Runner deployment target to 10.11. what should I do to change the MACOSX_DEPLOYMENT_TARGET version? this is the macos podfile:
platform :osx, '10.11'
# 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', 'ephemeral', '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 Flutter-Generated.xcconfig, then run \"flutter pub get\""
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_macos_podfile_setup
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_macos_build_settings(target)
end
end
this is the Pods macOS deployment config:
I have already tried to clean the build and rebuild the macos app but still could not work as expect.
Went into my macos/Podfile and replaced the post_install method that looked like so…
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_macos_build_settings(target)
end
end
to look like so instead.
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_macos_build_settings(target)
target.build_configurations.each do |config|
config.build_settings['MACOSX_DEPLOYMENT_TARGET'] = '10.15'
end
end
end
source:
https://levelup.gitconnected.com/how-to-fix-your-flutter-macos-target-mismatch-bc55424b7c77
Hope it helps!
Open the macos folder in Xcode and select Pods in the project navigator. Choose the framework target and select the General tab.
Change this Deployment Target in the pods and save the changes that will resolve that issue
After hours looking for a solution, found it.
Need to change at 2 places but into the very same file.
The file is macos/Runner.xcworkspace
Reveal it in Finder, and open with XCode.
1st change in the file:
Runner > General > Minimum Deployment.
Set to minimum in the list or desired (in my case 10.13)
2nd change in the file:
Flutter Assemble > Build Settings > macOS Deployment Target.
Set to the same as before (in my case 10.13)
To switch to the Flutter Assemble, use the submenu below Runner. This was my confusion. The 2 changes need to be made in the very same file and only select Runner or Flutter Assemble with the upper menu under Runner.
See the following video with details too
https://youtu.be/iqGHugqyDiM
Hope this can help.
Attached 2 photos.
In xcode select the target then select build settings. Make sure it displays the combined options. Check valid architecture. Remove architecture which you arent using.
Also please take a back up of yhe project and run
pod install --repo-update

No podspec found for `FBReactNativeSpec` in `../node_modules/react-native/Libraries/FBReactNativeSpec`

I have upgrade react-native to 0.64 and I'm getting this error after I run pod install.
No podspec found for `FBReactNativeSpec` in `../node_modules/react-native/Libraries/FBReactNativeSpec`
I have tried to remove the node_module, remove the pod file, deintegrate, but still got this issue.
Any help?
The newer version of ReactNative (starting from 0.64) store FBReactNativeSpec in another folder.
You will need to replace the legacy FBReactNativeSpec path with the new one in the Pod declaration.
Open your Podfile and find this line :
pod 'FBReactNativeSpec', :path => "./node_modules/react-native/Libraries/FBReactNativeSpec"
And fix the path by replacing with this one :
pod 'FBReactNativeSpec', :path => "../node_modules/react-native/React/FBReactNativeSpec"
While I am updating to the new react-native version 0.64.1,then I got the above-mentioned error when I tried pod install.I have fixed the issue by replacing the content on my podfile like the following
https://raw.githubusercontent.com/react-native-community/rn-diff-purge/release/0.64.1/RnDiffApp/ios/Podfile
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/#react-native-community/cli-platform-ios/native_modules'
platform :ios, '10.0'
target 'RnDiffApp' 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
)
target 'RnDiffAppTests' do
inherit! :complete
# Pods for testing
end
# 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
I changed my podfile like the above.Then I tried pod install on my terminal.Its working fine.
Try npx react-native-clean-project
Input 'Y' for all the prompts asked.
I had the same question these days and found out it was because of the command npm audit fix i ran. It automatically updated react native version, which made podfile somehow confused. Downgrade your rn package or reset your version control should work

Xcode can't find a module, after updating

I've recently updated my Xcode, but I faced with strange issue.
I'm installing library via cocoapods and use it further in my project, but after updating I Xcode can't find the module, I've installed via CocoaPods
I've updating pods, but the problem stays.
Also I have Pods.framework red
What is the problem?
Podfile:
# Uncomment this line to define a global platform for your project
platform :ios, '9.0'
target 'Bloom' do
# Comment this line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for Bloom
target 'BloomTests' do
inherit! :search_paths
# Pods for testing
end
target 'BloomUITests' do
inherit! :search_paths
# Pods for testing
end
end
pod 'Firebase/Core'
pod 'Firebase/Database'
pod 'Firebase/Auth'
pod 'Gifu'
UPD: Solved it by opening the project with the .xcworkspace file not with .xcodeproj.
Do the following things and you can import any swift file from "Pods"
Clean your project
Make sure that all your "Pods" > "Build Settings" > "Build Active Architecture Only" is set to "NO".
Don't run, just build your project.
Now, import any file from "Pods" to any swift file
This will solve your import module problem.
Update:
To solve this issue delete the current pod file and create one using the terminal. Follow the below steps:
1) Open Terminal.
2) Navigate to your Project Path.
3) Type pod init in terminal to create new pod file.
4) Open the newly created pod file and write the pod line which you want to install after target "TargetName" do and before end.
5) Then type pod install in the terminal.
Hope this helps!
I had to delete my podfile and ALL the files it made including the .workspace file then I did:
pod init
open -a Xcode Podfile
add pods I want to podfile then save and close xcode.
Finally do pod install and open the new workspace file :)
change your pod file like this and clean the project quit xcode and reopen it.it may solve the problem
# Uncomment this line to define a global platform for your project
platform :ios, '9.0'
# Comment this line if you're not using Swift and don't want to use
dynamic frameworks
use_frameworks!
target 'Bloom' do
pod 'Firebase/Core'
pod 'Firebase/Database'
pod 'Firebase/Auth'
pod 'Gifu'
end
target 'BloomTests' do
inherit! :search_paths
# Pods for testing
end
target 'BloomUITests' do
inherit! :search_paths
# Pods for testing
end
Some frameworks in cocoapods declare a hard-link to XCode in the module description file (XMPP for example). So, be sure that you have:
place XCode.app in /Application (default folder), with name
"XCode.app", not Xcode-beta.app
or/and
call xcode-select to specify the right XCode.app:
sudo xcode-select --switch /Applications/Xcode.app
I had the same issue after I tried to merge a branch using Xcode (never again!).
What finally worked for me was:
Deleting derved data
Cleaning project
Exiting Xcode
Running 'pod install' again in my project

Hook in Podfile to edit my project file

I want to fix Cocoapods bug, when it adds Embed Pods Frameworks build phase for Extension targets. These phases are not needed there.
https://github.com/CocoaPods/CocoaPods/issues/4203
I wrote script to remove it
puts "Deleting not needed phases…"
project_path = "Keyboard.xcodeproj"
project = Xcodeproj::Project.open(project_path)
project.targets.each do |target|
if target.name.include?("Extension")
phase = target.shell_script_build_phases.find { |bp| bp.name == 'Embed Pods Frameworks' }
if !phase.nil?
puts "Deleting Embed Pods Frameworks phase…"
target.build_phases.delete(phase)
end
end
end
project.save
I can run this script after pod install manually, but I want to add it to Podfile somehow. It doesn't work in post_install hook
post_install do |installer|
...
end
because UserProjectIntegrator.integrate! is called after post_install and it overrides my changes.
Is there any way to integrate this script in Podfile?
The short answer is No.
The long answer:
From the output of pod install --verbose, the build phase Embed Pods Frameworks is added in the Integrating client project which runs after the post_install step in the Podfile.
This is why you should execute this script separately after the pod install finished running.

Resources