I have project with 10+ targets in Xcode. I am using cocoapods to provide me some frameworks.
But Pod projects starting to grow (many files)
It is possible somehow configure Pod file to create one universal configuration, which is imported to other projects? Something like abstract target?
I don't need for each target create new pod framework, because all my targets using same pods.
Thanks for suggestion.
Something like this:
platform :ios, '11.0'
custom config 'Pods-framewrks' do
use_frameworks!
pod 'Alamofire'
end
project = Xcodeproj::Project.open “./MyProject.xcodeproj"
project.targets.each do |t|
target t.name do
import framework Pods // ???
end
end
If you put pod 'Alamofire' outside of any specific target, then it will be included in all targets.
For example:
platform :ios, '11.0'
pod 'Alamofire'
target 'FirstTarget' do
end
target 'SecondTarget' do
pod 'SwifterSwift'
end
I am using firebase for tracking crashes in my project and i am using the below pods in my project.
pod 'FirebaseCore', '6.6.4'
pod 'FirebaseMessaging', '4.3.0'
pod 'FirebaseAnalytics','6.3.1'
While archieving this project for placing the testflight build, i am getting duplication error below for google utilities :
Multiple commands produce '/Path/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/GoogleUtilities.framework':
1) Target 'GoogleUtilities-00567490' has create directory command with output '/Path//IntermediateBuildFilesPath/UninstalledProducts/iphoneos/GoogleUtilities.framework'
2) Target 'GoogleUtilities-54e75ca4' has create directory command with output '/Path//IntermediateBuildFilesPath/UninstalledProducts/iphoneos/GoogleUtilities.framework'
When I checked my Pods settings in my build setting, I saw google utilities added twice in project. I have removed the one of the GoogleUtilities it's getting an error.
Note: I can able to run the build and I can't able to archive it. Is there any fix for achieving this build, without changing the legacy build system?
Because I have enabled the library distribution for my SDK, so when I made changes into legacy its throws an error.
Adding pod 'GoogleUtilities', '~> 7.7.0' to all the targets that use Firebase pods will make it work. In my case, this included 3 targets: iOS app, iMessage Extension and UnitTests.
No need to add this part explicitly:
def google_utilites
pod 'GoogleUtilities/AppDelegateSwizzler'
pod 'GoogleUtilities/Environment'
pod 'GoogleUtilities/Logger'
pod 'GoogleUtilities/MethodSwizzler'
pod 'GoogleUtilities/NSData+zlib'
pod 'GoogleUtilities/Network'
pod 'GoogleUtilities/Reachability'
pod 'GoogleUtilities/UserDefaults'
end
Update the Podfile to explicitly request all the needed GoogleUtilties subspecs. Examine the Podfile.lock to find the list.
There is a lot more detail at this CocoaPods issue.
This issue occurred to me when i added a new target to my project using very similar but not equal firebase dependencies, so GoogleUtilities was duplicated because my other target doesn't need as much dependencies from utilities as the main one so, basically (with the help of Paul Beusterien answer) went to the Pods project and look at both targets (GoogleUtilities-xxx) -> Build Phases -> Compile Sources and look at the differences in files added, basically in the new target was missing 'GoogleUtilities/UserDefaults' and 'GoogleUtilities/MethodSwizzler' but this can be different in any case, so i just did a compilation like this
platform :ios, '13.0'
def google_utilites
pod 'GoogleUtilities/AppDelegateSwizzler'
pod 'GoogleUtilities/Environment'
pod 'GoogleUtilities/Logger'
pod 'GoogleUtilities/MethodSwizzler'
pod 'GoogleUtilities/NSData+zlib'
pod 'GoogleUtilities/Network'
pod 'GoogleUtilities/Reachability'
pod 'GoogleUtilities/UserDefaults'
end
abstract_target 'AggregatedPodsTarget' do
use_frameworks!
google_utilites
pod 'FirebaseCore'
pod 'FirebaseAuth'
pod 'FirebaseFirestore'
pod 'FirebaseStorage'
pod 'FirebaseFunctions'
pod 'FirebaseAnalytics'
pod 'FirebaseMessaging'
pod 'Firebase/Crashlytics'
pod 'Google-Mobile-Ads-SDK'
target 'MainApp' do
end
target 'MainApp Dev' do
end
end
abstract_target 'ExtensionPodsTarget' do
use_frameworks!
google_utilites
pod 'FirebaseAuth'
pod 'FirebaseFunctions'
target 'Extension' do
end
target 'Extension Dev' do
end
end
after this i just did pod install and i went back to have only one GoogleUtilities Dependency
This worked for me, it's similar to this Bogdan's answer
Summarising steps
Add pod 'GoogleUtilities' so they don't clash from different targets
Clean install your pods (pod deintegrate and pod install)
Might need pod repo update.
Reopen xcode and archive, you would see single GoogleUtilities now
I saw this error when I tried archiving one of my projects where I had recently introduced another new target.
Going into the pod settings for this new target, I noticed that the iOS deployment version was different (14.4) from the iOS deployment version in the main Runner target (12.0) - something I had missed when I was initially configuring this new extension target.
The only difference between the iOS deployment versions I saw was that 14.4 had App Extensions enabled. Since that was something inconsequential to my project, I was happy matching the iOS deployment
versions for both my targets so they could refer to only one set of dependencies. After that, I just removed the duplicate pods for the version that I had removed. And I could archive again.
For each of your Targets, got to Build Settings -> check the iOS Deployment Target -> change the version so that they match.
For most circumstances, there is no reason why they should be different. But if for some reason you deem they should be different, checkout Paul Beusterien's answer and follow that.
We had the similar issue on Flutter project using firebase_core and firebase_analytics dependencies. Adding pod 'GoogleUtilities', '~> 7.7.0' in all the targets in the Podfile under ios folder.
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 'customnotificationext' do
use_frameworks!
pod 'GoogleUtilities', '7.7.0'
end
I am writing an iOS app, using CocoaPods 1.6.0 as my dependency manager. My project consists of a iOS app project (myapp-ui), as well as 3 iOS framework projects (myapp-common, myapp-model, and myapp-editor). I'm also leveraging Fabric.io for crash reporting and app metrics. My myapp-ui and myapp-model projects both make use of the Fabric and Crashlytics frameworks. My Pods file looks like this:
platform :ios, '11.0'
workspace 'MyApp.xcworkspace'
project 'myapp-ui/myapp-ui.xcodeproj'
project 'myapp-common/myapp-common.xcodeproj'
project 'myapp-model/myapp-model.xcodeproj'
project 'myapp-editor/myapp-editor.xcodeproj'
target 'myapp-ui' do
use_frameworks!
project 'myapp-ui/myapp-ui.xcodeproj'
# Pods for myapp-ui
pod 'SwiftyBeaver'
pod 'SwifterSwift'
pod 'Fabric'
pod 'Crashlytics'
pod 'KeychainSwift', '~> 13.0'
target 'myapp-uiTests' do
inherit! :search_paths
# Pods for testing
end
end
target 'myapp-common' do
use_frameworks!
project 'myapp-common/myapp-common.xcodeproj'
# Pods for myapp-common
pod 'SwiftyBeaver'
pod 'SwifterSwift'
pod 'KeychainSwift', '~> 13.0'
end
target 'myapp-model' do
use_frameworks!
project 'myapp-model/myapp-model.xcodeproj'
# Pods for myapp-model
pod 'SwiftyBeaver'
pod 'SwifterSwift'
pod 'Fabric'
pod 'Crashlytics'
end
target 'myapp-editor' do
use_frameworks!
project 'myapp-editor/myapp-editor.xcodeproj'
# Pods for myapp-editor
end
The pods install just fine, and my app builds with no issue. However, when I run it I see a large number of errors in the console that look something like this:
objc[62607]: Class CLSInternalReport is implemented in both <SOME LOCATION>/Build/Products/Debug-iphonesimulator/myapp_model.framework/myapp_model (0x11252f960) and <SOME OTHER LOCATION>/myapp-ui.app/myapp-ui (0x10f2831e8). One of the two will be used. Which one is undefined.
objc[62607]: Class Crashlytics is implemented in both <SOME LOCATION>/Products/Debug-iphonesimulator/myapp_model.framework/myapp_model (0x11252f9b0) and <SOME OTHER LOCATION>/myapp-ui.app/myapp-ui (0x10f283238). One of the two will be used. Which one is undefined.
objc[62607]: Class CLSFileManager is implemented in both <SOME LOCATION>/Build/Products/Debug-iphonesimulator/myapp_model.framework/myapp_model (0x11252fa00) and <SOME OTHER LOCATION>/myapp-ui.app/myapp-ui (0x10f283288). One of the two will be used. Which one is undefined.
objc[62607]: Class CLSAlert is implemented in both <SOME LOCATION>/Build/Products/Debug-iphonesimulator/myapp_model.framework/myapp_model (0x11252fa78) and <SOME OTHER LOCATION>/myapp-ui.app/myapp-ui (0x10f283300). One of the two will be used. Which one is undefined.
Is there a way to address these warnings? I've tried removing them from myapp-ui thinking that myapp-ui makes use of myapp-model (and would therefore inherit the dependency) but that didn't work. I'm at a loss as to how to address this. Thoughts?
I was getting the same warnings you're seeing and took me a while to find a fix. Turns out this happens when you have a dependency that comes pre-compiled, like Fabric and Crashlytics. I think it's because they are copied twice.
What I did was to add those pods only to the app target. My Podfile ended up looking somewhat like this
def pods
pod 'CGMath'
...
end
def app
pod 'Crashlytics'
pod 'Fabric'
end
target 'FrameworkTarget' do
pods
end
target 'AppTarget' do
pods
app
end
I'm trying to figure out how to use Realm in both projects iOS and macOS of a single workspace.
At first try it fails to compile with more than 200 errors.
Workspace currently contains:
MyApp iOS project
MyAppMac macOS project
Pods project
Podfile:
workspace 'MyApp'
target 'MyApp' do
workspace 'MyApp'
xcodeproj 'MyApp.xcodeproj'
use_frameworks!
pod 'RealmSwift'
pod 'SVProgressHUD'
end
target 'MyAppMac' do
workspace 'MyApp'
xcodeproj 'MyAppMac.xcodeproj'
use_frameworks!
pod 'RealmSwift'
end
I just discovered that adding pod 'Realm' to MyAppMac target, works fine and produces no errors.
However, is this optimal?
I've seen some ways to reuse shared pods like RealmSwift but not sure how to do this given the configuration.
I want to integrate an action extension into my app. I generated an embedded framework with the shared code between app and extension.
Now I need to access a pod in the embedded framework. How do I link the pods into the framework?
You can use target to separate the pods for the app and your embedded framework.
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
target :App do
pod ...
pod ...
end
target :Framework do
pod ...
pod ...
end