Xcode - dyld:未加载库
Xcode - dyld: Library not loaded
我尝试在我的 Cocoa 应用程序中使用与 cocoapods 一起安装的 GCDWebServer,它工作正常!
但是,当我尝试在命令行工具应用程序中执行相同操作时,出现此错误 -
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)
我的代码 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;
}
根据以下内容修补您的 Podfile:
https://github.com/CocoaPods/CocoaPods/issues/3707
我用于 hello world CLI 应用程序的版本:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['DYLIB_INSTALL_NAME_BASE'] = target.product_name
config.build_settings['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = 'YES'
end
end
end
与其说是解决方案,不如说是变通方法。
我尝试在我的 Cocoa 应用程序中使用与 cocoapods 一起安装的 GCDWebServer,它工作正常!
但是,当我尝试在命令行工具应用程序中执行相同操作时,出现此错误 -
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)
我的代码 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;
}
根据以下内容修补您的 Podfile:
https://github.com/CocoaPods/CocoaPods/issues/3707
我用于 hello world CLI 应用程序的版本:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['DYLIB_INSTALL_NAME_BASE'] = target.product_name
config.build_settings['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = 'YES'
end
end
end
与其说是解决方案,不如说是变通方法。