在开发中 易遇小问题解决方法

一:在ios开发过程中总是需要新建工程做实现一些特定功能的demo,需要完成一些设置

1.bitcode  设为no

2. 有相机相册的地方info中要添加设置NSCameraUsageDescription/ Photo Library Usage Description

3. ld: symbol(s) not found for architecture arm64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

这个问题的解决方法加入 SystemConfiguration.frameworkOk了哦

4.IOS9 不能正常使用 Http的解决方法: (注意从iOS9开始,凡是涉及到网络操作的,都要在Info.plist中加入:)

App Transport Security Settings   字典

    Allow Arbitrary Loads yes


二: 在做一些操作时,由于操作方法不同易出现一些小问题

1. 

如下图一,在添加文件时,习惯性的直接把文件拖进工程(eg:拖进工程一个PDF文件123.pdf),使用一下方法

来获取本地文件路径时pdfPath为nil;

NSString *pdfPath = [[NSBundlemainBundle] pathForResource:@"123"ofType:@"pdf"];


返回的 pdfPath 为nil。


解决方法:

1. 将文件删掉,如图二所示直接点击addFiles来添加文件;

2. 文件保留,点击项目 =>  Build Phases => Copy Bundle Resource 

然后添加123.pdf进来。

图一:


图二:



原因:

[NSBundle mainBundle]获取的路径是你程序的安装路径下的资源文件位置。 在xcode中采用add file to 方式添加文件时,一般情况下xcode会自动将文件添加到你的资源文件,而且,这些文件在你工程的 build Phases中的 copy Bundle Resources中可以查看到。但是直接拖进工程的文件,不能自动添加到你的资源文件中,这时,可以采用copy Bundle Resources下面的“+”号,手动将文件添加到你的资源文件中,这样就可以解决问题了。


猜你喜欢

转载自blog.csdn.net/haixing_zfj/article/details/75513511
今日推荐