【问题标题】:Alamofire framework not found(Xcode-8.2.1 and iOS 10.2)未找到 Alamofire 框架(Xcode-8.2.1 和 iOS 10.2)
【发布时间】:2017-08-31 21:28:58
【问题描述】:

我已经尝试了很多解决方案,但最终还是没有得到解决。我刚刚为 Alamofire 和 swiftyJson 安装了 cocoa pods。现在,当我清理和构建我的项目时,我得到了一个错误

没有这样的框架 ALAMOFIRE

当我尝试在任何 swift 文件中导入 Alamofire 时,它​​会显示:

没有这样的模块 ALAMOFIRE

我的更新后的 Podfile 是这样的(没有这样的框架 Alamofire 错误由这个 pod 文件解决)。但仍然得到 No such Module alamofire-:

  # Uncomment the next line to define a global platform for your project
platform :ios, ’10.2’


source 'https://github.com/CocoaPods/Specs.git'

target 'ModesTests' do
use_frameworks!
 pod 'Alamofire', '~> 4.4'

  target 'ModesUITests' do
    inherit! :search_paths
    # Pods for testing
  end

end

这就是我创建 Modes.xcworkspace 并安装 pods 并创建 pod 文件的方式 -:

1) 打开终端

2) 使用 cd 命令导航到包含您的 ModesSample 项目的目录:

3) 给出初始化命令

pod init

4) 使用命令打开 Podfile-:

open -a Xcode Podfile

创建的pod文件如上图所示,最后一步是-:

5) pod install

我已验证的所有内容-:

1) 我在路径下添加了 Alamofire.framework -: Modes->General->Linked Frameworks and Libraries

2) 尝试在 -: Build settings->Framework search paths 下添加 Alamofire 目录路径

3) Verified Build Active Architecture Only 值它是-:

DEBUG:YES
RELEASE:NO

谁能帮我解决这个问题,我已经尝试了 3 次。谢谢

【问题讨论】:

  • @Sneak okk 明白了你的意思你对问题有什么想法吗?
  • 我不知道,这可能对您有所帮助:stackoverflow.com/questions/25817479/…,另外,请避免删除您的问题并重新发布它们以增加它们。祝你好运。
  • @Sneaks 谢谢,我会再试一次。
  • @Sneak,你试过重启 Xcode 吗?
  • 您可以运行 pod deintegratepod install 并查看再次安装 pod 是否对您有帮助。你也可以检查你的Podfile.lock 并告诉你正在使用什么版本的 alamofire。你能导入 swiftjson 吗?

标签: ios swift3 cocoapods xcode8 alamofire


【解决方案1】:

从 pod 获取时,您无需链接框架(Alamofire 或 SwiftyJSON)。所有链接都是从 pod 自动完成的。您只需要导入它们。

我为你试过这个,它奏效了。 enter image description here

【讨论】:

  • 那么我应该链接什么? like-: Pods_Modes.framework 什么的?
  • 不。我猜你是通过从项目中分离你的 pod 来解决的。但是您仍然不必手动链接 pod。您也可以执行“$pod clean”来删除现有工作区并创建一个新工作区。
  • nopes pod deintegrate 没有解决它。实际解决的是在目标“模式”下编写 use_framworks
【解决方案2】:

将以下文本粘贴到您的 podfile 中。

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

source 'https://github.com/CocoaPods/Specs.git'

target 'ModesTests' do
 pod 'Alamofire', '~> 4.4'

  target 'ModesUITests' do
    inherit! :search_paths
    # Pods for testing
  end

end

保存它。 然后在终端中运行命令“$ pod install”。(如果您之前没有安装)。 如果你想更新 Alamofire 然后运行命令“$ pod update”

谢谢你..!!!

【讨论】:

  • 嗨,您的命令很有用,但还有一步要做-:转到构建设置-> 框架搜索路径-> 添加这个-:$(inherited)。然后清理并构建。
  • 我现在收到这个警告 -: directory not found for option '-F``' .
  • 通过只添加 $(inherited) 到 Pods->Build settings->framework Search Paths 解决它
  • 它没有给出任何未找到框架的错误,但是现在当我导入 Alamofire 时它说没有这样的模块。:(
  • 只需关闭您的项目并移动到您的项目路径并打开安装 Pod 时创建的 projectName.xcworkspace 文件
【解决方案3】:

使用以下内容更改您的 Podfile

# Uncomment the next line to define a global platform for your project
platform :ios, '10.2'
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!


def shared_pods
   pod 'Alamofire'
   pod 'SwiftyJSON'
end
target 'Modes' do
   # Pods for Modes
   shared_pods
end
target 'ModesTests' do
   inherit! :search_paths
   # Pods for testing
   shared_pods

 end

 target 'ModesUITests' do
   inherit! :search_paths
    # Pods for testing
    shared_pods

   end

执行 pod deintegrate 并再次安装 pod。

【讨论】:

  • 谢谢你试试这个
  • 感谢您的代码我的一个小想法,我们解决了它。:)
【解决方案4】:

这就是我完全为 ios-10.2 和 Xcode -:8.2.1 所做的(这很好用)

1) 创建一个项目。

2) 转到终端

3) 给出命令cd desktop(如果项目在桌面上)

4) cd project name

5) pod init(这在目录中创建了 pod 文件)

6) 使用这个 pod 文件-:

# Uncomment the next line to define a global platform for your project
platform :ios, '10.2'
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
def shared_pods
use_frameworks!
   pod 'Alamofire', '~> 4.4'
   pod 'SwiftyJSON'
end
target 'Modes' do
   # Pods for Modes
   shared_pods
end
target 'ModesTests' do
   inherit! :search_paths
   # Pods for testing
   shared_pods

 end

 target 'ModesUITests' do
   inherit! :search_paths
    # Pods for testing
    shared_pods

   end

MARK-:我在shared_pods函数下添加了use_frameworks(这让我可以使用框架)不要把它放在外面。

7) 保存 pod 文件

8) pod install

9) 关闭终端和所有打开的项目。

10) 进入项目目录并打开Projectname.xcworkspace。

11) 首先清理和构建

12) 导入 Alamofire

13) Bravo 使用您的框架。

【讨论】:

    猜你喜欢
    • 2019-08-16
    • 2014-12-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-16
    • 1970-01-01
    • 1970-01-01
    • 2021-05-08
    相关资源
    最近更新 更多