Xcode: 没有这样的模块 'Alamofire'
Xcode: No Such Module 'Alamofire'
我一直收到错误
No Such Module 'Alamofire'
在我的Xcode项目swift文件中使用import Alamofire
;该文件位于项目中的单独模块中。
我试过以下;
- 构建和运行
Alamofire
目标
- 注释掉 import
Alamofire
和 运行 项目,然后取消注释并重新构建
- 确保我使用的是
<MyProject>.xcworkspace
而不是 .xcodeproj
在项目中使用 $(inherited)
> 构建设置 > 构建选项 > ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES
更新 Cocoapods,删除并重新安装依赖项
然而,当我打开 swift 文件的检查器 window 时,Target Membership 已勾选主应用程序和模块框。
当我取消选中文件所在的模块时,在我的 seperateModuleTests
文件中我无法使用 swift 文件中使用的 classes,因为我得到错误;
Use of undeclared type
&&
Use of unresolved identifier 'ClassName'
似乎当我取消选中用于测试的 class 的 swift 文件的目标成员时,seperateModuleTests
无法识别 class来自 swift 文件的 es。但是当我检查 swift 文件的目标成员身份是否是单独模块的一部分时,我得到了原始错误。
任何人都可以帮助我了解为什么会发生这种情况以及我该如何解决?
我认为您在测试目标
中缺少添加 Alamofire
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
target 'AppName' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for AppName
pod 'SwiftyJSON'
pod 'Alamofire', '4.4.0'
target 'AppNameTests' do
inherit! :search_paths
pod 'Alamofire', '4.4.0'
end
target 'AppNameUITests' do
inherit! :search_paths
pod 'Alamofire', '4.4.0'
end
end
更好
您还可以对您的目标
的所有 pods 进行配置
# Uncomment this line to define a global platform for your project
platform :ios, '8.2'
# Uncomment this line if you're using Swift
use_frameworks!
# Define main pods.
def main_pods
#Your common pods here
pod 'Alamofire', '4.4.0'
end
target 'AppName' do
main_pods
#add here other pods specific for this target
end
target 'AppNameTests' do
main_pods
#add here other pods specific for this target
end
target 'AppNameUITests' do
main_pods
#add here other pods specific for this target
end
希望对您有所帮助
运行 清理:产品 > 清理然后构建。
如果这不起作用。这是如何使用的?是你自己的代码,还是需要你有 AlamoFire 的另一个模块?
我一直收到错误
No Such Module 'Alamofire'
在我的Xcode项目swift文件中使用import Alamofire
;该文件位于项目中的单独模块中。
我试过以下;
- 构建和运行
Alamofire
目标 - 注释掉 import
Alamofire
和 运行 项目,然后取消注释并重新构建 - 确保我使用的是
<MyProject>.xcworkspace
而不是.xcodeproj
在项目中使用
$(inherited)
> 构建设置 > 构建选项 > ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES更新 Cocoapods,删除并重新安装依赖项
然而,当我打开 swift 文件的检查器 window 时,Target Membership 已勾选主应用程序和模块框。
当我取消选中文件所在的模块时,在我的 seperateModuleTests
文件中我无法使用 swift 文件中使用的 classes,因为我得到错误;
Use of undeclared type
&&
Use of unresolved identifier 'ClassName'
似乎当我取消选中用于测试的 class 的 swift 文件的目标成员时,seperateModuleTests
无法识别 class来自 swift 文件的 es。但是当我检查 swift 文件的目标成员身份是否是单独模块的一部分时,我得到了原始错误。
任何人都可以帮助我了解为什么会发生这种情况以及我该如何解决?
我认为您在测试目标
中缺少添加Alamofire
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
target 'AppName' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for AppName
pod 'SwiftyJSON'
pod 'Alamofire', '4.4.0'
target 'AppNameTests' do
inherit! :search_paths
pod 'Alamofire', '4.4.0'
end
target 'AppNameUITests' do
inherit! :search_paths
pod 'Alamofire', '4.4.0'
end
end
更好
您还可以对您的目标
的所有 pods 进行配置# Uncomment this line to define a global platform for your project
platform :ios, '8.2'
# Uncomment this line if you're using Swift
use_frameworks!
# Define main pods.
def main_pods
#Your common pods here
pod 'Alamofire', '4.4.0'
end
target 'AppName' do
main_pods
#add here other pods specific for this target
end
target 'AppNameTests' do
main_pods
#add here other pods specific for this target
end
target 'AppNameUITests' do
main_pods
#add here other pods specific for this target
end
希望对您有所帮助
运行 清理:产品 > 清理然后构建。
如果这不起作用。这是如何使用的?是你自己的代码,还是需要你有 AlamoFire 的另一个模块?