ios 找不到 Pods.modulemap - 在错误的目录中查找
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30745675/
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
Can't find Pods.modulemap - looking in wrong directory
提问by timpone
I'm trying to get CocoaPods working in a Swift project but this is my first time.
我正在尝试让 CocoaPods 在 Swift 项目中工作,但这是我第一次。
My Podfile is
我的 Podfile 是
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'Alamofire', '~> 1.2'
pod 'SwiftyJSON', '~> 2.2.0'
I run pod install
but building it gives me this error:
我运行pod install
但构建它给了我这个错误:
Error: unable to read module map contents from 'Target Support
Files/Pods/Pods.modulemap': Error Domain=NSCocoaErrorDomain Code=260
"The file “Pods.modulemap” couldn't be opened because there is no such file."
UserInfo=0x7fac488d5af0 {NSFilePath=/Users/jt/tmp-ios/my-template/Pods/Target
Support Files/Pods/Pods.modulemap, NSUnderlyingError=0x7fac457f0e90 "The operation
couldn't be completed. No such file or directory"}
The weird is that this is that /Users/jt/tmp-ios/ is not even the directory I am in.
奇怪的是, /Users/jt/tmp-ios/ 甚至不是我所在的目录。
Tue Jun 09$ pwd
/Users/jt/repos/EmbersSwift
Tue Jun 09$
I did have something in that directory before by what it is referencing that is not clear. How would I fix this? I suspect it is something in Pods.debug.xconfig but was hoping somebody had dealt with this before.
我之前在该目录中确实有一些内容,但它所引用的内容尚不清楚。我将如何解决这个问题?我怀疑它是 Pods.debug.xconfig 中的东西,但希望之前有人处理过这个问题。
回答by skofgar
The solution that worked for me was:
对我有用的解决方案是:
First step:
(this step may no longer be needed in Xcode 9.x and newer)
- Open Xcode
- Click Window (Menu Bar)
- Click Projects
- Remove all projects (e.g. use backspace)
- Close Xcode
Second Step:
- Open a terminal app
cd ~/Library/Developer/Xcode/DerivedData
rm -rf Build/*
see below if you have a customized build locationrm -rf ModuleCache/*
- Close a terminal app
Third Step:
- Open Xcode
- Product > Clean
- Product > Run
第一步:
(Xcode 9.x 及更新版本可能不再需要此步骤)
- 打开 Xcode
- 单击窗口(菜单栏)
- 点击项目
- 删除所有项目(例如使用退格键)
- 关闭 Xcode
第二步:
- 打开终端应用
cd ~/Library/Developer/Xcode/DerivedData
rm -rf Build/*
如果您有自定义的构建位置,请参见下文rm -rf ModuleCache/*
- 关闭终端应用
第三步:
- 打开 Xcode
- 产品 > 清洁
- 产品 > 运行
If you have defined a custom build location:
如果您定义了自定义构建位置:
- Go with Finder or the Terminal to the location of the build files. The location for these files is defined in Xcode. To check where these files are:
- Open Xcode
- Go to
Settings -> Locations -> Derived Data
- Go to that location and delete the
Build
folder
- 使用 Finder 或终端转到构建文件的位置。这些文件的位置在 Xcode 中定义。要检查这些文件的位置:
- 打开 Xcode
- 去
Settings -> Locations -> Derived Data
- 转到该位置并删除
Build
文件夹
Edit: June 9, 2016
编辑:2016 年 6 月 9 日
It is also possible that this resolves your problem:
这也有可能解决您的问题:
By default the clean of Xcode, does not delete everything, by going to Product
, pressing the ALT
-key, the Clean
-button will change to Clean Build Folder...
.
默认情况下,Xcode 的 clean 不会删除所有内容,通过转到Product
,按 -ALT
键, -Clean
按钮将更改为Clean Build Folder...
。
回答by BCalder
In my case I had made a few changes to my PodFile, got a similar error and just re-ran 'install':
就我而言,我对 PodFile 进行了一些更改,遇到了类似的错误,然后重新运行了“安装”:
% pod install
And I was back in business.
我又回来做生意了。
回答by SoliQuiD
I solved my problem by removing the pods from the pod file, pod install, add them again, then pod install again.
我通过从 pod 文件中删除 pod,pod install,再次添加它们,然后再次 pod install 解决了我的问题。
looks like a pod was incorrectly installed.
看起来 pod 安装不正确。
回答by Andgh
A similar problem happened to me with core datawhen reseting changes that involved core new version from the source control (Git). it threw:
在从源代码管理 (Git) 重置涉及核心新版本的更改时,核心数据发生了类似的问题。它抛出:
/Path/To/Model/Model.xcdatamodel: Failed to read data model Error Domain=NSCocoaErrorDomain Code=260 "The file “contents” couldn't be opened because there is no such file." UserInfo={NSFilePath=/Path/To/Model/Model.xcdatamodel/contents, NSUnderlyingError=0x7fb632e558d0 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
/Path/To/Model/Model.xcdatamodel: 无法读取数据模型 Error Domain=NSCocoaErrorDomain Code=260 “无法打开文件“内容”,因为没有这样的文件。UserInfo={NSFilePath=/Path/To/Model/Model.xcdatamodel/contents, NSUnderlyingError=0x7fb632e558d0 {Error Domain=NSPOSIXErrorDomain Code=2“没有那个文件或目录”}}
I was unable to build the project because of that error I've tried the above solution but it didn't work.
由于该错误,我无法构建项目我已经尝试了上述解决方案,但没有奏效。
What worked for me was:
对我有用的是:
- Open the RootModel.xcdatamodel (Left click on the model and Show in Finder).
- Manually erase the Model.xcdatamodel that triggets the issue.
- Clean project (cmd+shift+k) and Run.
- 打开 RootModel.xcdatamodel(左键单击模型并在 Finder 中显示)。
- 手动擦除触发问题的 Model.xcdatamodel。
- 清理项目(cmd+shift+k)并运行。
Hope this helps someone.
希望这可以帮助某人。
回答by inokey
The simplest way though is going to Xcode's Preferences
最简单的方法是转到 Xcode 的首选项
Preferences->Locations->Derived Data
Just deleting Derived Data folder does the trick. Just Clean and Build the project again after, should not throw any errors.
只需删除派生数据文件夹即可。之后再次清理并构建项目,不应抛出任何错误。
回答by arvidurs
What worked for me was to go to the project directory, where the pod file is. and:
对我有用的是转到 pod 文件所在的项目目录。和:
rm -f Podfile.lock
rm -rf Pods/
That actually removed all the culprits and I was able to build and run the project again.
这实际上消除了所有罪魁祸首,我能够再次构建和运行该项目。
( I also did the previously mentioned steps, removed build folder and module caches, but that didn't help)
(我也做了前面提到的步骤,删除了构建文件夹和模块缓存,但这没有帮助)