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.
Related
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
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
How does one delete a scheme created by CocoaPods in the post_install hook? It is a little convoluted, but this scheme is breaking Carthage builds for my SwiftMessages library.
According to this thread, deleting schemes is possible. However, I've looked through the CocoaPods reference and don't see a way to do it.
Update
Following Thiago Cruz's suggestion, I added the following post install hook to my project. Keeping it simple, I just blew away all of the user and shared data in the pods project.
post_install do |installer|
# Blow away schemes – the schemes created by CocoaPods break Carthage builds
# because they incluede a SwiftMessages framework that Carthage picks
# over the main SwiftMessages framework. The SwiftMessages framework that gets
# picked is configured for an app extension and doesn't work correctly in an app.
File.directory?(path)
[
"#{installer.sandbox.root}/Pods.xcodeproj/xcuserdata",
"#{installer.sandbox.root}/Pods.xcodeproj/xcshareddata"
].each { |path|
if File.directory?(path)
FileUtils.remove_dir(path)
end
}
end
In addition to this, I had to open the pods project and disable "Autocreate schemes" in the scheme management dialog. It's worth noting that pod install doesn't revert this setting.
Not sure which .xcscheme files you want to delete but in a post_install hook you have access to the root of your project and also the /Pods root. You could glob your way to the file and manually delete it.
post_install do |installer|
puts "#{installer.config.installation_root}"
puts "#{installer.sandbox.root}"
end
I just added Firebase pod and run Tests again:
Why there are firebase files? This is completely different target...
You need to add following line in your podfile in post_install
config.build_settings['CLANG_ENABLE_CODE_COVERAGE'] = 'NO'
This will cause setting code coverage for each pod to false, so any of your pods will NOT be visible in code coverage of your app.
Solution: Set the CLANG_ENABLE_CODE_COVERAGE flag in the build settings in your podfile
Unfortunately, no more changes are accepted for the existing solution, so here is the complete solution with the complete post-install phase code.
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
config.build_settings['CLANG_ENABLE_CODE_COVERAGE'] = 'NO'
end
end
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