我已经构建了一个动态库(在本例中是添加ICU支持),我需要将它作为一个依赖项添加到一个pod中。为此,我用下面的podspec创建了一个荚(我删除了作者、许可、.保持简短)
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这里我有第二个吊舱,我也需要连接这些库。
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中找不到库。
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框架。
所以我做错了什么..。问题是,我能把一个豆荚和另一个豆荚连接起来吗?如果是这样..。多么?
发布于 2016-10-27 11:36:55
基于"libs“和"Frameworks”之间的差异,这看起来像是运行路径搜索路径 (正在运行的应用程序没有从框架中查找库),或者库的安装名称与其放置位置相对于动态加载的位置不匹配的问题。
@executable_path/../Frameworks,@loader_path/../Frameworks@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。但希望不会发生这种事。https://stackoverflow.com/questions/40102209
复制相似问题