0

有人设法在 tvos 上使用 GCDWebServer 吗?我试过在 Xcode 7.1 中编译,我得到:

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_GCDWebServer", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_GCDWebServerDataResponse", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_GCDWebServerRequest", referenced from:
      objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

tvOS 没有的框架的 GCDWebServer 内部是否有一些用法?它可以修复吗?我很高兴研究它,但如果有人已经知道它会省去我重复工作的麻烦......

4

2 回答 2

0

GCDWebServer 基于 tvOS 构建,最新的预发布版本有一个示例 tvOS 项目。

如果您使用 CocoaPods 或 Carthage 并将其配置为指向master而不是3.x,它应该可以工作。

于 2015-11-17T03:08:25.707 回答
0

是的。最后我得到了这个问题的解决方案。

顺便说一句。我使用Cocoapods在我的项目中安装GCDWebServer,并用我的手机应用程序一起构建我的电视应用程序,但它们是不同的目标。

就我而言,我使用Objective-C编写我的手机应用程序并使用Swift编写电视应用程序。所以我应该将桥接头添加到我的电视目标。

TARGETS > YOUR-TV-TARGET > Build Settings > Swift Compiler > Objective-C Bridging Header > 添加这个

$(SRCROOT)/YOUR-TV-PROJECT/YOUR-PROJECT-MODULE-Bridging-Header.h

然后我在我的项目中创建这个头文件并添加

#import <GCDWebServer/GCDWebServer.h>
#import <GCDWebServer/GCDWebServerDataResponse.h>

如何在 Swift 和 Objective-C 之间架起一座桥梁,你可以点击这个链接:

https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html

然后我遇到了这个问题

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_GCDWebServer", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_GCDWebServerDataResponse", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_GCDWebServerRequest", referenced from:
      objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我认为这可能是我的建筑有问题。也许缺少一些库。所以我去 TARGETS > YOUR-TV-TARGET > Build Phrase > Link Binary With Libraries 并添加这些框架等:

libxml2.2.tbd
libz.1.2.5.tbd
CFNetwork.framework
MobileCoreServices.framework
UIKit.framework

这是我的 TV-TARGET 的构建阶段。我们还应该检查 Pods > GCDWebServer > Build Settings 等。因为它在 Pods 中,所以我们必须编辑Podfile并重建我的项目。这是 Podfile。你应该将目标分开播客文件。

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

def common_pods
    pod 'Fabric' , '~> 1.6.4'
end

def tv_pods
    pod 'GCDWebServer' , '~ 3.3.2'
end

target :phoneApp do
    link_with 'YOUR-PHONE-TARGET'
    platform :ios, '8.0'
    common_pods
end

target :tvApp do
    link_with 'YOUR-TV-TARGET'
    platform :tvos, '9.0'
    tv_pods
end

编辑 Podfile 并运行后:

pod install 

您可以在 TV-TARGET 中调用 GCDWebServer,GCDWebServer 在您的 tvOS 中运行良好。:-)

希望它可以帮助你。

于 2016-04-28T10:08:29.303 回答