如何对一个框架进行单一目标的预链接?

huangapple go评论52阅读模式
英文:

How to single-object prelink a framework?

问题

My situation:

  • 我正在开发一个名为A的动态链接框架,打包成.xcframework
  • 我依赖于其他静态链接的框架BC
  • 但是,我不希望A的消费者了解BC的存在
  • 因此,我想在链接A时执行单个对象预链接,以便A完全消耗BC,并且再也不会看到它们。

如果不是静态框架(.framework)而是静态库(.a),这个任务会相对容易。在这种情况下,我可以将.a的路径轻松放入“Prelink Libraries”设置中,将“Perform Single-Object Prelink”设置为“YES”,禁用嵌入 - 这样就可以实现目标。

然而,我面临的是与框架的链接,而不是库。问题在于它内部有资源和捆绑包。

  • 如果将.xcframework.framework的路径放入“Prelink Libraries”构建设置中,构建会失败:
Command MasterObjectLink failed with a nonzero exit code
can't map file, errno=22 file '/Users/*****/B/B.xcframework/ios-arm64/B.framework'
  • 如果将框架内部实际可执行文件的路径(B.xcframework/ios-arm64/B.framework/B)放入其中,构建会成功。但是,B.framework的任何资源都不会出现在生成的输出中。

有办法在“Single-Object Prelink”期间自动复制资源吗?

英文:

My situation:

  • I am developing a dynamically linked framework called A, wrapped into .xcframework
  • I depend upon other frameworks B and C that are linked statically
  • However, I don't want the consumers of A to learn about the existence of B and C
  • And because of this, I would like to perform single object pre-link during the linkage of A so that B and C are totally consumed by A and are to be never seen again.

This task would be relatively easy if instead of static frameworks (.framework), I used static libraries (.a). In this case, I would be able to easily plop the path to the .a into the Prelink Libraries setting, set Perform Single-Object Prelink to YES, disable the embedding - and the goal would be accomplished.

However, I am facing the linkage against frameworks, not libs. The problem is that it has resources and bundles inside of it.

  • If I put a path to the .xcframework or .framework into the Prelink Libraries Build Setting, the build fails:
Command MasterObjectLink failed with a nonzero exit code
can't map file, errno=22 file '/Users/*****/B/B.xcframework/ios-arm64/B.framework'
  • And if I put a path to the actual executable inside the framework (B.xcframework/ios-arm64/B.framework/B), the build succeeds. However, none of the resources of B.framework are present in the resulting output.

Is there a way to automatically copy resources during Single-Object Prelink?

答案1

得分: 0

没有,如果不使用常规的“嵌入框架”(Embed Frameworks)方法,就没有自动复制资源的方式。

英文:

No, there is no way to automatically copy the resources if the regular Embed Frameworks isn't used.

huangapple
  • 本文由 发表于 2023年5月15日 14:08:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/76251278.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定