Duplicate target after "pod install" - ios

After I added new dependency to my project and run pod install, I have duplicate target in my workspace(.xcworkspace) as below:
And this is the pod file structure:
platform :ios, '8.0'
use_frameworks!
pod 'AFNetworking', '~> 2.6'
pod 'Fabric'
pod 'Crashlytics'
pod 'SocketRocket'
I restart the project and also Xcode, but it does not help. What is the reason and how can I solve the problem?

First, try to wrap your pods with target specification, like this:
target 'TargetName' do
pod 'Fabric'
pod 'Crashlytics'
#other pods
end
Delete your .xcworkspace, podfile.lock and pods folder, just as #SukruK suggested.
Do pod install again and open the workspace created.
You can do the following instructions in order to fix this configuration issue CocoaPods did not set the base configuration of your project because your project already has a custom config set.
Go to your project settings
Set None configuration set for both Pods-related targets
Run pod install again

Related

IOS - How to Fix the "ld: library not found for -lBolts" Error?

I've got this annoying error for number of days now:
I've tried:
Deleting pods folder & pod file & pod.lock file & .workspace file and reinstalling pods again.
removing all library search paths in pods.xconfig file
this is my pod file :
# Uncomment the next line to define a global platform for your project
platform :ios, '11.0'
target 'MyApp' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# Pods for MyApp
pod 'Firebase'
pod 'Bolts'
pod 'Firebase/Firestore'
pod 'Google-Mobile-Ads-SDK'
pod 'Fabric'
pod 'Crashlytics'
pod 'PersonalizedAdConsent'
pod 'Highcharts', '~> 6.1.0'
pod 'FBSDKCoreKit'
pod 'GoogleToolboxForMac'
pod 'FirebaseAnalytics'
end
This is my problem, If you need any other indications or code about my issue, feel free to leave me a comment and I'll edit the question
Try to run following commands in Terminal (in your project's folder):
pod deintegrate // removes all pod related configurations from your project
rm Podfile.lock //removes the saved reference to the pods
pod install // reinstalls the pods
Clean your project (In Xcode: ⌘+K and ⌘+Shift+K)
And finally make sure you compile the same target from which the error originates (You should be able to see the target it originates from within the issue navigator ⌘+5)

Flutter: Making Podfiles work

I'm trying to add the Facebook SDK to one of my Flutter projects. In a regular Podfile, it'd look something like this:
# Pods for facebooklogintest
pod 'FBSDKCoreKit'
pod 'FBSDKShareKit'
pod ‘FBSDKLoginKit’
With "facebooklogintest" being the name of my project. The Podfile in Flutter projects looks a bit different. Is it correct to add the pod files under "# Pods for Runner"?
# Pods for Runner
pod 'FBSDKCoreKit'
pod 'FBSDKShareKit'
pod ‘FBSDKLoginKit’
I'm getting the following error when I try to install it as shown above:
[!] Invalid `Podfile` file: Please set FLUTTER_FRAMEWORK_DIR to the directory containing Flutter.framework.
Where and to where should I point this file to get rid of this error?
Try this :
def fbPods
pod 'FBSDKCoreKit'
pod 'FBSDKShareKit'
pod ‘FBSDKLoginKit’
end
target 'facebooklogintest' do
fbPods
end
target 'Runner' do
fbPods
end
Run this command
pod install --no-repo-update
In bash_profile,
export FLUTTER_FRAMEWORK_DIR=/flutter/bin/cache/artifacts/engine/ios
source ~/.bash_profile
In iOS folder,
pod install

AFNetworking.framework: No such file or directory in Xcode 8

I just opened my project in Xcode 8.0 and tried to build it, but the following "PBXCp Error Group" appeared:
error: /Users/username/Documents/XYZ/build/Debug-iphoneos/AFNetworking.framework: No such file or directory
My Podfile is below:
platform :ios, '10.0'
use_frameworks!
target 'XYZ' do
pod "MSSTabbedPageViewController"
pod "SKStatefulTableViewController", "~> 0.1"
pod "QBFlatButton"
pod "LTNavigationBar"
pod "KBRoundedButton"
pod "CTCheckbox"
pod "SKStatefulTableViewController", "~> 0.1"
pod "SDWebImage"
pod "TOCropViewController"
pod "UIImageViewAligned"
pod "AFNetworking"
pod "MBProgressHUD"
pod "JSONModel"
pod "CWStatusBarNotification"
pod "Firebase/Messaging"
pod "MaterialControls"
pod "Fabric"
pod "Crashlytics"
end
Pod is installed and OK.
I don't know what I did, since Cocoapods seems to be in the build folder.
I've had the same issue. Adding and removing AFNetworking from podfile didn't help at all. The only thing that worked for me was to remove AFNetworking.framework and add it again from correct path. The original path was pointing to wrong direction...
change the platform :ios, '10.0' to older platform and update pod file it will work fine for me.
try to add it properly because i had recently install all pod file in my side it working fine for me.remove your pod file and then install it.
Checking the item "Copy only when installing" in build setting just worked for me.

Xcode/Cocoapods Project messed up after adding a TVOS Target and changing Podfile structure

I'm working on a larger project(Swift) with some Pods and everything was fine so far...
Bu now I wanted to add a tvos target and now my project is messed up :(
And there is an easy way to reproduce:
1.) create a new SingleView Application and name it "pod-test" in Xcode
2.) open it an run it
3.) run pod init to create the Podfile
4.) Edit the Podfile with this:
use_frameworks!
platform :ios, '8.0'
pod 'Alamofire'
pod 'ObjectMapper'
pod 'AlamofireObjectMapper'
pod 'Fabric'
pod 'Crashlytics'
pod 'Nuke'
pod 'MGSwipeTableCell'
pod 'GradientCircularProgress', :git => 'https://github.com/keygx/GradientCircularProgress'
pod 'Reveal-iOS-SDK', :configurations => ['Debug']
5.) run pod install
6.) open workspace project file an run the application
7.) now add the twos target and name it "pod-test-tvos"
8.) run iOS and tvos app. Everything still fine
9.) edit the Podfile with this:
source 'https://github.com/CocoaPods/Specs.git'
target 'pod-test' do
use_frameworks!
platform :ios, '8.0'
pod 'Alamofire'
pod 'ObjectMapper'
pod 'AlamofireObjectMapper'
pod 'Fabric'
pod 'Crashlytics'
pod 'Nuke'
pod 'MGSwipeTableCell'
pod 'GradientCircularProgress', :git => 'https://github.com/keygx/GradientCircularProgress'
pod 'Reveal-iOS-SDK', :configurations => ['Debug']
end
target 'pod-test-tvos' do
use_frameworks!
platform :tvos, '9.0'
pod 'Fabric'
pod 'Crashlytics'
end
10.) Edit configuration for pod-test and pod-test-tvos to none
10.) close XCode
11.) run pod install again
12.) Open Xcode again
13.) run iOS and TVOS apps again... Still everything is fine
14.) edit "AppDelegate" for both targets and add just this import:
import Fabric
15.) run iOS and TVOS apps again... and boom... iOS runs fine TVOS says Fabric is not found :(
This all just happens, because I "changed" the Podfile after adding the TVOS target...
With just this steps everything is fine:
1.) create a new SingleView Application and name it "pod-test" in Xcode
2.) now add the twos target and name it "pod-test-tkos"
3.) run pod init to create the Podfile
4.) edit the Podfile with this:
source 'https://github.com/CocoaPods/Specs.git'
target 'pod-test' do
use_frameworks!
platform :ios, '8.0'
pod 'Alamofire'
pod 'ObjectMapper'
pod 'AlamofireObjectMapper'
pod 'Fabric'
pod 'Crashlytics'
pod 'Nuke'
pod 'MGSwipeTableCell'
pod 'GradientCircularProgress', :git => 'https://github.com/keygx/GradientCircularProgress'
pod 'Reveal-iOS-SDK', :configurations => ['Debug']
end
target 'pod-test-tvos' do
use_frameworks!
platform :tvos, '9.0'
pod 'Fabric'
pod 'Crashlytics'
end
5.) run pod install
6.) open workspace project file an run the application
7.) edit "AppDelegate" for both targets and add just this import:
import Fabric
8.) run iOS and TVOS apps again... Still everything is fine
So, there seems to be a problem with changing the Podfile in an "older" Project...
I hope somebody can help me out with this :)
This can be resolved by using the deintegrate command in Cocoapods 1.0.
Close Xcode
Open Terminal and navigate to the directory that contains your Podfile.
pod deintegrate
pod install
Open your workspace in Xcode and build.
I had exactly the same problem. I don't know why. Inspired by your experimentation, I downloaded the Cocoapods app, and used it to remove Cocoapods from my project. I then reinstalled cocoapods and now it works just fine.

How to install new pods witout affecting other pods?

I'm facing a problem with my pods.
I edited some pods, and when I request a new pods using "pod install", the edited pods will be cleaned and installed again.
Is there a way to install new pods or update specific one without affecting others?
No. When you install new pods, all the pods will be reset accordingly. If you need to make changes to an API you want, you should rather add it in your project manually instead of using it as a pod.
This way, you can add any amount of pods without affecting that particular API, and your changes will be saved properly as well.
Actually, there is a workaround: just specify exact versions of pods in your Podfile.
For example:
Podfile:
# Uncomment the next line to define a global platform for your project
platform :ios, '10.0'
target 'TestApp' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for TestApp
pod 'RxSwift', '4.1.2'
pod 'RxCocoa', '4.1.2'
pod 'Alamofire', '4.6'
pod 'SwiftyJSON', '4.0'
pod 'ObjectMapper', '3.1'
pod 'SVProgressHUD', '2.2', :inhibit_warnings => true
pod 'IQKeyboardManagerSwift', '5.0.7'
pod 'Validator', '3.0', :inhibit_warnings => true
end
As you can see in my Podfile all pods have exact specified versions (i.e. without ~>).
So if you add your pod in this kind of Podfile, then only it will be installed, cause the other ones are already installed.

Resources