Best way to install a custom cocoa framework

后端 未结 4 702
执笔经年
执笔经年 2020-12-29 15:00

I have a custom framework that, following the advice in Apple\'s Framework Programming Guide >> Installing your framework I install in /Library/Frameworks. I do this by addi

4条回答
  •  萌比男神i
    2020-12-29 15:39

    In the past months, I've learned a lot more about frameworks, so I'm rewriting this answer. Please note that I'm talking about installing a framework as part of the development workflow.

    The preferred location for installing a public framework (i.e. a framework that will be used by more than one of your apps or bundles) is /Library/Frameworks[link text] because "frameworks in this location are discovered automatically by the compiler at compile time and the dynamic linker at runtime."[Framework Programming Guide]. The most elegant way to do this is in the Deployment section of the Build settings.

    As you work on your framework, there are times when you do want to update the framework when you do a build, and times when you don't. For that reason, I change the Deployment settings only in the Release Configuration. So:

    1. Double-click on the framework target to bring up the Target info window and switch to the Build tab.
    2. Select Release in the Configuration selectbox.
    3. Scroll down to the Deployment section and enter the following values:

    Deployment Location = YES (click the checkbox)

    Installation Build Products Location = /

    Installation Directory = /Library/Frameworks

    The Installation Build Products Location serves as the root of the installation. Its default value is some /tmp directory: if you don't change it to the system root, you'll never see your installed framework since it's hiding in the /tmp.

    Now you can work on your framework as you like in the Debug configuration without upsetting your other projects and when you are ready to publish all you need to do is switch to Release and do a Build.

    Xcode 4 Warning Since switching to Xcode 4, I've experienced a number of problems with my custom framework. Mostly, they are linking warnings in GDB that do not really interfere with the usefulness of the framework, except when running the built-in unit-test. I have submitted a technical support ticket to Apple a week ago, and they are still looking into it. When I get a working solution I will update this answer since the question has proven quite popular (1 kViews and counting).

提交回复
热议问题