Bundle framework with application in XCode

前端 未结 3 1338
时光取名叫无心
时光取名叫无心 2020-12-04 20:09

I am an XCode novice. I am trying to follow these instructions. Clearly I am missing something because while I can see that the framework I want has been copied into the ap

相关标签:
3条回答
  • 2020-12-04 20:32

    When the OpenCV.framework has been build it has been configured to use an install path of /Users/david/Library/Frameworks/.

    Since you want to use the library as a private framework (installed in the application wrapper at ClipSplitter.app/Contents/Frameworks/OpenCV.framework) you have to change its install path. This can be done easily using the terminal as follows:

    $ install_name_tool -id @executable_path/../Frameworks/OpenCV.framework/OpenCV <your_path>/OpenCV.framework/OpenCV
    

    Of course you have to adjust the path of the last argument.

    Now, when linking your application, your modified framework tells the linker that dyld has to search for the OpenCV.framework in the app wrapper of your application (in the ClipSplitter.app/Contents/Frameworks directory).

    Now you have to copy the OpenCV.framework to your application wrapper. You can do this as part of your build process by adding a copy files build phase: Right-click on your target, select Add->New Build Phase->New Copy Files Build Phase. Select "Frameworks" from the "Destination" pop up and close the dialog.

    Your target will now contain a new phase to which you can add the OpenCV.framework by dragging the icon from the Project Navigator on the left side of Xcode window. Note that Xcode won't allow you to add a folder to the Copy Files phase by using the '+' button so in order to copy the framework you'll have to drag&drop it.

    0 讨论(0)
  • 2020-12-04 20:38

    You need to set the build setting "Installation directory" to @executable_path/../Frameworks

    See the chapter about Embedding a Private Framework in Your Application Bundle in https://developer.apple.com/library/content/documentation/MacOSX/Conceptual/BPFrameworks/Tasks/CreatingFrameworks.html

    Regards

    0 讨论(0)
  • 2020-12-04 20:55

    Using Xcode 5, you can facilitate this using the Build Phases panel of your application target.

    The default appearance of this panel is

    By pressing the "+" button underneath Copy Files, you can add your framework as a file that will be copied into Frameworks in your app bundle.

    Now, when you build, your Framework(s) will be copied into your bundle.

    0 讨论(0)
提交回复
热议问题