UIWebView加载本地H5文件时的错误,Class PLBuildVersion is implemented in both ....One of the two will be used. Which one is undefined.

今天朋友给我一份H5代码,让我用WebView加载出来

如图

UIWebView加载本地H5文件时的错误,Class PLBuildVersion is implemented in both ....One of the two will be used. Which one is undefined._第1张图片
Paste_Image.png
只是用给一个webview加载本地H5界面啊~没什么难的
贴上代码
- (void)viewDidLoad {
    [super viewDidLoad];
    UIWebView *webView = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    [self.view addSubview:webView];
    NSString *path = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"];
    NSString *htmlString = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
    NSString *basePath = [[NSBundle mainBundle] bundlePath];
    NSURL *baseURL = [NSURL fileURLWithPath:basePath];
    [webView loadHTMLString:htmlString baseURL:baseURL];
}
前方高能~重点来了
UIWebView加载本地H5文件时的错误,Class PLBuildVersion is implemented in both ....One of the two will be used. Which one is undefined._第2张图片
Paste_Image.png
错误信息

objc[26534]: Class PLBuildVersion is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/AssetsLibraryServices.framework/AssetsLibraryServices (0x126969cc0) and /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibraryServices.framework/PhotoLibraryServices (0x1267806f0). One of the two will be used. Which one is undefined.

竟然给我这个错误,说是加载了两个类库,不知道引用哪一个,我上谷歌,百度搜索搜了好长时间,都没有找到如何解决问题的方法,贴上网站

stackoverflow上的回答

苹果爸爸的回答

apple上的回答

目前这个问题还解决不了,看样子...
另外,查文档的时候,发现另外一个会报此错误的问题就是
主要是iOS10的适配问题,info.plist里没有加对.访问相册只加了一个


NSPhotoLibraryUsageDescription
App需要您的同意,才能访问相册

然后运行程序就报上面的错误,解决办法(在添加一个即可)


NSAppleMusicUsageDescription
App需要您的同意,才能访问媒体资料库

引用此处

这个我没试,但是先贴出来吧.如果以后碰到了,可以翻翻看
如果有其他的问题,请在下方留言,看到我会回复~

今天问题偶然间得到解决了,值得一提的是,标题报的错误并不影响程序的运行!!!目前可以忽略.

以下是解决方法,参考出处参考出处

使文件夹变为蓝色,也就是在选择 Added folders 选项时选择 Create folder references



选择此选项

项目结构如图
然后,代码如下
- (void)viewDidLoad {
    [super viewDidLoad];
    UIWebView *webView = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    [self.view addSubview:webView];
//    NSString *path = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"];
//    NSString *htmlString = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
//    NSString *basePath = [[NSBundle mainBundle] bundlePath];
//    NSURL *baseURL = [NSURL fileURLWithPath:basePath];
//    [webView loadHTMLString:htmlString baseURL:baseURL];
    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:@"www"]]]];
}

至此加载完成,完成后截图



感谢大家的分享,我也把自己的分享出来,希望可以帮到一些人~

你可能感兴趣的:(UIWebView加载本地H5文件时的错误,Class PLBuildVersion is implemented in both ....One of the two will be used. Which one is undefined.)