49

I am trying to run Aplication which I have downloaded from GitHub.

When I run get error unable to open file in target, I have Xcode 10.

I already searched for solution and get this one.

I had the same problem, but in Xcode 6.1.1 - what fixed it for me was to change the configuration file setting to None for the two Pods-related targets, then run pod install again.

The configuration file setting is found by selecting the project (not the target) and then the Info tab.

But cant find configuration file location.

Here is the error picture: https://i.stack.imgur.com/Ql3M5.png

Jerry Chong
  • 7,954
  • 4
  • 45
  • 40
whatlOol
  • 611
  • 1
  • 5
  • 7

16 Answers16

50

A solution I found to work for me was

Inside the project root directory

root
  |- <ProjectName>
  |- <ProjectName>.xcodeproj
  |- <ProjectName>.xcworkspace
  |- <ProjectName>Tests
  |- Podfile
  |- Podfile.lock
  |- Pods

Delete the following files. Ensure you have copied the contents of Podfile.

  1. Podfile
  2. Podfile.lock
  3. Pods Folder

Open your .xcodeproj using Xcode or using terminal command

open <ProjectName>.xcodeproj

Inside Xcode, locate the "Pods" folder which should contain something along the lines of...

Pods
|- Pods-<ProjectName>.debug.xconfig
|- Pods-<ProjectName>.release.xconfig

Delete those references and select "move to trash" when prompted.

Close Xcode

Now run the following:

pod init && pod install

Open your Podfile and paste in your previously copied old Podfile that was deleted earlier.

run the following command:

pod install

In terminal open Xcode again with the following command

open <ProjectName>.xcworkspace

Note: that I opened the xcworkspace file NOT the xcodeproj file.

At this point for me I was able to compile my code as normal without having to change back to the Legacy Build System.

TimD
  • 1,090
  • 11
  • 22
  • 2
    Awesome solution! This worked for me. Much better than using the legacy system. This should be the top answer. – Cole James May 31 '19 at 06:00
  • 3
    This is how answer should be provided step by step.Excellent answer. – Peter Walter Jun 26 '19 at 07:28
  • Why there are a references in .xcodeproj that should be deleted although it's the first time to clone the project and "pod install" – Ahmed Saeed Jul 31 '21 at 06:34
  • @AhmedSaeed I believe what you are asking is when you clone the project you do not see the xcodeproj? It really depends on how the maintainer has chosen to establish the project. It is possible to commit and upload all the pods for a project. This is not the recommended approach however it affords cloners the ability to compile without the need to run `pod install` or have cocoa pods at all. By default, when you instantiate pods based project, it will create a workspace for you and this should be committed in the repo. – TimD Dec 18 '21 at 02:45
  • For reference: Cocoapod documentation https://guides.cocoapods.org/using/using-cocoapods.html @AhmedSaeed – TimD Dec 18 '21 at 02:47
45

In File -> Project setting -> select Legacy Build System

Make sure you have opened .xcworkspace file and pod installed properly.

Saeed All Gharaee
  • 1,546
  • 1
  • 14
  • 27
Pushp
  • 1,064
  • 10
  • 18
20

Reinstall the pods to get everything cleaned up:

pod deintegrate
pod cache clean --all
pod install    
Ben
  • 3,346
  • 6
  • 32
  • 51
12

This happened due to change the Project Name or Miss the Pods from Your Project

if the Pods are Miss Then Following Method

  1. open the Project and Command + Shift + K
  2. Close the Project
  3. Open Terminal got to Your Xcode Project Directory cd /your-Xcode-project
  4. if coca pods are already installed so skip this Point if not sudo gem install cocoa pods run this Command on terminal
  5. pod install

If Above Method not Working so its Project name Issue then Go with following Method

  1. First, open your Pod File and change the target
  2. target 'your Xcode project name' do

run the Following Commands from Terminal

go to Your directory from terminal

pod deintegrate

pod clean

pod install

Done now open your xcWorkSpace file

Imran Rasheed
  • 825
  • 10
  • 25
10

For me it works, update the version of CocoaPods and reinstall the pods

sudo gem install cocoapods
DiegoQ
  • 1,114
  • 11
  • 20
  • Yes, we need to update the `cocoapods` I was using 1.5.3 version where it wasn't able to `deintegrate` the project properly. Had to use the updated version to do that. I am using XCode 11.1 now. – Praveenkumar Oct 21 '19 at 12:13
8

Run following commands after you have downloaded Xcode project from GitHub:

cd /your-xcode-project
pod install

This worked on Xcode 10.2.

Jerry Chong
  • 7,954
  • 4
  • 45
  • 40
7

I had this issue too with project I cloned from GitLab. Your error looks extremely similar to mine. I solved it by running this in Terminal:

cd path/to/your/project
pod install

When I checked project folder in Finder, there was a Podfile. But same project viewed in Xcode had nothing under 'Pods' module. From this I figured out the pods are not installed (or installed properly?) and installing them solved this error.

If there is some Pods or .xcworkspace file, it might be worth doing pod deintegrate before installation - just to be sure :)

DeepBlue
  • 591
  • 9
  • 18
6

I was facing the same error opening an old project in a new macbook with a recent installation of Xcode and no cocoa pods or anything related on it.

My way to fix this was following some of the steps en the issues #1727 of alamofire and change some things. Open the terminal and cd project where the pod file is.

So, this is what worked for me:

  • sudo gem install cocoa pods
  • pod repo remove master
  • pod setup
  • pod repo update
  • pod install

Then just, clean build folder and build the project.

karique
  • 533
  • 6
  • 17
4
  1. Quit Xcode
  2. Open Terminal
  3. Change to directory (where podfile is present)
  4. pod install

I was trying to do pod install after removing unwanted pod(steps 2,3 & 4), but it still was not working. Quitting Xcode (steps 1, 2, 3 & 5) worked.

Saif
  • 2,678
  • 2
  • 22
  • 38
2

If you suddenly start seeing this issue on an existing project, before you try anything else, try

  • pod update
  • Make sure your pod build settings looks good
  • Clean build folder
  • Retry building
N Kurt
  • 134
  • 1
  • 3
2

1- in xcode menu --> project --> clean build files

2- close project

3- in terminal cd

4- in terminal pod update

5- re-open project..xcworkspace file

6- clean, build

good luck

Omar
  • 85
  • 4
2

delete file name "Podfile.lock" and try pod install again.

Papon Smc
  • 576
  • 4
  • 11
  • Isn't this the same as just running 'pod update'? In which case it will update to newer versions of the specified pods. – xdeleon May 11 '19 at 04:59
2

Just stumbled into the issue recently myself. It seems it's a bug in CocoaPods.

Possible fix: gem install cocoapods --pre

πter
  • 1,899
  • 2
  • 9
  • 23
2

I tried below and error went away !!

project name - SwiftExample

Went to Pods -> Info -> Configurations -> Debug Change to None for Pods-SwiftExample

Code compiles even after setting it back to original.

ashishn
  • 410
  • 5
  • 18
2

I can see many solutions already given there. But I believe the easiest way to resolve this problem is

  1. Open the project directory in Terminal
  2. Delete .xcworkspace file
  3. Run pod install

That's it. The newly created .xcworkspace file will work without any problem.

Naval Hasan
  • 1,226
  • 1
  • 13
  • 18
1

Open your project file (project.pbxproj) and check of 'Pods' is added to the path before the 'Target Support Files' folder. Remove that and i got it to build fine.

KamyFC
  • 858
  • 9
  • 17