【发布时间】:2016-09-19 23:55:10
【问题描述】:
我正在尝试按照 github(https://github.com/Alamofire/Alamofire#cocoapods) 指令将 Alamofire 包含在我的 Swift 项目中。
我创建了一个新项目,导航到项目目录并运行此命令sudo gem install cocoapods。然后我遇到以下错误:
ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted - /usr/bin/pod
搜索后我设法通过运行此命令sudo gem install -n /usr/local/bin cocoapods 安装cocoapods
现在我通过pod init 生成一个 pod 文件并以这种方式进行编辑:
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
target 'ProjectName' do
# Comment this line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for Law
pod 'Alamofire'
target 'ProjectNameTests' do
inherit! :search_paths
# Pods for testing
end
target 'ProjectNameUITests' do
inherit! :search_paths
# Pods for testing
end
end
最后我运行pod install 来安装Alamofire。之后我打开项目,import Alamofire 语句给了我以下错误No such module 'Alamofire'
Update-1:pod install 的结果是:
Analyzing dependencies
Downloading dependencies
Using Alamofire (3.4.0)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.
【问题讨论】:
-
当您运行 pod install 时,您是否看到安装了依赖项?如果需要,你有 -bridging-header.h 吗?如果该进程实际下载了 Alamofire,请打开已创建的 .xcworkspace。
-
我在编辑 pod 文件后运行
pod install。pod install的结果在更新中给出。所以我猜是正确安装了依赖项 -
听起来很像。你打开的是 .xcworkspace 而不是 xcodeproj?
-
尝试打开 xcodeproj 和 xcworkspace。不幸的是,两者都不起作用! :(
-
您是否在项目中看到具有适当框架的 pod?它们是 swift 框架吗?
标签: ios xcode swift cocoapods alamofire