xcode 使用自定义框架

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/78423/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 18:24:01  来源:igfitidea点击:

Using a custom framework

iphonexcodemacoscocoa

提问by user8030

The error I'm getting:

我得到的错误:

in /Users/robert/Documents/funWithFrameworks/build/Debug-iphonesimulator/funWithFrameworks.framework/funWithFrameworks, can't link with a main executable

Cliff notes:

悬崖笔记:

  • trying to include framework
  • doesn't want to link
  • 试图包含框架
  • 不想链接

More detail: I'm developing for a mobile device... hint, hintusing Xcode and I'm trying to make my own custom framework which I can include from another application. So far, I've done the following:

更多细节:我正在为移动设备开发...提示,使用 Xcode 进行提示,我正在尝试制作我自己的自定义框架,我可以从另一个应用程序中包含该框架。到目前为止,我已经完成了以下工作:

  1. Create a new project; an iPhone OS window based app.
  2. Go to target info-> under packaging, change the wrapper extension from app to framework
  3. Go to Action->new build phase -> copy headers. Change roles of headers to 'public'
  4. From my application, I add the framework to the frameworks group.
  1. 创建一个新项目;基于 iPhone 操作系统窗口的应用程序。
  2. 转到目标信息-> 在打包下,将包装器扩展从应用程序更改为框架
  3. 转到操作-> 新构建阶段-> 复制标题。将标题的角色更改为“公共”
  4. 在我的应用程序中,我将框架添加到框架组。

回答by user8030

Apple clearly said that you can notuse dynamic libraries on their mobiles. And a private framework is just this.

Apple 明确表示您不能在他们的手机上使用动态库。私有框架就是这样。

You can, however, use static libraries.

但是,您可以使用静态库。

回答by Tom Harrington

Egil, that's usually considered as one of the implications of section 3.3.2 of the iPhone developer agreement, which (in part) forbids plug-in architectures or other frameworks. The fact that they don't provide an Xcode project template for an iPhone-compatible framework tends to reinforce the idea, though of course it could just be an oversight or something they're discouraging without actually forbidding.

Egil,这通常被认为是 iPhone 开发者协议第 3.3.2 节的含义之一,该协议(部分)禁止插件架构或其他框架。他们没有为与 iPhone 兼容的框架提供 Xcode 项目模板的事实往往会强化这个想法,尽管这当然可能只是一个疏忽或他们不鼓励的事情,而实际上并没有禁止。

Whether this is the intended meaning of that section is something you'd have to ask Apple about, and possibly consult a lawyer, but this is where the oft-stated "no frameworks" idea comes from.

这是否是该部分的预期含义是您必须询问 Apple 并可能咨询律师的事情,但这就是经常陈述的“无框架”想法的来源。

For those who have framework code they'd like to use in an iPhone app, an alternative approach is to use the framework code to build a static library. That then gets compiled into the application instead of getting dynamically loaded at run time. The fact that it's part of the application executable avoids any potential concerns about this part of the agreement.

对于那些希望在 iPhone 应用程序中使用框架代码的人,另一种方法是使用框架代码来构建静态库。然后将其编译到应用程序中,而不是在运行时动态加载。它是应用程序可执行文件的一部分这一事实避免了对协议这一部分的任何潜在担忧。

回答by jbenet

Though dynamic libraries are not allowed, you CAN create a framework (using static libraries and lipo).

尽管不允许使用动态库,但您可以创建一个框架(使用静态库和 lipo)。

Check out: http://accu.org/index.php/journals/1594

查看:http: //accu.org/index.php/journals/1594

回答by amrox

I haven't tried it for so called mobile device, but I would guess its very similar to the method for a regular Cocoa application. Check out this tutorial:

我还没有为所谓的移动设备尝试过它,但我猜它与常规 Cocoa 应用程序的方法非常相似。看看这个教程:

Embedded Cocoa Frameworks

嵌入式 Cocoa 框架