Swift - Unable to open file in target Xcode 10

狂风中的少年 提交于 2019-12-05 10:00:32

问题


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


回答1:


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

make sure you have open .xcworkspace file and pod installed properly




回答2:


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.




回答3:


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

sudo gem install cocoapods



回答4:


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.




回答5:


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




回答6:


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

Possible fix: gem install cocoapods --pre




回答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.




回答8:


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

cd /your-xcode-project
pod install

This worked on Xcode 10.2.




回答9:


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



回答10:


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




回答11:


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.




回答12:


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.




回答13:


  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.




回答14:


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.



来源:https://stackoverflow.com/questions/53117077/swift-unable-to-open-file-in-target-xcode-10

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!