Nat
Nat

Reputation: 12942

Cocoapods no-arc in only few files

I've updated my podspec to support few files, that doesn't use 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" => "[email protected]"
  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

However I receive an error:

$ pod spec lint

-> AppName (0.0.1) - ERROR | [AppName/no-arc] Returned an unsuccessful exit code. You can use --verbose for more information. - NOTE | [RNDataHandler/no-arc] clang: error: linker command failed with exit code 1 (use -v to see invocation)

And more details from --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 **

Seems like the files are not connected with the project.

Upvotes: 2

Views: 1697

Answers (2)

dhar
dhar

Reputation: 31

I hava a mrc file NSStringAdditions.m in my private pod project,I add this confituration,it works

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

Upvotes: 1

Nat
Nat

Reputation: 12942

Resolved the issue by creating a static library and including it to the podspec.

Upvotes: 0

Related Questions