1. <tfoot id='HnLgE'></tfoot>
        <bdo id='HnLgE'></bdo><ul id='HnLgE'></ul>

      <small id='HnLgE'></small><noframes id='HnLgE'>

      <legend id='HnLgE'><style id='HnLgE'><dir id='HnLgE'><q id='HnLgE'></q></dir></style></legend>
      <i id='HnLgE'><tr id='HnLgE'><dt id='HnLgE'><q id='HnLgE'><span id='HnLgE'><b id='HnLgE'><form id='HnLgE'><ins id='HnLgE'></ins><ul id='HnLgE'></ul><sub id='HnLgE'></sub></form><legend id='HnLgE'></legend><bdo id='HnLgE'><pre id='HnLgE'><center id='HnLgE'></center></pre></bdo></b><th id='HnLgE'></th></span></q></dt></tr></i><div id='HnLgE'><tfoot id='HnLgE'></tfoot><dl id='HnLgE'><fieldset id='HnLgE'></fieldset></dl></div>

      1. 使用私有 dylib/framework 构建 Cocoa 应用程序包

        时间:2023-05-17
          <legend id='aPNo3'><style id='aPNo3'><dir id='aPNo3'><q id='aPNo3'></q></dir></style></legend>
              <tbody id='aPNo3'></tbody>

              <i id='aPNo3'><tr id='aPNo3'><dt id='aPNo3'><q id='aPNo3'><span id='aPNo3'><b id='aPNo3'><form id='aPNo3'><ins id='aPNo3'></ins><ul id='aPNo3'></ul><sub id='aPNo3'></sub></form><legend id='aPNo3'></legend><bdo id='aPNo3'><pre id='aPNo3'><center id='aPNo3'></center></pre></bdo></b><th id='aPNo3'></th></span></q></dt></tr></i><div id='aPNo3'><tfoot id='aPNo3'></tfoot><dl id='aPNo3'><fieldset id='aPNo3'></fieldset></dl></div>

                <tfoot id='aPNo3'></tfoot>

                  <bdo id='aPNo3'></bdo><ul id='aPNo3'></ul>

                  <small id='aPNo3'></small><noframes id='aPNo3'>

                  本文介绍了使用私有 dylib/framework 构建 Cocoa 应用程序包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我使用 xcode 4 构建一个带有私有 dylib/框架的可可应用程序.

                  I use xcode 4 to build a cocoa application with a private dylib/framework.

                  在我的开发Mac中,我把dylib放在/usr/local/lib目录下,然后拖到项目中.

                  In my development Mac, I put the dylib in the /usr/local/lib directory, and drag it into the project.

                  该应用程序已编译并在我的计算机上完美运行.

                  The app is compiled and runs perfect on my computer.

                  为了将此应用分发到另一台 Mac,我创建了一个复制文件构建阶段,并说将那个 dylib 复制到 Frameworks 目录".

                  To distribute this app to the other Mac, I create a copy Files building phase, and say "copy that dylib to Frameworks directory".

                  应用构建成功,我确实看到dylib被复制到了app bundle的Frameworks目录中.

                  The application is built successfully, and I indeed see the dylib is copied to the Frameworks directory in the app bundle.

                  问题是当我在另一个没有安装这个 dylib 的普通 Mac 上运行这个应用程序时.我收到一条错误消息:

                  The problem is when I run this app in another regular Mac, which does not have this dylib installed. I get an error saying:

                  dyld: Library not loaded: /usr/local/lib/mylib.dylib
                  

                  推荐答案

                  问题在于您将框架复制到应用程序包中,因此它可以在以下位置使用:

                  The issue comes from the fact that you copy the framework into the app bundle, so it is available at a location like:

                   <you_app_path>/Contents/Frameworks
                  

                  但您尝试从 /usr/local/lib 加载它,但它在您的部署机器上不可用.来自 Apple 框架编程指南:

                  but you try to load it from /usr/local/lib where it is not available on you deployment machine. From Apple Framework Programming Guide:

                  要将框架嵌入到应用程序中,您必须执行几个步骤:

                  To embed a framework in an application, there are several steps you must take:

                  您必须配置应用程序目标的构建阶段,以将框架放置在正确的位置.

                  You must configure the build phases of your application target to put the framework in the correct location.

                  您必须配置框架目标的安装目录,该目录告诉框架它将位于何处.

                  You must configure the framework target’s installation directory, which tells the framework where it will live.

                  您必须配置应用程序目标,以便它引用其安装目录中的框架.

                  You must configure the application target so that it references the framework in its installation directory.

                  现在,你说构建阶段没问题;我还假设您正确发送了应用程序目标构建设置.剩下的就是配置框架目标的安装目录了.

                  Now, you say that the build phase is ok; I assume also that you sent the application target build setting correctly. What is left is configuring the framework target’s installation directory.

                  如果您没有自己构建框架,您应该能够通过更改框架安装路径来解决此问题,以便将其定义为相对于加载器(您的应用程序),例如:@loader_path/../Frameworks/(或 @executable_path/../Frameworks).您可以通过 install_name_tool.

                  If you did not build the framework yourself, you should be able to fix this by changing the framework install path so that it is defined relative to the loader (your app), to something like: @loader_path/../Frameworks/ (or @executable_path/../Frameworks). You can do that by means of install_name_tool.

                  如果您自己编译私有框架,您可以在 Xcode 构建设置中定义其安装位置.

                  If you are compiling on your own the private framework, you can define its install location in Xcode build settings.

                  这篇关于使用私有 dylib/framework 构建 Cocoa 应用程序包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:使用 Xcode 调试库 下一篇:我可以构建一个 ARC 框架并在非 ARC 项目中使用它吗?

                  相关文章

                  <legend id='eEGup'><style id='eEGup'><dir id='eEGup'><q id='eEGup'></q></dir></style></legend>

                    <i id='eEGup'><tr id='eEGup'><dt id='eEGup'><q id='eEGup'><span id='eEGup'><b id='eEGup'><form id='eEGup'><ins id='eEGup'></ins><ul id='eEGup'></ul><sub id='eEGup'></sub></form><legend id='eEGup'></legend><bdo id='eEGup'><pre id='eEGup'><center id='eEGup'></center></pre></bdo></b><th id='eEGup'></th></span></q></dt></tr></i><div id='eEGup'><tfoot id='eEGup'></tfoot><dl id='eEGup'><fieldset id='eEGup'></fieldset></dl></div>

                  1. <tfoot id='eEGup'></tfoot>
                    • <bdo id='eEGup'></bdo><ul id='eEGup'></ul>

                    <small id='eEGup'></small><noframes id='eEGup'>