Swift - 无法在目标 Xcode 10 中打开文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/53117077/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Swift - Unable to open file in target Xcode 10
提问by whatlOol
I am trying to run Aplication which I have downloaded from GitHub.
我正在尝试运行从 GitHub 下载的应用程序。
When I run get error unable to open file in target, I have Xcode 10.
当我运行得到错误无法在目标中打开文件时,我有 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 Nonefor the two Pods-related targets, then run pod install again.
我遇到了同样的问题,但在 Xcode 6.1.1 中 - 对我来说修复它的是将两个与 Pods 相关的目标的配置文件设置更改为None,然后再次运行 pod install。
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
这是错误图片:https: //i.stack.imgur.com/Ql3M5.png
回答by Pushp
In File -> Project setting -> select Legacy Build System
在 File -> Project setting -> 选择Legacy Build System
Make sure you have opened .xcworkspace file and pod installed properly.
确保您已打开 .xcworkspace 文件并正确安装了 pod。
回答by TimD
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.
删除以下文件。确保您已复制 Podfile 的内容。
- Podfile
- Podfile.lock
- Pods Folder
- 播客文件
- Podfile.lock
- Pod 文件夹
Open your .xcodeproj using Xcode or using terminal command
使用 Xcode 或使用终端命令打开您的 .xcodeproj
open <ProjectName>.xcodeproj
Inside Xcode, locate the "Pods" folder which should contain something along the lines of...
在 Xcode 中,找到“Pods”文件夹,其中应包含以下内容...
Pods
|- Pods-<ProjectName>.debug.xconfig
|- Pods-<ProjectName>.release.xconfig
Delete those references and select "move to trash" when prompted.
删除这些引用并在出现提示时选择“移至垃圾箱”。
Close Xcode
关闭 Xcode
Now run the following:
现在运行以下命令:
pod init && pod install
Open your Podfile and paste in your previously copied old Podfile that was deleted earlier.
打开您的 Podfile 并粘贴之前复制的先前删除的旧 Podfile。
run the following command:
运行以下命令:
pod install
In terminal open Xcode again with the following command
在终端中使用以下命令再次打开 Xcode
open <ProjectName>.xcworkspace
Note: that I opened the xcworkspace
file NOT the xcodeproj file.
注意:我打开的xcworkspace
文件不是 xcodeproj 文件。
At this point for me I was able to compile my code as normal without having to change back to the Legacy Build System.
在这一点上,我能够像往常一样编译我的代码,而无需改回旧版构建系统。
回答by DiegoQ
For me it works, update the version of CocoaPods and reinstall the pods
对我来说它有效,更新 CocoaPods 的版本并重新安装 pods
sudo gem install cocoapods
回答by karique
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.
我在最近安装了 Xcode 并且没有可可豆或任何相关内容的新 macbook 中打开旧项目时遇到了同样的错误。
My way to fix this was following some of the steps en the issues #1727of alamofire and change some things. Open the terminal and cd project where the pod file is.
我解决这个问题的方法是遵循alamofire问题 #1727 中的一些步骤并更改一些内容。打开终端和 pod 文件所在的 cd 项目。
So, this is what worked for me:
所以,这对我有用:
- sudo gem install cocoa pods
- pod repo remove master
- pod setup
- pod repo update
- pod install
- sudo gem 安装可可豆荚
- pod repo 移除 master
- 吊舱设置
- pod 回购更新
- 吊舱安装
Then just, clean build folder and build the project.
然后,清理构建文件夹并构建项目。
回答by Jerry Chong
Run following commands after you have downloaded Xcode project from GitHub:
从 GitHub 下载 Xcode 项目后运行以下命令:
cd /your-xcode-project
pod install
This worked on Xcode 10.2.
这适用于 Xcode 10.2。
回答by DeepBlue
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:
我从 GitLab 克隆的项目也遇到了这个问题。你的错误看起来和我的非常相似。我通过在终端中运行它来解决它:
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.
当我在 Finder 中检查项目文件夹时,有一个 Podfile。但是在 Xcode 中查看的同一个项目在“Pods”模块下没有任何内容。由此我发现 pod 没有安装(或安装正确?)并安装它们解决了这个错误。
回答by Saif
- Quit
Xcode
- Open
Terminal
- Change to directory (where podfile is present)
pod install
- 退出
Xcode
- 打开
Terminal
- 切换到目录(podfile 所在的位置)
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.
我试图pod install
在删除不需要的 pod(步骤 2,3 和 4)后执行此操作,但它仍然无法正常工作。退出 Xcode(步骤 1、2、3 和 5)有效。
回答by ashishn
I tried below and error went away !!
我在下面尝试过,错误消失了!!
project name - SwiftExample
项目名称 - SwiftExample
Went to Pods -> Info -> Configurations -> Debug Change to None for Pods-SwiftExample
转到 Pods -> 信息 -> 配置 -> Pods-SwiftExample 的调试更改为无
Code compiles even after setting it back to original.
即使在将其设置回原始代码后,代码也会编译。
回答by Omar
1- in xcode menu --> project --> clean build files
1- 在 xcode 菜单中 --> 项目 --> 清理构建文件
2- close project
2- 关闭项目
3- in terminal cd
3-in 终端光盘
4- in terminal pod update
4-in 终端舱更新
5- re-open project..xcworkspace file
5- 重新打开 project..xcworkspace 文件
6- clean, build
6-清洁,构建
good luck
祝你好运
回答by Papon Smc
delete file name "Podfile.lock" and try pod install again.
删除文件名“Podfile.lock”并再次尝试 pod install。