代码之家  ›  专栏  ›  技术社区  ›  Kevlar

如何在Xcode iPhone项目中启用代码块?

  •  1
  • Kevlar  · 技术社区  · 14 年前

    I'm trying to enable code blocks in our iphone application so that i can run the static analyzer tool included with xcode. I get this warning (or error, depending on which compiler i use) when i run the build and analyze task:

    /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIView.h:252:72: error: blocks support disabled - compile with -fblocks or pick a deployment target that supports them

    I've changed my deployment target to compiler default from iPhone OS 3.0, and i've changed the compiler from GCC 4.2 to LLVM 1.5 and LLVM GCC 4.2 with no luck. I'm not sure what else I have to change to make this work, or where i need to add the -fblocks argument. Does anyone know?

    1 回复  |  直到 14 年前
        1
  •  2
  •   Massimo Cafaro    14 年前

    在sdk 4.0中,如果使用新方法(包括块)作为参数,那么静态分析器将不工作。必须按如下方式显式启用块:在项目的设置中,将 -fblocks 在“ Other C Flags “设置。