简体   繁体   English

从同一应用程序的框架访问嵌入在iOS应用程序中的静态库

[英]Access static library embeded in iOS app from framework in the same app

Is it possible to access the symbols from a static library added to an iOS app from a framework added in the same app. 是否可以从同一应用程序中添加的框架中访问添加到iOS应用程序的静态库中的符号。

I am trying to build an ios framework which has dependeny on a thirdparty static library which the customer buys. 我正在尝试构建一个依赖于客户购买的第三方静态库的ios框架。 So the customer adds the static library to the app. 因此,客户将静态库添加到应用程序。

But my framework needs to read the symbols from the static library added in the app. 但是我的框架需要从应用程序中添加的静态库中读取符号。

Any pointers will be much appreciated. 任何指针将不胜感激。

-- Thanks, Syed Yusuf -谢谢,赛义德(Syed Yusuf)

You should link your framework against that static library to do that. 您应该将框架与该静态库链接以实现此目的。 Otherwise, you can't access that static libraries' symbols. 否则,您将无法访问该静态库的符号。 Because they are embedded in your customer's application. 因为它们已嵌入在客户的应用程序中。

Using 'Cocoapods' as a dependency manager will get you where you want: 使用“ Cocoapods”作为依赖项管理器将使您到达所需的位置:

For example - a framework that uses the Alamofire networking framework: 例如,一个使用Alamofire网络框架的框架:

  1. Create your framework project 创建您的框架项目
  2. Use Cocoapods and add 'pod 'Alamofire', '~> 4.0'' to your podfile. 使用Cocoapods并将'pod'Alamofire','〜> 4.0''添加到您的podfile中。
  3. Build your framework and add it to the project that intends to use this framework. 构建您的框架,并将其添加到打算使用此框架的项目中。
  4. In you app project also add 'pod 'Alamofire', '~> 4.0' to your podfile 在您的应用程序项目中,还将'pod'Alamofire','〜> 4.0'添加到您的podfile中

That's it. 而已。

By the way - if your app project will not add the dependent framework to its podfile, you'll see a linker error upon building the app which will look something like that: 顺便说一句-如果您的应用程序项目不会将依赖框架添加到其Podfile中,则在构建应用程序时会看到一个链接器错误,该错误看起来像这样:

"dyld: Library not loaded: @rpath/Alamofire.framework/Alamofire Referenced from: /private/var/containers/Bundle/Application/8B381B5F-6B86-4CDD-8A49-E0CBF9C04786/test.app/Frameworks/MyFramework.framework/MyFramework Reason: image not found" “ dyld:未加载库:@ rpath / Alamofire.framework / Alamofire引用自:/private/var/containers/Bundle/Application/8B381B5F-6B86-4CDD-8A49-E0CBF9C04786/test.app/Frameworks/MyFramework.framework/MyFramework原因:找不到图片”

Hope this is helpful. 希望这会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM