Cocoapods: Pod install mess with : one workspace with multiple projects with different relative paths.

Created on 15 Jan 2013  Â·  24Comments  Â·  Source: CocoaPods/CocoaPods

Consider this layout :
platform :ios, '5.1'

xcodeproj 'Core/App1' do
    target App1
end

xcodeproj 'Core/PlugIns/MyPlugIn' do
    target MyPlugIn
end

Apparently, there is a unique PODS_ROOT used, and the last defined target wins. The other one gets a wrong path.

Most helpful comment

I was getting that same warning while I didn't a month ago. I don't understand the delta, however after some tweaking, I got it working again using

workspace 'test7.xcworkspace'

xcodeproj 'ios/ios.xcodeproj'

target :ios, :exclusive => true do
    platform :ios, '7.0'
    xcodeproj 'ios/ios.xcodeproj'
    pod 'Bean-iOS-OSX-SDK'
end

target :mac, :exclusive => true do
    platform :osx, '10.9'
    xcodeproj 'mac/mac.xcodeproj'
    pod 'Bean-iOS-OSX-SDK'
end

All 24 comments

I have had no problem defining different paths for projects defined inside a target, this gives me a different PODS_ROOT for each target.

platform :ios, '5.1'
target App1 do
  xcodeproj 'Core/App1'
end

target MyPlugIn do
  xcodeproj 'Core/PlugIns/MyPlugIn' 
end

Hmm ok I was obviously misunderstanding something, as my targets were embedded in my xcodeproj instead of the other way round.

However, I'm still facing an error with my updated layout.
Basically, I have App, SeedMaker and IAPSIm in the Core folder. I want them to be gathered in the Test.xcworkspace which one level above.

I would expect this to work :

platform :ios, '5.1'
workspace 'Test.xcworkspace'


target :App do
    xcodeproj 'Core/App.xcodeproj'
end

target :SeedMaker do
    xcodeproj 'Core/SeedMaker.xcodeproj'
end

target :IAPSim do
    xcodeproj 'Core/IAPSim.xcodeproj'
end

But I get an "[!] Unable to find an Xcode project to integrate" error :

Resolving dependencies of `./Podfile'
Resolving dependencies for target `default' (iOS 5.1)
Resolving dependencies for target `App' (iOS 5.1)
Resolving dependencies for target `SeedMaker' (iOS 5.1)
Resolving dependencies for target `IAPSim' (iOS 5.1)
Downloading dependencies
Using AFNetworking (1.1.0)
[...]
Generating support files
[!] Unable to find an Xcode project to integrate

_Update: Sorry about the image sizes, retina has its downfalls!_

I have just tested this and it does indeed still work.
I have a parent directory into which I placed my Podfile and a 'Core' folder, into Core I created 2 new empty projects.
DirectoryStructure

I have a Podfile with the contents

platform :ios, 5.0
workspace 'Core'

target :TestApp1 do
  xcodeproj 'Core/TestApp1'
    pod 'JSONKit'
  end
target :TestLib1 do
  xcodeproj 'Core/TestLib1'
   pod 'AFNetworking'
end

Which I use to install with output (verbose to show more)

$ pod install --verbose

Resolving dependencies of `./Podfile'

Updating spec repositories
Updating spec repo `master'
  $ /usr/local/bin/git pull
  Already up-to-date.

Resolving dependencies for target `default' (iOS 6.0)

Resolving dependencies for target `TestApp1' (iOS 6.0)
  - JSONKit

Resolving dependencies for target `TestLib1' (iOS 6.0)
  - AFNetworking

Downloading dependencies

-> Installing AFNetworking (1.1.0)
...

-> Installing JSONKit (1.5pre)
...

Generating support files
  - Running pre install hooks
  - Generating project
  - Installing targets
    - Generating xcconfig file at `./Pods/Pods-TestApp1.xcconfig'
    - Generating prefix header at `./Pods/Pods-TestApp1-prefix.pch'
    - Generating copy resources script at `./Pods/Pods-TestApp1-resources.sh'
    - Generating xcconfig file at `./Pods/Pods-TestLib1.xcconfig'
    - Generating prefix header at `./Pods/Pods-TestLib1-prefix.pch'
    - Generating copy resources script at `./Pods/Pods-TestLib1-resources.sh'
  - Running post install hooks
  - Writing Xcode project file to `./Pods/Pods.xcodeproj'
  - Writing lockfile in `./Podfile.lock'

[!] From now on use `Core.xcworkspace'.

Integrating `libPods-TestApp1.a' into target `TestApp1' of Xcode project `./Core/TestApp1.xcodeproj'.

Integrating `libPods-TestLib1.a' into target `TestLib1' of Xcode project `./Core/TestLib1.xcodeproj'.

[!] The target `TestLib1 [Debug - Release]' overrides the `OTHER_LDFLAGS' build setting defined in `../Pods/Pods-TestLib1.xcconfig'.
    - Use the `$(inherited)' flag, or
    - Remove the build settings from the target.

