背景描述:项目升级到xcode 8 后,遇到了一些问题,做下记录,以供大家参考;
问题一:Swift 2.3 升级到 swift 3.0 的问题
PS:我是在OC项目中遇到的,静态库冲突
解决方案:
1,旧项目,使用xcode8打开时,会自动询问,是否自动将 swift2.3语法,升级到swift3.0;可以选择转换,转换之后,如果还有报错的地方,需要自己手动处理swift语法错误;
2,如果不升级swift语法,可以在build setting 中,设置Use Legacy Swift Language Version 为YES;即:允许使用低版本swift;
问题二:项目编译期间,报符号重定义的错误:duplicate symbols
解决方案:
1,Build Setting 中,设置NO Common Blocks 为NO; 【该选项的意思,官方解释如下】
In C, allocate even uninitialized global variables in the data section of the object file, rather than generating them as common blocks. This has the effect that if the same variable is declared (without extern ) in two different compilations, you will get an error when you link them. The only reason this might be useful is if you wish to verify that the program will work on other systems which always work this way.
2,如果1不起作用,继续Build Setting 中,设置Enable Testability 为NO;【该选项的意思,解释如下】(或者查看重定义的符号,是否声明为了static 类型)
From The Xcode 8 Release Notes:
When the Enable Testability build setting is enabled, Xcode 8 will pass -export_dynamic to the linker to preserve all global symbols for testing. This effectively overrides dead code stripping, which can expose link failures from unused functions that reference undefined symbols. If necessary, disabling testability will allow the link to proceed without source changes. (27684883)
Of course, the best thing to do is to either: a) remove the unused code that is causing the linker issues, or b) actually fix the linker issues.
在用oc语言写的项目中亲测可用,在这附上原文地址http://blog.csdn.net/jiajiayouba/article/details/52766600
十分感谢原创作者