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

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

如图

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];
}
前方高能~重点来了
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里没有加对.访问相册只加了一个


<key>NSPhotoLibraryUsageDescription</key>
<string>App需要您的同意,才能访问相册</string>

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


<key>NSAppleMusicUsageDescription</key>
<string>App需要您的同意,才能访问媒体资料库</string>

引用此处

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

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

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

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


QQ20170513-173603@2x.png

选择此选项

项目结构如图
QQ20170513-174332@2x.png
然后,代码如下👇
- (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"]]]];
}

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


QQ20170513-173907@2x.png

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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容