gcdwebserver

GCDWebServer on tvOS


Anyone managed to use GCDWebServer on tvos? I've tried compiling in Xcode 7.1 and I get:

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)

Is there some usage inside GCDWebServer of frameworks that tvOS doesn't have? Is it fixable? I'm happy to look into it but if someone already knows it would save me the trouble of repeating the work...


Solution

  • Yep.Finally I got the solution of this problem.

    BTW.I use Cocoapods to install GCDWebServer in my project and I build my tv app with my phone app together,but they are different targets.

    In my case,I use Objective-C to write my phone app and use Swift to write tv app.So I should add bridging header to my tv target.

    TARGETS > YOUR-TV-TARGET > Build Settings > Swift Compiler > Objective-C Bridging Header > Add this

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

    Then I create this header file in my project and add

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

    How to make a bridge between Swift and Objective-C , you can follow this link :

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

    Then I meet the problem with this

    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)
    

    I thought it could be some problem with my building.Maybe some Libraries are missing.So I go to TARGETS > YOUR-TV-TARGET > Build Phrase > Link Binary With Libraries and add these frameworks etc. :

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

    It is my TV-TARGET's Build Phases.We should also check out Pods > GCDWebServer > Build Settings etc.Because it is in Pods,so we have to edit Podfile and rebuild my project.This is the Podfile.You should separate the targets in 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
    

    After editing the Podfile and run :

    pod install 
    

    You can call GCDWebServer in your TV-TARGET and GCDWebServer runs well in your tvOS. :-)

    Hope it could help you.