Using Cocoapods in a Workspace with two apps - xcode

I have two apps (xcode projects) that i want to have in one workspace. Since Cocoapods usually generates the workspace, i looked to see if it was possible to do this and found some answer. The recommended Podfile would look like:
workspace 'TestWorkspace'
target 'TestApp1' do
xcodeproj 'testApp1/testApp1.xcodeproj'
workspace 'TestWorkspace'
pod 'AFNetworking'
end
workspace 'TestWorkspace'
target 'TestApp2' do
xcodeproj 'TestApp2/TestApp2.xcodeproj'
pod 'MBProgressHUD'
end
(sorry wasn't sure how to have SO format the Ruby code)
So my folder structure looks like a TestWorkspace folder, with the two App projects folders, and the Podfile. Running pod install
[!] xcodeproj was renamed to project. Please update your Podfile accordingly.
and..
[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target TestApp1 to ../Pods/Target Support Files/Pods-TestApp1/Pods-TestApp1.debug.xcconfig or include the ../Pods/Target Support Files/Pods-TestApp1/Pods-TestApp1.debug.xcconfig in your build configuration (TestApp1/Pods/Target Support Files/Pods-TestApp1/Pods-TestApp1.debug.xcconfig).
So my question is what changes must be made to wind up with my TestWorkspace workspace having three projects: TestApp1, TestApp2, and Pods?
(btw, i changed the true names of my projects/workspaces to pseudo-aliases for the purposes of posting here. Hopefully, I changed everything faithfully.)
EDIT: Ok so i fixed the first warning (just a change in podfile syntax from xcodeproj to project). However, my workspace is definitely not being configured properly. I don't even see a Pod project after pod installing.
EDIT2: OK so i fixed the second warning by setting both project configuration files (debug and release) to "none". So now I have no errors, but the Pod project is still no where to be found. (Sorry if i'm solving parts of the question but I think its better to add edits than to create a new question).

Use the targets as scopes for the xcproject/workspaces. Update the podfile to something like this:
workspace 'TestWorkspace'
target 'TestApp1' do
xcodeproj 'testApp1/testApp1.xcodeproj'
workspace 'TestWorkspace'
pod 'AFNetworking'
end
target 'TestApp2' do
xcodeproj 'TestApp2/TestApp2.xcodeproj'
workspace 'TestWorkspace'
pod 'MBProgressHUD'
end
Now run pod install --verbose

Related

Can't add "MidiParser" pod to Podfile

I am trying to add this github project to my project as a pod: https://github.com/matsune/MidiParser
In my PodFile, I have tried
pod 'MidiParser'
and
pod 'MidiParser', :git => 'https://github.com/matsune/MidiParser.git'
but either time I get the error
Unable to find a specification for 'MidiParser'.
I have tried adding other pods like 'https://github.com/daltoniam/SwiftHTTP' just to see if they work, and they do. I notice there are multiple projects on GitHub called MidiParser, so maybe I need to distinguish between them somehow? The installation instructions in the MidiParser README only give instructions for Carthage. It says to add this line to the Cartfile:
github "matsune/MidiParser"
I also have also tried:
pod 'matsune/MidiParser'
I notice I can't find the project when I search for it here: https://cocoapods.org.
Does that mean I simply can't install the project using Cocoapods, and that I have to do it manually?
Edit: I ended up using Carthage.
CocoaPods requires pods to be specified with a podspec to describe its Xcode workspace integration. See https://guides.cocoapods.org/making/making-a-cocoapod.html

Cocoapods use_frameworks! caused strange compiler errors in the old OC codes

I added use_frameworks! in my pod file, running pod install again (without any other changes). Then I got the compiler error like 'Masonry.h' file not found with <angled> include; use "quotes" instead.
Although I believed those pod header files should be used with <...> I did change them to "...". But then I got the error like Redefinition of 'FMTokenizerCursor' (from FMDB pod)
I felt like this maybe a cocoapod bug (I am using 1.0.1) so I upgraded it to cocoapods-1.1.0.beta.2, same error. pod deintegrate & pod install made no difference.
I found these is a similar question here. But the answers there did not work for me.
I tried both Xcode 7 & 8, clean ~/Library/Developer/Xcode/DerivedData
same error too.
I met the same problem as you, I try to search for Search Paths in the Build Settings of the project, then add to the User header search paths $ (SRCROOT) and select recursive. But that does not work ... Then I put the "use_frameworks!" was removed from the podfile, recompile the project, problem solved =-=
Here's an example for a Podfile using the new format. (This example project has 2 targets), Try it.
also, make sure you don't edit this file in textEdit. (xCode is preferred)
abstract_target 'YourProject-abstract' do
use_frameworks!
pod 'Alamofire', '3.5.0'
pod 'ObjectMapper'
pod 'FBSDKLoginKit'
pod 'FBSDKCoreKit'
pod 'AlamofireImage'
target 'MyProject' do
end
target 'MyProject-staging' do
end
end

Cannot find module FBSDKCoreKit Cocoapods

I'm trying to integrate facebook into my app using CocoaPods, using the use_frameworks! tag, and according to facebook's instructions here, also included the pod bolts. When I try use import FBSDKCoreKit in my appdelegate, I get a no such module 'FBSDKCoreKit error. I've included my podfile below:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.2'
use_frameworks!
pod 'Bolts'
pod 'Alamofire', '~> 3.0'
pod 'FBSDKCoreKit'
pod 'FBSDKShareKit'
pod 'FBSDKLoginKit'
Additionally, in my Pods folder, there is a question mark next to Bolts, FBSDKCoreKit, and FBSDKSharekit, but not one next to alamofire, which I had been using previously. In the Frameworks folder in my Pods project, FBSDKCoreKit and Bolts are listed there, but are both red.
Any ideas? I've tried cleaning my project, and reinstalling and updating the pods.
For people moving from Carthage to Cocoapods make sure to remove the Carthage references of the FBSDKCoreKit from the Link Binary With Libraries under Build Phases option.
Please try below steps,
Explicitly mention the versions i.e.
pod 'FBSDKCoreKit', '~>5.8.0'
pod 'FBSDKShareKit', '~>5.8.0'
pod 'FBSDKLoginKit', '~>5.8.0'
Update pod repo using sudo pod repo update
Update pod using pod update
Seems that the facebook pods are Objective-C and they need a special way of importing in a swift project.
This is how I got it to work:
Create a bridging header in your project, if you dont have one(I created a new header file called Bridging-Header.h and set it as a bridging header in the project settings, like in the screenshot)
Then in this file import the facebook modules. Here's how my file looks like:
#ifndef Bridging_Header_h
#define Bridging_Header_h
#import FBSDKCoreKit;
#import FBSDKLoginKit;
#endif /* Bridging_Header_h */
Let me know if this workout for you or you need more help.
I fixed this by
Removing the Bridging Header. Facebook SDK doesn't need them anymore after version 4.1
Adding all of the .frameworks to the Projects Build Phases -> Link Binary With Libraries
Selecting each framework and building it. You can do this by selecting your project name next to the run arrow.
Cleaning the project and restarting my computer.
Very simple solution, if you are using Apple Swift Packages:
Go to Navigator pane and select the project
Then make sure you choose project name under "Project" not under "Targets"
Then select Package Dependencies tab
You will find the Facebook package there, double click on it
Change version to 9.0.0 and click "Done"
Rebuild, and it should be corrected.
Note that you may need this url to add Facebook SDK as Apple Swift Packages rather than Cocoapods.
You can try :
pod 'FBSDKCoreKit/Swift'
first add in pod file
pod 'FacebookCore'
pod 'FacebookLogin'
pod 'FacebookShare'
this is facebook swift library,after that before using FBSDKCoreKit,just use FacebookCore then import FBSDKCoreKit

Incorrect path for Pods.debug.xcconfig in Xcode?

so I used Venmo/Synx on my Xcode project with CocoaPods, and it completely screwed everything up.
I was able to fix the Manifest.lock and Podfile.lock errors, but now I am getting this error:
The file “Pods.debug.xcconfig” couldn’t be opened because there is no such file. (/Users/user/GitHub/xxxxxx/Pods/Pods/Target Support Files/Pods/Pods.debug.xcconfig)
As you can see, the path is incorrect, as there is no Pods/Pods directory (there is one extra pod).
How can I fix this? I have only added PODS_ROOT to the user-defined variable, as that fixed my Podfile and Manifest.lock files.
Any help would be much appreciated!
Edit:
After adding PODS_ROOT, I get this when running pod install.
[!] The `Project [Debug]` target overrides the `PODS_ROOT` build setting defined in `Pods/Target Support Files/Pods/Pods.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
I had the same problem in Xcode 6.1.1. I did the following to solve it:
Set the configuration file setting* "None" for the Pods related target.
Close the .xcworkspace.
run pod install again
now open and build your .xcworkspace
*The configuration file setting is found by selecting the project (not the target) and then the Info tab.
If your path to pods in error is wrong try this:
use pod deintegrate
delete all pod remains files - Podfile.lock, Pods, <Project>.xcworkspace
open <Project>.xcodeproj
remove Pods project on left side
try pod install
I had the same problem with Xcode 11 but I just updated CocoaPods and it worked.
Update CocoaPods to latest version with sudo gem install cocoapods
Run pod install again
I had the same error while trying to build my project for the first time. This is how I resolved it:
pod deintegrate
sudo gem install cocoapods-clean
pod clean
Open the project and delete the “Pods” folder that should be red.
pod setup
pod install
Reopen and build the project, I think it's good to go!
I faced this issue when I upgraded/downgraded cocoapods between 1.6.x and 1.5.x.
The following step fixed this error
1, go to project info tab
2, just under Deployment target, there is configurations field. change your configuration. In my case, there are 2 options
/Users/user/GitHub/xxxxxx/Pods/Pods/Target Support Files/Pods/Pods.debug.xcconfig
/Users/user/GitHub/xxxxxx/Pods/Target Support Files/Pods/Pods.debug.xcconfig
3, clean and build again.
1- Remove your Pods folder Podfile.lock and xcworkspace files root in your project.
2- Open .xcodeproj
3- Go to Build Settings and under Build Options search Always Embed Swift Standard Libraries
4- Update its value with $(inherited)
5- Close project and pod install again
There has been an update to cocoa pods that is causing this problem. Please refer to the cocoa pods release notes :
Change shell script relative paths to use ${PODS_ROOT} instead of ${SRCROOT}/Pods.
Whirlwind #7878
This was done in version 1.6.0.beta.1 (2018-08-16)
Release notes are here: cocoapods release notes
I had the same error and I fixed in following way
1 - Goto your projected setting by blue icon of your project from left pan
2 - Select your project under the project
3 - Select Info window
4 - Check IOS deployement target. This target should be same as you set in general settings of your project (Pic 2).
I got the same situation in Xcode 10.1. This is what works for me.
Open <Project>.xcworkspace
Go into your <project_name> folder(by default it's blue), delete the Pods folder (by default it's yellow)
In Terminal.app, run pod install again
Then I'm able to CMD + R to run the simulator
A few things worth trying:
As Keith mentioned above, you definitely want to exclude Pods from synx.
You almost certainly do not want to override the PODS_ROOT build setting.
I've seen similar errors to yours in a project with multiple targets. Make sure that your Podfile includes a link_with setting that specifies all your app targets.
If you have at least one test target, consider using your Podfile to explicitly import all your app pods to both your application and test targets.
I've not too much experience using a custom xcconfig with CocoaPods, but you might first try removing your xcconfig and allowing CocoaPods to generate its own first.
Close project
Do pod deintegrate
Delete - Podfile.lock, Pods,.xcworkspace in project directory
Do sudo gem install cocoapods
Do pod install
Go to project directory right click on
project.xcodeproj -> show package contents -> open project.pbxproj
Find
"Pods/Target Support Files/
and replace with
"Target Support Files/
This solution will work at any cost!
Try deleting the debug.xcconfig file and run pod install again. It solved my issue
In my case, I deleted my Podfile, Podfile.lock.
Run pod init, then copy all pods to new Podfile, then run pod install again and it's worked.
I think it's happened for the differences from folder paths in the old project (for me, I cloned another project from Git repo).
For me, changing Build system to Legacy in File -> workspace settings did the trick
For me, this caused after I updated cocoapods. So, I downgraded and the build worked again.
To downgrade, first list of all your versions:
sudo gem list cocoapods
Then specify the you want to delete (for me was 1.8.4):
sudo gem uninstall cocoapods -v 1.8.4
Then, with 1.5.3 worked!
This is what worked for me !
I use always Bundler to manage ruby dependencies, then in all my iOS projects i have Gemfile that look like this !
source "https://rubygems.org"
gem "cocoapods"
gem "fastlane"
gem "jazzy"
gem 'xcodeproj', :git => 'https://github.com/CocoaPods/Xcodeproj.git'
gem 'fastlane-plugin-teams', :git => "https://github.com/mbogh/fastlane-plugin-teams"
plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')
eval_gemfile(plugins_path) if File.exist?(plugins_path)
i just run the following, i advice you using alias for this :
## Alias to add in zshrc or bashrc
# bundle install
bdli() {
bundle install $#;
}
piu() {
kill $(ps aux | grep 'Xcode' | awk '{print $2}');
pod deintegrate;
pod repo update;
pod install;
pod update;
open -a Xcode *.xcworkspace;
}
then simply run :
bdli && piu
It will do everything for you :)
PS : To install Bundler go here -> Bundler
pod reintegrate
pod install
edit the .xcodeproj/project.pbxproj file and change the PBXGroup "path = Pods" to "name = Pods"

Cocoapods - include certain dependencies only for XCTest files

I have the following Podfile:
platform :ios, '7.0'
pod 'CocoaLumberjack'
target :MyProjectTests do
pod 'OCHamcrest'
end
I want to include CocoaLumberjack in all targets and OCHamcrest only in the test target. This seems to work great when I was using GHUnit (as I had to create a specific GHUnit test target).
However, I thought I would try XCTest to see how I like it (given that GHUnit seems to be getting a few cobwebs and has changed ownership recently).
When I check my Pods.xconfig, it shows that it is including OCHamcrest
HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers" "${PODS_ROOT}/Headers/CocoaLumberjack" "${PODS_ROOT}/Headers/OCHamcrest"
So, it looks like XCTests are not a separate target.
What can I do to ensure that I'm not including testing frameworks in my release build? Is this something I have to manually manage or can Cocoapods do this for me?,
This should do the trick.
target :MyProjectTests, :exclusive => true do
pod 'OCHamcrest'
end
Source: http://guides.cocoapods.org/syntax/podfile.html#target

Resources