Cocoapods: Static C++ library as a part of private/local pod

Created on 6 Mar 2020  路  4Comments  路  Source: CocoaPods/CocoaPods

First of all, thank you very much for contributing best dependency system for iOS.

I have a swift project which will be used as a private pod. This project has C++ static library 'euscp.a', with Objc-c wrapper. This is how my podspec looks like:

Pod::Spec.new do |s|

s.name = "ElectronicDigitalSignature"
s.version = "0.1.0"
s.summary = "SDK for electronic signing documents"
s.description = "SDK for electronic signing documents. Developed by iOS dream team."
s.homepage = "https://git.microaws.com/p24-ios/electronic_digital_signature-ios"
s.license = { :type => "MIT", :file => "LICENSE" }
s.author = "PrivatBank"

s.platform = :ios, "9.0"
s.swift_version = "5.0"
s.source = { :git => "https://git.microaws.com/p24-ios/electronic_digital_signature-ios", :tag => '0.1.0' }
s.pod_target_xcconfig = {'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) PC_STATIC_LIBS OS_IOS',
'USER_HEADER_SEARCH_PATHS' => '"${PROJECT_DIR}/ElectronicDigitalSignature/.."/' }
###s.libraries = 'euscp', 'xml2', 'c++'
s.resources = "ElectronicDigitalSignature/
/*.{png,jpeg,jpg,storyboard,xib,xcassets,xcdatamodeld,strings}"

s.source_files = "ElectronicDigitalSignature/SDK//*.{h,m,mm,cpp,c,a,swift}"
s.vendored_libraries = 'ElectronicDigitalSignature/
/euscp.a'

s.frameworks = "Foundation", "UIKit"

s.dependency "SnapKit"
s.dependency "Alamofire"
s.dependency "ios-sdk-extensions"
s.dependency "shared-ios"

end

When I connect in my main project this Pod (as a local developer pod or from branch), I got an error: ld: library not found for -leuscp
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I make research an issue with the same problem, but without a result. I also try to link it manually, but is still error. Can anybody help me with this problem, please?

Screen Shot 2020-03-06 at 13 24 00
Screen Shot 2020-03-06 at 13 23 32

Screen Shot 2020-03-06 at 13 45 48

awaiting input

Most helpful comment

Can you try renaming your binary to libeuscp.a? Also, looks like there's an extra / character in the vendored_libraries value.

All 4 comments

Can you try renaming your binary to libeuscp.a? Also, looks like there's an extra / character in the vendored_libraries value.

@amorde, it is a brilliant answer with adding "lib" in the file name. Can you explain how it works, please?

P.S. extra / character - because in podspec it is calling recursively with ''. // have to be / * /

This is the behavior of gcc and clang's linker flags - from gcc's docs:

-l library
...
The linker searches a standard list of directories for the library, which is actually a file named liblibrary.a. The linker then uses this file as if it had been specified precisely by name.

So using -lmylib expects a file named libmylib.a

This issue will be auto-closed because there hasn't been any activity for a few months. Feel free to open a new one if you still experience this problem :+1:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

soleares picture soleares  路  3Comments

steffendsommer picture steffendsommer  路  3Comments

Mingmingmew picture Mingmingmew  路  3Comments

luhui picture luhui  路  3Comments

Curtis-Halbrook picture Curtis-Halbrook  路  3Comments