找不到 Pods.modulemap - 在错误的目录中查找
Can't find Pods.modulemap - looking in wrong directory
我正在尝试让 CocoaPods 在 Swift 项目中工作,但这是我的第一次。
我的 Podfile 是
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'Alamofire', '~> 1.2'
pod 'SwiftyJSON', '~> 2.2.0'
我 运行 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"}
奇怪的是这个/Users/jt/tmp-ios/竟然不是我所在的目录
Tue Jun 09$ pwd
/Users/jt/repos/EmbersSwift
Tue Jun 09$
我之前在该目录中确实有一些内容,但它引用的内容并不清楚。我将如何解决这个问题?我怀疑这是 Pods.debug.xconfig 中的问题,但希望之前有人处理过这个问题。
对我有用的解决方案是:
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 location
rm -rf ModuleCache/*
- Close a terminal app
Third Step:
- Open Xcode
- Product > Clean
- Product > Run
Source:
如果您定义了自定义构建位置:
- 使用 Finder 或终端转到构建文件的位置。这些文件的位置在 Xcode 中定义。要检查这些文件在哪里:
- 打开Xcode
- 转到
Settings -> Locations -> Derived Data
- 转到该位置并删除
Build
文件夹
编辑:2016 年 6 月 9 日
这也可能解决了您的问题:
默认情况下 Xcode 的清理不会删除所有内容,通过转到 Product
,按 ALT
-键,Clean
-按钮将改变到 Clean Build Folder...
。
我在 核心数据 重置涉及来自源代码管理 (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"}}
由于该错误,我无法构建项目我已经尝试了上述解决方案,但它没有用。
对我有用的是:
- 打开 RootModel.xcdatamodel(左键单击模型并在 Finder 中显示)。
- 手动删除引发问题的 Model.xcdatamodel。
- 清理项目 (cmd+shift+k) 和 运行.
希望这对某人有所帮助。
不过,最简单的方法是转到 Xcode 的首选项
Preferences->Locations->Derived Data
只需删除 Derived Data 文件夹即可。之后再次清理并构建项目,应该不会抛出任何错误。
我通过从 pod 文件中删除 pods 解决了我的问题,安装 pod,再次添加它们,然后再次安装 pod。
看起来 pod 安装不正确。
在我的例子中,我对我的 PodFile 做了一些更改,遇到了类似的错误,然后重新 运行 'install':
% pod install
我又回来了。
对我有用的是转到 pod 文件所在的项目目录。
和:
rm -f Podfile.lock
rm -rf Pods/
这实际上消除了所有罪魁祸首,我能够再次构建和 运行 项目。
(我也做了前面提到的步骤,删除了构建文件夹和模块缓存,但这没有帮助)
我正在尝试让 CocoaPods 在 Swift 项目中工作,但这是我的第一次。
我的 Podfile 是
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'Alamofire', '~> 1.2'
pod 'SwiftyJSON', '~> 2.2.0'
我 运行 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"}
奇怪的是这个/Users/jt/tmp-ios/竟然不是我所在的目录
Tue Jun 09$ pwd
/Users/jt/repos/EmbersSwift
Tue Jun 09$
我之前在该目录中确实有一些内容,但它引用的内容并不清楚。我将如何解决这个问题?我怀疑这是 Pods.debug.xconfig 中的问题,但希望之前有人处理过这个问题。
对我有用的解决方案是:
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
Source:
如果您定义了自定义构建位置:
- 使用 Finder 或终端转到构建文件的位置。这些文件的位置在 Xcode 中定义。要检查这些文件在哪里:
- 打开Xcode
- 转到
Settings -> Locations -> Derived Data
- 转到该位置并删除
Build
文件夹
编辑:2016 年 6 月 9 日
这也可能解决了您的问题:
默认情况下 Xcode 的清理不会删除所有内容,通过转到 Product
,按 ALT
-键,Clean
-按钮将改变到 Clean Build Folder...
。
我在 核心数据 重置涉及来自源代码管理 (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"}}
由于该错误,我无法构建项目我已经尝试了上述解决方案,但它没有用。
对我有用的是:
- 打开 RootModel.xcdatamodel(左键单击模型并在 Finder 中显示)。
- 手动删除引发问题的 Model.xcdatamodel。
- 清理项目 (cmd+shift+k) 和 运行.
希望这对某人有所帮助。
不过,最简单的方法是转到 Xcode 的首选项
Preferences->Locations->Derived Data
只需删除 Derived Data 文件夹即可。之后再次清理并构建项目,应该不会抛出任何错误。
我通过从 pod 文件中删除 pods 解决了我的问题,安装 pod,再次添加它们,然后再次安装 pod。
看起来 pod 安装不正确。
在我的例子中,我对我的 PodFile 做了一些更改,遇到了类似的错误,然后重新 运行 'install':
% pod install
我又回来了。
对我有用的是转到 pod 文件所在的项目目录。 和:
rm -f Podfile.lock
rm -rf Pods/
这实际上消除了所有罪魁祸首,我能够再次构建和 运行 项目。
(我也做了前面提到的步骤,删除了构建文件夹和模块缓存,但这没有帮助)