xcode工程中产生的警告

作者: 5b6a9d22d4f0 | 来源:发表于2016-07-01 21:55 被阅读506次

1、Format string is not a string literal (potentially insecure)

Xcode 警告信息处理:Format string is not a string literal (potentially insecure)

解决:NSString 继承于 NSObject;

NSObject *obj = @"A string or other object.";

NSLog(@"%@",obj);

没有必要再调用 NSString的 stringWithFormat: 方法

2、工程一直提示ld: warning: directory not found for option:xxxxxx

解决:

这种提示,通常是由于添加了第三方SDK,但是后来改了个名字或者去掉了SDK,但是在Build Settings----->Search Paths---->Library Search Paths 中仍然没有删除掉对应的路径,所以需要到Library Search Paths和Framework Search Paths中删除掉警告的路径

3、unexpected file type 'wrapper.plug-in' in frameworks & libraries build phase

在General->Linked Frameworks and Libraries中,是因为在framework and library中添加了其他不是lib的文件,如bundle,删除即可。

4、directory not found for option -L..path

在Build Settings--->>Framework Search Path,Library Search Path中删除找不到的路径。

5、.pcm:no such file for requested architechture

将Debug Information Format的Debug改成DWARF

6、no rule to process file。。。

在compile source里删掉多余的文件.

7、Pointer is missing a nullability type specifier (__nonnull or __nullable)

nullability annotations。这一新特性的核心是两个新的类型注释:__nullable和__nonnull。从字面上我们可以猜到,__nullable表示对象可以是NULL或nil,而__nonnull表示对象不应该为空。当我们不遵循这一规则时,编译器就会给出警告。

8、如何解决使用ARC后出现的PerformSelector may cause a leak because its selector is unknown

原因:在ARC模式下,运行时需要知道如何处理你正在调用的方法的返回值。这个返回值可以是任意值,如void,int,char,NSString,id等等。ARC通过头文件的函数定义来得到这些信息。所以平时我们用到的静态选择器就不会出现这个警告。而使用[someController performSelector: NSSelectorFromString(@"someMethod")];运行时ARC并不知道该方法的返回值是什么,以及该如何处理?该忽略?还是标记为ns_returns_retained还是ns_returns_autoreleased?

解决1、使用宏:

#pragma clang diagnostic push

#pragma clang diagnostic ignored "-Warc-performSelector-leaks"

[someController performSelector: NSSelectorFromString(@"someMethod")]

#pragma clang diagnostic pop

解决2、使用afterDelay

[self performSelector:aSelector withObject:nil afterDelay:0.0];

持续更新中。。。

相关文章

网友评论

    本文标题:xcode工程中产生的警告

    本文链接:https://www.haomeiwen.com/subject/jtcqjttx.html