首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >cocoapods dylib依赖项use_frameworks

cocoapods dylib依赖项use_frameworks
EN

Stack Overflow用户
提问于 2016-10-18 07:35:18
回答 1查看 1.5K关注 0票数 2

我已经构建了一个动态库(在本例中是添加ICU支持),我需要将它作为一个依赖项添加到一个pod中。为此,我用下面的podspec创建了一个荚(我删除了作者、许可、.保持简短)

代码语言:javascript
复制
Pod::Spec.new do |s|
  s.name     = 'unicode'
  s.version  = '57.0'
  s.source              = { :git => "git@bitbucket.org:mycompany/unicode.git", :tag => "#{s.version}" }
  s.requires_arc = false
  s.platform = :ios, '8.0'

  s.default_subspecs = 'all'

  s.subspec 'all' do |ss|
    ss.header_mappings_dir = 'icu4c/include'
    ss.source_files = 'icu4c/include/**/*.h'
    ss.public_header_files = 'icu4c/include/**/*.h'
    ss.vendored_libraries = 'Frameworks/lib*.dylib'
  end

end

这里我有第二个吊舱,我也需要连接这些库。

代码语言:javascript
复制
Pod::Spec.new do |s|
  s.name     = 'sqlite3'
  s.version  = '3.14.2'
  s.summary  = 'SQLite is an embedded SQL database engine'
  s.documentation_url = 'https://sqlite.org/docs.html'
  s.homepage = 'https://github.com/clemensg/sqlite3pod'
  s.authors  = { 'Clemens Gruber' => 'clemensgru@gmail.com' }

  v = s.version.to_s.split('.')
  archive_name = "sqlite-amalgamation-"+v[0]+v[1].rjust(2, '0')+v[2].rjust(2, '0')+"00"
  #s.source   = { :http => "https://www.sqlite.org/#{Time.now.year}/#{archive_name}.zip" }
  s.source              = { :git => "git@bitbucket.org:wrthphoenixspeedy/sqlite3.git", :tag => "#{s.version}" }
  s.requires_arc = false
  s.platform = :ios, '8.0'

  s.default_subspecs = 'common'

  s.subspec 'common' do |ss|
    ss.source_files = "#{archive_name}/sqlite*.{h,c}"
    ss.osx.pod_target_xcconfig = { 'OTHER_CFLAGS' => '$(inherited) -DHAVE_USLEEP=1' }
    # Disable OS X / AFP locking code on mobile platforms (iOS, tvOS, watchOS)
    sqlite_xcconfig_ios = { 'OTHER_CFLAGS' => '$(inherited) -DHAVE_USLEEP=1 -DSQLITE_ENABLE_LOCKING_STYLE=0' }
    ss.ios.pod_target_xcconfig = sqlite_xcconfig_ios
    ss.tvos.pod_target_xcconfig = sqlite_xcconfig_ios
    ss.watchos.pod_target_xcconfig = sqlite_xcconfig_ios
  end

  # enable support for icu - International Components for Unicode
  s.subspec 'icu' do |ss|
    ss.dependency 'sqlite3/common'
    ss.pod_target_xcconfig = { 'OTHER_CFLAGS' => '$(inherited) -DSQLITE_ENABLE_ICU=1' }
    ss.dependency           'unicode', '57.0'
    ss.libraries = 'icucore', 'icudata.57.1', 'icui18n.57.1', 'icuio.57.1', 'icule.57.1', 'iculx.57.1', 'icutu.57.1', 'icuuc.57.1'
  end

end

有了这些,我就能编译它了。Cocoapods在构建时将这些库复制到../Frameworks/文件夹中,而不是在运行时执行。相反,它失败了,因为它说它在../lib中找不到库。

代码语言:javascript
复制
dyld: Library not loaded: ../lib/libicudata.57.1.dylib
  Referenced from: /var/containers/Bundle/Application/9663CB3A-6ACD-487E-A92D-48F8AFE5260C/MyApp.app/MyApp
  Reason: image not found

我得用use_frameworks!因为我也使用了一些Swift框架。

所以我做错了什么..。问题是,我能把一个豆荚和另一个豆荚连接起来吗?如果是这样..。多么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-10-27 11:36:55

基于"libs“和"Frameworks”之间的差异,这看起来像是运行路径搜索路径 (正在运行的应用程序没有从框架中查找库),或者库的安装名称与其放置位置相对于动态加载的位置不匹配的问题。

  1. 确保在捆绑动态库的应用程序中,在“运行路径搜索路径”中包含了以下路径:@executable_path/../Frameworks@loader_path/../Frameworks
  2. 确保正在加载的库的"Dynamic安装名称“被设置为与@rpath/$(EXECUTABLE_PATH)等效的名称(在您的示例中应该是”@rpath/libiudata.57.1.dylib“)。可以在构建期间使用-install_name编译器(链接器?)对其进行设置。标志,或使用install_name_tool,如:install_name_tool -id "@rpath/libicudata.57.1.dylib" libicudata.57.1.dylib。但希望不会发生这种事。
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40102209

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档