Managing Static Library project as a module like Framework on iOS project in Xcode4

Many people including me trying to make a kind of Static Library framework for iOS to archive some kind of modularity. Framework is best way to do this, but it doesn’t provided by Apple, and workarounds don’t work well.

https://github.com/kstenerud/iOS-Universal-Framework/tree/master/Fake%20Framework/Templates

  • Custom key bindings Xcode 4?
  • Warning is not displayed in Xcode Issue Navigator
  • How to install Cocos2d PROJECT templates in Xcode 4?
  • In Xcode4, the new interface builder says “no selection”
  • NSTimer stops during scrolling
  • Xcode 4.2 - App Loader: Unable to verify icon dimensions, no icon found
    1. Fake framework cannot be referenced from linking tab in Build Phases.
    2. Real framework needs modification of system setting. And still not work smoothly on every parts.

    Problem is static library need header files, and it’s impossible to reference header files on project at another location on different project without some script. And script breaks IDE’s file management abstraction.

    How can I use static library project like a convenient module manner? (just dragging project into another project to complete embedding)

    3 Solutions Collect From Internet About “Managing Static Library project as a module like Framework on iOS project in Xcode4”

    I’ve since updated the template to do away with the script target. It now builds the universal framework from your regular target, so you can include it in workspaces or as a project dependency.

    With a real framework target, you can just add it to “Link Binary With Libraries”, and it will show up fine.

    With a fake framework, Xcode doesn’t recognize the target type, so you need to add the link command manually. For example, assuming your framework is called Foo:

    1. Expand the “Products” group of your framework project, then drag “Foo.framework” into the “Link Binary With Libraries” build phase of your app target.

    2. In your app target, edit “Other Linker Flags” in the build settings and add: “-framework Foo”

    Framework template link for anyone not sure what we’re talking about: https://github.com/kstenerud/iOS-Universal-Framework

    Solution.

    1. Goto Project or Target‘s Build Settings.
    2. Find Public Headers Folder Path. (definition name = PUBLIC_HEADERS_FOLDER_PATH)
    3. Set it as YourLibrary.framework/Headers. I have used ${PRODUCT_NAME}.framework/Headers for automatic syncing with project name.
    4. Goto Build Phases and find Copy Headers step.
    5. Move all required headers to Public pane.

    Now all header files will be formed like Framework and copied with product binary. IDE will copy all of them as a unit into some temporary folder like app’s build folder. So referencing app project can use the headers automatically.

    This is a trick. The created directory structure is not real framework. Because it doesn’t contain any binary. However we don’t need real framework to archive just this functionality. IDE works with frameworks without any binary. And I don’t want to hack IDE without documentation about internal structure.


    This works well, however you’ll experience some problem when you Archive. This happens because Xcode4 behaves specially when Archiving. Here’s workaround.

    1. For each embedded library project, SKIP_INSTALL = YES in target build settings.
    2. For final product project, FRAMEWORK_SEARCH_PATHS = "${OBJROOT}/UninstalledProducts". Take care about this setting should be set only for Release build mode.

    Now it’ll be archived well.


    At the case of cross platform library, there can be many projects for many platforms. But sometime Xcode will show some product as red color even it compiled successfully.

    This is a bug of Xcode. IDE display depends SDKROOT of Project build setting. So if you set the SDKROOT differently on Target, it won’t work. You can check the the product will become black color after changing the SDKROOT of the Project build setting. See this Open Radar entry for details.

    http://openradar.appspot.com/9636211

    If you wish to fix this bug, please report this to Apple’s Radar. Duplicated bugs will make attention of Apple. Just copy & paste my report 🙂