Core.xcworkspace:
CoreWorkspace

You can try deleting 'Podfile.lock', './Pods' and 'Test.xcworkspace' and running the install again, make sure you have no targets define that don't point to a valid xcodeproj/location relative to the Podfile.

First, many thanks for your time.
In order to get it to work, I had to move all the pods declarations into the targets and remove the general pods declarations.
For example, this doesn't work (mixed general and specific pod declarations) :

platform :ios, '5.1'
workspace 'Test'

pod 'RestKit',                          '~> 0.20.0pre5'
pod 'MagicalRecord',                    '~> 2.0.8'
pod 'MKNetworkKit',                     '~> 0.87'

target :App do
    xcodeproj 'Core/App.xcodeproj'
    pod 'LOG_EXPR'
end

target :SeedMaker do
    xcodeproj 'Core/SeedMaker.xcodeproj'
    pod 'LOG_EXPR'
end

target :IAPSim do
    xcodeproj 'Core/IAPSim.xcodeproj'
    pod 'LOG_EXPR'
end

This works :

platform :ios, '5.1'
workspace 'Test'

target :App do
    xcodeproj 'Core/App.xcodeproj'
    pod 'RestKit',                          '~> 0.20.0pre5'
    pod 'MagicalRecord',                    '~> 2.0.8'
    pod 'MKNetworkKit',                     '~> 0.87'
    pod 'LOG_EXPR'
end

target :SeedMaker do
    xcodeproj 'Core/SeedMaker.xcodeproj'
    pod 'RestKit',                          '~> 0.20.0pre5'
    pod 'MagicalRecord',                    '~> 2.0.8'
    pod 'MKNetworkKit',                     '~> 0.87'
    pod 'LOG_EXPR'
end

target :IAPSim do
    xcodeproj 'Core/IAPSim.xcodeproj'
    pod 'RestKit',                          '~> 0.20.0pre5'
    pod 'MagicalRecord',                    '~> 2.0.8'
    pod 'MKNetworkKit',                     '~> 0.87'
    pod 'LOG_EXPR'
end

Actually, what I would like to see working is the following (only general pods declaration), because I really want all projects to share the same static library (which makes sense, and which I have been able to achieve manually).

platform :ios, '5.1'
workspace 'Test'

pod 'RestKit',                          '~> 0.20.0pre5'
pod 'MagicalRecord',                    '~> 2.0.8'
pod 'MKNetworkKit',                     '~> 0.87'
pod 'LOG_EXPR'

target :App do
    xcodeproj 'Core/App.xcodeproj'
end

target :SeedMaker do
    xcodeproj 'Core/SeedMaker.xcodeproj'
end

target :IAPSim do
    xcodeproj 'Core/IAPSim.xcodeproj'
end

First, many thanks for your time.

I am new to the CocoaPods community so I am trying to get up to speed fast so playing with this stuff in my spare time really helps!

In order to get it to work, I had to move all the pods declarations into the targets and remove the general pods declarations.

This is good to know, I tried myself to make sure and this is indeed an issue.

Actually, what I would like to see working is the following (only general pods declaration), because I really want all projects to share the same static library (which makes sense, and which I have been able to achieve manually).

I agree that this would make sense and would be the intuitive way I would expect things to work.

This is indeed a problem.

In my projects I simply need several projects based on exactly same pods, wouldn't it be simpler if support multiple xcodeproj in a target section? Since creare a target will generate a separate .a and make the build time longer.

platform :ios, '5.1'
workspace 'Test'

pod 'RestKit', '~> 0.20.0pre5'
pod 'MagicalRecord', '~> 2.0.8'
pod 'MKNetworkKit', '~> 0.87'
pod 'LOG_EXPR'

xcodeproj 'Core/App.xcodeproj'
xcodeproj 'Core/SeedMaker.xcodeproj'
xcodeproj 'Core/IAPSim.xcodeproj'

I'm moving the discussion about the declarations to #840. Closing as the original issue appears to be solved.

it seems that something broke with the latest changes. Before a file like this was valid:

workspace 'Test'

target 'iphone'
    platform :ios
    pod 'RestKit'
    xcodeproj 'iphone/iphone.xcodeproj'
end

I believe this should be OK. I also have a gist with the stack dump of the error. I can also provide a repo with the demo project.

https://gist.github.com/fgarcia/5276818#file-gistfile1-txt

I am not sure if this should be posted here or in https://github.com/CocoaPods/CocoaPods/issues/840, but since it does not mention anything about a Podfile with workspace and xcodeproj I went for this thread

@fgarcia There is a Ruby syntax error in the declaration of the target block, it misses the block begin keyword do:

workspace 'Test'

target 'iphone' do
    platform :ios
    pod 'RestKit'
    xcodeproj 'iphone/iphone.xcodeproj'
end

