6 Comments

  • I would suggest that you could get inspiration from Qt defines http://doc.qt.io/qt-5/qtglobal.html http://doc.qt.io/qt-5/qtglobal.html#details
    It has quite a history of running over lots of different platforms and configurations

  • Which version of a service the app connects to. This is similar to your dev/test/prod flag, but is orthogonal. And if an app connects to multiple services there will be one set of build flags for each.

    • +1 to this. The services may be owned by the developer (the app’s server stacks) or Apple itself (APNS, iTMS IAP).

    • Whether or not the build is intended for internal distribution only, which may expose a debug menu/gesture in the app that is stripped from App Store releases. This is orthogonal to Debug/Release.

  • I really want to test if a module has been imported elsewhere in the project.

    For example, If Facebook’s POP has been imported in the project, I would like to support those animations in my framework/module. But if it hasn’t, I don’t want to require the user of my framework to import it… and want to just fall back to Core Animation.

    Similarly, I run into this *near constantly* with cross-platform frameworks and Core Graphics. If the user has imported Cocoa, I want to support CGPoints, NSAttributedString, NSColor, etc…. If they have imported UIKit, I want to support UIColor, etc…. But if they have only imported Foundation, I don’t want to force them to import those frameworks. I want to fall back to supporting just the features supported by Foundation.

    Ideally, I could just say “Weak Import UIKit” and then wrap areas of my code which rely on it in “#if imported(UIKit)”

    • In ObjC we were able to do this by defining a constant, and then checking for its existence…