iOS debug版本与release版本(问题)

为什么会写这一篇文章呢?是因为工作中遇到很诡异的情况,公司要求做一个封装C语言的静态库,真机debug版的静态库运行正常,而真机release版则出现问题(c代码中的参数运行发生变化或释放),所以异常,无奈,不知怎么解决~~~~各种调查,庆幸的是最后解决了

很多情况下我们开发测试都是在debug模式下运行开发的,然而发布程序后或者切换至release版本下 程序就会出现各种问题,也就是说debug版本运行正常,而release版本出现错误?

针对于这种情况可以更改targets的 optimization level设置,将release版本的optimization level改为none后就可以了

下面是关于优化的英语,英语很烂看不懂,留着慢慢研究吧

关于优化级别:GCC_OPTIMIZATION_LEVEL 描述如下None: Do not optimize. [-O0]With this setting, the compiler's goal is to reduce the cost of compilation and to make debugging produce the expected results. Statements are independent: if you stop the program with a breakpoint between statements, you can then assign a new value to any variable or change the program counter to any other statement in the function and get exactly the results you would expect from the source code.Fast: Optimizing compilation takes somewhat more time, and a lot more memory for a large function. [-O, -O1]With this setting, the compiler tries to reduce code size and execution time, without performing any optimizations that take a great deal of compilation time. In Apple's compiler, strict aliasing, block reordering, and inter-block scheduling are disabled by default when optimizing.Faster: The compiler performs nearly all supported optimizations that do not involve a space-speed tradeoff. [-O2]With this setting, the compiler does not perform loop unrolling or function inlining, or register renaming. As compared to the 'Fast' setting, this setting increases both compilation time and the performance of the generated code.Fastest: Turns on all optimizations specified by the 'Faster' setting and also turns on function inlining and register renaming options. This setting may result in a larger binary. [-O3]Fastest, smallest: Optimize for size. This setting enables all 'Faster' optimizations that do not typically increase code size. It also performs further optimizations designed to reduce code size.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值