2015-10-31 85 views
0

任何设法在tvos上使用GCDWebServer的人?我试图在Xcode 7.1编译和我得到:tvOS上的GCDWebServer

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) 

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

回答

0

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

BTW.I使用的CocoaPods安装GCDWebServer在我的项目,我建我的电视应用程序与我的手机应用程序一起,但他们是不同的目标。

在我的情况,我用Objective-C的写我的手机应用,并使用斯威夫特写电视app.So我要补充桥接报我的电视的目标。

TARGETS>您-TV-TARGET>构建设置>斯威夫特编译器> Objective-C的桥接报>将此

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

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

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

如何让斯威夫特和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) 

的问题,我认为这可能是有些问题,我building.Maybe一些图书馆是missing.So我去到目标的>您-TV-TARGET>生成词组>链接二进制与图书馆和添加这些框架等:

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

这是我的TV-目标的构建阶段。我们还应该检查出豆荚> GCDWebServer>构建设置etc.Because是豆荚,所以我们要编辑Podfile and rebu使用我的项目。这是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 

您可以拨打GCDWebServer在TV-TARGET和GCDWebServer在tvOS运行良好。 :-)

希望它能帮助你。

0

GCDWebServer建立在tvOS上,latest pre-release version有一个示例tvOS项目。

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

+0

是的,我配置它指向主。但它仍然给我同样的错误。 –

+0

我已经添加了“Link Binary With Libraries”,就像您的演示项目一样。我为桥接Swift和GCDWebServer.Wait创建了一个Bridging-Header文件,用于为tvOS.BTW提供更具体的文档,GCDWebServer是一个非常不错的开源项目。 –

+0

我通过Cocoapods.I添加了GCDWebServer。我猜想由Pods> GCDWebServer> TARGETS.I导致的问题看到设置与iOS建筑兼容,但与tvOS不兼容。也许我应该尝试手动配置。 –