I trying to use GCDWebServer installed with cocoapods in my Cocoa Application and it's works fine!
But when I try to do the same in Command Line Tool Application I get this error -
dyld: Library not loaded: @rpath/GCDWebServer.framework/Versions/A/GCDWebServer
Referenced from: /Users/username/Library/Developer/Xcode/DerivedData/test-cjiasulvnyulqidyrsqipangmbfh/Build/Products/Debug/test
Reason: image not found
(lldb)
Code of my main.m -
#import "GCDWebServer.h"
#import "GCDWebServerDataResponse.h"
int main(int argc, const char* argv[]) {
@autoreleasepool {
// Create server
GCDWebServer* webServer = [[GCDWebServer alloc] init];
// Add a handler to respond to GET requests on any URL
[webServer addDefaultHandlerForMethod:@"GET"
requestClass:[GCDWebServerRequest class]
processBlock:^GCDWebServerResponse *(GCDWebServerRequest* request) {
return [GCDWebServerDataResponse responseWithHTML:@"<html><body><p>Hello World</p></body></html>"];
}];
// Use convenience method that runs server on port 8080
// until SIGINT (Ctrl-C in Terminal) or SIGTERM is received
[webServer runWithPort:8080 bonjourName:nil];
NSLog(@"Visit %@ in your web browser", webServer.serverURL);
}
return 0;
}
Patch your Podfile according to:
https://github.com/CocoaPods/CocoaPods/issues/3707
The version I use for my hello world CLI app:
It is more a workaround than a solution.