Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift - Unable to open file in target Xcode 10

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

like image 767
whatlOol Avatar asked Nov 02 '18 10:11

whatlOol


People also ask

How do I open a target in Xcode?

Click on the project (the very first object in the tree) in the project navigator and you'll get a view with project settings on the right and targets on the left.

How do I add files to target in Xcode?

I include them in the project by right-clicking on the project folder in the project view in Xcode, and selecting "Add Files to ...". I then navigate to the folder containing the source files, click on the folder and select "Add." With the options "Create folder references" and "Add to target [target name]".

How do I open a file in Xcode?

Xcode also makes it easy to open associated files by pressing Cmd + Ctrl + Arrow Up/Down. In the case of Swift source files, this will open a generated file that contains just the interface. Last but not least, you can show an "Action" popover for the code under the caret by pressing Cmd + Shift + A.

How do I open a Xcodeproj file on a Mac?

You can only open XCODEPROJ files with Apple Xcode in macOS. To open the file, select File → Open....


3 Answers

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

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

like image 86
Pushp Avatar answered Oct 03 '22 22:10

Pushp


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.

like image 40
TimD Avatar answered Oct 04 '22 00:10

TimD


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

like image 38
Imran Rasheed Avatar answered Oct 03 '22 22:10

Imran Rasheed