Cocoapods no-arc 只有几个文件
Cocoapods no-arc in only few files
我更新了我的 podspec 以支持几个不使用 ARC 的文件:
Pod::Spec.new do |spec|
spec.name = "AppName"
spec.version = "0.0.1"
spec.source = { :git => 'ssh://...', :tag => '0.0.1'}
spec.license = 'Apache 2.0'
spec.author = "me" => "me@somewhere.com"
spec.platform = :ios, '7.0'
spec.requires_arc = true
spec.frameworks = ['Foundation', 'UIKit', 'CoreGraphics', 'QuartzCore', 'CoreFoundation']
# import sources
spec.source_files = 'Classes/*.{h,m}',
'Classes/**/*.{h,m}'
spec.resources = 'Resources/**.*'
# attach non-arc files
non_arc_files = ['Classes/Frameworks/PGSQLKit/*.{h,m}',
'Classes/Frameworks/PGSQLKit/**/*.{h,m}',
'Classes/Frameworks/QRunLoopOperation/*.{h,m}']
spec.exclude_files = non_arc_files
spec.subspec 'no-arc' do |sna|
sna.requires_arc = false
sna.source_files = non_arc_files
end
# link with modules
spec.subspec 'Core' do |cs|
cs.dependency 'libextobjc', '~> 0.4'
cs.dependency 'CocoaLumberjack', '2.0.0-rc2'
cs.dependency 'FMDB', '~> 2.5'
cs.dependency 'ASIHTTPRequest', '~> 1.8'
end
end
但是我收到一个错误:
$ pod spec lint
-> 应用名称 (0.0.1)
- 错误 | [AppName/no-arc] 返回了不成功的退出代码。您可以使用 --verbose
获取更多信息。
- 注意 | [RNDataHandler/no-arc] clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)
更多详情来自 --verbose
:
// more errors like this
"_PQresultErrorMessage", referenced from:
-[PGSQLConnection open:] in PGSQLConnection.o
"_PQresultStatus", referenced from:
-[PGSQLConnection execCommand:] in PGSQLConnection.o
-[PGSQLConnection open:] in PGSQLConnection.o
"_PQsetNoticeProcessor", referenced from:
-[PGSQLConnection connect] in PGSQLConnection.o
"_PQstatus", referenced from:
-[PGSQLConnection connect] in PGSQLConnection.o
"_PQunescapeBytea", referenced from:
-[PGSQLConnection sqlDecodeData:] in PGSQLConnection.o
"_sqlite3_exec", referenced from:
___57-[MyFile(Category) doSomething:]_block_invoke in MyFile+Category.o
___33-[MyFile doSomethingElse]_block_invoke in MyFile.o
-[MyFile doSomething:withSomething:error:] in MyFile.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
** BUILD FAILED **
似乎文件与项目没有关联。
通过创建静态库并将其包含到 podspec 中解决了该问题。
我的私有 pod 项目中有一个 mrc 文件 NSStringAdditions.m,我添加了这个配置,它有效
non_arc_files = 'Pod/Classes/**/NSStringAdditions.{h,m}'
s.exclude_files = non_arc_files
s.subspec 'no-arc' do |sna|
sna.requires_arc = false
sna.source_files = non_arc_files
end
我更新了我的 podspec 以支持几个不使用 ARC 的文件:
Pod::Spec.new do |spec|
spec.name = "AppName"
spec.version = "0.0.1"
spec.source = { :git => 'ssh://...', :tag => '0.0.1'}
spec.license = 'Apache 2.0'
spec.author = "me" => "me@somewhere.com"
spec.platform = :ios, '7.0'
spec.requires_arc = true
spec.frameworks = ['Foundation', 'UIKit', 'CoreGraphics', 'QuartzCore', 'CoreFoundation']
# import sources
spec.source_files = 'Classes/*.{h,m}',
'Classes/**/*.{h,m}'
spec.resources = 'Resources/**.*'
# attach non-arc files
non_arc_files = ['Classes/Frameworks/PGSQLKit/*.{h,m}',
'Classes/Frameworks/PGSQLKit/**/*.{h,m}',
'Classes/Frameworks/QRunLoopOperation/*.{h,m}']
spec.exclude_files = non_arc_files
spec.subspec 'no-arc' do |sna|
sna.requires_arc = false
sna.source_files = non_arc_files
end
# link with modules
spec.subspec 'Core' do |cs|
cs.dependency 'libextobjc', '~> 0.4'
cs.dependency 'CocoaLumberjack', '2.0.0-rc2'
cs.dependency 'FMDB', '~> 2.5'
cs.dependency 'ASIHTTPRequest', '~> 1.8'
end
end
但是我收到一个错误:
$ pod spec lint
-> 应用名称 (0.0.1)
- 错误 | [AppName/no-arc] 返回了不成功的退出代码。您可以使用 --verbose
获取更多信息。
- 注意 | [RNDataHandler/no-arc] clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)
更多详情来自 --verbose
:
// more errors like this
"_PQresultErrorMessage", referenced from:
-[PGSQLConnection open:] in PGSQLConnection.o
"_PQresultStatus", referenced from:
-[PGSQLConnection execCommand:] in PGSQLConnection.o
-[PGSQLConnection open:] in PGSQLConnection.o
"_PQsetNoticeProcessor", referenced from:
-[PGSQLConnection connect] in PGSQLConnection.o
"_PQstatus", referenced from:
-[PGSQLConnection connect] in PGSQLConnection.o
"_PQunescapeBytea", referenced from:
-[PGSQLConnection sqlDecodeData:] in PGSQLConnection.o
"_sqlite3_exec", referenced from:
___57-[MyFile(Category) doSomething:]_block_invoke in MyFile+Category.o
___33-[MyFile doSomethingElse]_block_invoke in MyFile.o
-[MyFile doSomething:withSomething:error:] in MyFile.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
** BUILD FAILED **
似乎文件与项目没有关联。
通过创建静态库并将其包含到 podspec 中解决了该问题。
我的私有 pod 项目中有一个 mrc 文件 NSStringAdditions.m,我添加了这个配置,它有效
non_arc_files = 'Pod/Classes/**/NSStringAdditions.{h,m}'
s.exclude_files = non_arc_files
s.subspec 'no-arc' do |sna|
sna.requires_arc = false
sna.source_files = non_arc_files
end