ios – AFNetworking不会编译

前端之家收集整理的这篇文章主要介绍了ios – AFNetworking不会编译前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我完全不想尝试使用AFNetworking在模拟器上运行项目.我以前在其他项目中使用过这种依赖,所以我不明白这里出了什么问题.首先,我尝试运行项目时出错:
Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_AFHTTPSessionManager",referenced from:
      _OBJC_CLASS_$_SharedNetworkObject in SharedNetworkObject.o
  "_OBJC_CLASS_$_AFJSONResponseSerializer",referenced from:
      objc-class-ref in SharedNetworkObject.o
  "_OBJC_MetaCLASS_$_AFHTTPSessionManager",referenced from:
      _OBJC_MetaCLASS_$_SharedNetworkObject in SharedNetworkObject.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command Failed with exit code 1 (use -v to see invocation)

我确信这是问题的一部分,但我不知道如何解决它:

这是违规的.h文件

#import <Foundation/Foundation.h>
#import <AFNetworking/AFNetworking.h>
#import "SharedSessionKey.h"

@interface SharedNetworkObject : AFHTTPSessionManager

+ (SharedNetworkObject *) sharedNetworkObject;   // class method to return the singleton object

@end

值得注意的是,当我开始输入AFNetworking的导入行时,该行会在几个字符后填写,所以我知道有一些AFNetworking依赖存在的意识.

我使用CocoaPods安装了依赖项.这是我的Podfile:

# Uncomment this line to define a global platform for your project
platform :ios,'8.0'

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

target 'WeRun' do
pod "AFNetworking","2.5.2"
end

target 'WeRunTests' do

end

当然,我在.xcworkspace(而不是.xcodeproj)工作.

还有一件事,我的xcconfig文件看起来像这样,它与其他成功的AFNetworking构建匹配:

GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking"
OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/AFNetworking"
OTHER_LDFLAGS = -ObjC -l"Pods-MyApp-AFNetworking" -framework "CoreGraphics" -framework "MobileCoreServices" -framework "Security" -framework "SystemConfiguration"
OTHER_LIBTOOLFLAGS = $(OTHER_LDFLAGS)
PODS_ROOT = ${SRCROOT}/Pods

我不知道还有什么要找的.我已经完全删除了pod并重新安装,但却发现完全相同的错误.任何人都可以帮我解决这个问题吗?谢谢!

解决方法

我花了几个小时与这个完全相同的问题进行斗争,经历了我能找到的所有Google点击.设备的构建工作正在进行,但是模拟器的构建却没有.

以下是最终为我解决问题的步骤:

>清除XCode缓存:

rm -rf ~/Library/Developer/Xcode/DerivedData/

>清除CocoaPods缓存并重新安装依赖项:

rm -rf "${HOME}/Library/Caches/CocoaPods"
rm -rf "`pwd`/Pods/"
pod update

>最后转到“Pods”项目,并将“Build Active Architectures Only”设置为“No”,以用于“Debug”配置.

原文链接:https://www.f2er.com/iOS/335281.html

猜你在找的iOS相关文章