ops! :-(

while I dry my tears in a corner of my room for such foolish mistake, I must confess that the Podfile like that still does not work.

I am getting the error:

[!] Could not automatically select an Xcode project. Specify one in your Podfile like so:
    xcodeproj 'path/to/Project.xcodeproj'

Just tried the latest version: 0.17.1

The project is just one template of xcode with no modifications.

Also, completely ashamed of my previous mistake, I did make sure that both paths do exist. For the workspace variable, I tried with and without the file extension.

@fgarcia No problem at all :) Can you create a new ticket for your issue and include a sample project that reproduces the problem?

The issue should be related to the default target (implicitly created at the root of the Podfile) not being able to find a project. For the moment, adding the xcodeproj directive to the outer level should fix the issue in that case as well. 
—
Sent from my iPhone

On Sun, Mar 31, 2013 at 1:39 AM, Eloy Durán [email protected]
wrote:

@fgarcia No problem at all :) Can you create a new ticket for your issue and include a sample project that reproduces the problem?

Reply to this email directly or view it on GitHub:
https://github.com/CocoaPods/CocoaPods/issues/738#issuecomment-15683897

I'm getting the same error as @fgarcia with two sub-projects in the attempted workspace.

[!] Could not automatically select an Xcode project. Specify one in your Podfile like so:
xcodeproj 'path/to/Project.xcodeproj'

What's frustrating is that it seems as if all the previous answers to this problem, like the following StackOverflow, used to work.

@irrationalfab was right, the problem was not having xcodproj in the outer level. This is the fixed Podfile, compare with the one I mentioned earlier https://github.com/CocoaPods/CocoaPods/issues/738#issuecomment-15675099

workspace 'Test'
xcodeproj 'iphone/iphone.xcodeproj'

target 'iphone' do
    platform :ios, '6.0'
    pod 'RestKit'
    xcodeproj 'iphone/iphone.xcodeproj'
end

@samkrishna I have not tried yet with two targets, but it should also fix your problem since a second target should override that variable

@alloy I can create a repo and upload this demo. Do you still need it once the reason of the problem is clear?

@fgarcia That got me _closer_.

Here's what my Podfile looks like now:

workspace 'BNR-MOVED'
xcodeproj 'Quiz/Quiz.xcodeproj'
xcodeproj 'RandomPossessions/RandomPossessions.xcodeproj'

pod 'MAKVONotificationCenter', '~> 0.0.2'

target 'Quiz' do
    platform :ios, '6.0'
    xcodeproj 'Quiz/Quiz.xcodeproj'
end

target 'RandomPossessions' do
    platform :ios, '6.0'
    xcodeproj 'RandomPossessions/RandomPossessions.xcodeproj'
end

Unfortunately, this triggered the error referenced in #920 . Not sure exactly where to go from here.

Same issue for me, that's not suitable for a stable version :-1:

@fgarcia No, that won’t be necessary after all then. @irrationalfab’s superpowers were apparently enough ;) Thanks!

@angrauel Next time please try the release-candidates.

Hi guys
Am trying to make use pods in my project but i get this error
[!] Could not automatically select an Xcode project. Specify one in your Podfile like so:
xcodeproj 'path/to/Project.xcodeproj'

This is how my pod file looks like:
platform:ios, '7.0'
workspace 'Anna'
target :Anna do
xcodeproj 'Anna/Anna.xcodeproj'
pod 'StreamingKit', '~> 0.1.20'
end

Any my folder structure is like so..
img

@kenjox I get the same

Any update on that issue?

I was getting that same warning while I didn't a month ago. I don't understand the delta, however after some tweaking, I got it working again using

workspace 'test7.xcworkspace'

xcodeproj 'ios/ios.xcodeproj'

target :ios, :exclusive => true do
    platform :ios, '7.0'
    xcodeproj 'ios/ios.xcodeproj'
    pod 'Bean-iOS-OSX-SDK'
end

target :mac, :exclusive => true do
    platform :osx, '10.9'
    xcodeproj 'mac/mac.xcodeproj'
    pod 'Bean-iOS-OSX-SDK'
end

@foobar8675 That helped me get started on something I was trying out. Thanks!

In case that someone happens the same that happened to me :)

I was working in a project with other developer and I had this issue.

What happened in my case was that the other developer had renamed the project and when I did a pull I ended with two .xcodeproj:

nameBeforeRename.xcodeproj
nameAfterRename.xcodeproj

Then when I was running pod install or pod update I get the message "Could not automatically select an Xcode project."

The solution was to just delete the old .xcodeproj and then run pod install.

Uncomment the next line to define a global platform for your project

platform :ios, '9.0'

project 'TestProject.xcodeproj'   <- *******(Need to mention protect name)**********

target 'BaalDahab' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!

# Pods for TestProject

pod 'Test_POd'
end

Was this page helpful?
0 / 5 - 0 ratings

Related issues

steffendsommer picture steffendsommer  Â·  3Comments

k06a picture k06a  Â·  3Comments

dawnnnnn picture dawnnnnn  Â·  3Comments

tlandsmancars picture tlandsmancars  Â·  3Comments

pallaviMN picture pallaviMN  Â·  3Comments