2

This is my SDK's podspec:

#
#  Be sure to run `pod spec lint Core.podspec' to ensure this is a
#  valid spec and to remove all comments including this before submitting the spec.
#
#  To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html
#  To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/
#

Pod::Spec.new do |s|
  s.name             = "TiendeoCore"
  s.version          = "0.1.10"
  s.summary          = "Tiendeo Core"
  s.homepage         = "https://www.tiendeo.com"
  s.license          = 'Custom'
  s.author           = { "Tiendeo" => "info@tiendeo.com" }
  s.platform         = :ios, '10.0'

  #REMOTE 
s.source = { "http" => "https://tiendeo.jfrog.io/tiendeo/pods/TiendeoCore/TiendeoCore-0.1.10.zip" }

  #LOCAL#   s.source = { :git => "https://gitlab.tiendeo.com/ios/core-ios.git", :tag => s.version }
  s.dependency "Governor", "~> 0.2.5"
  s.dependency "AlamofireObjectMapper", "~> 5.2"
  s.dependency "Alamofire", "~> 4.8"
  s.dependency "RealmSwift", "~> 3.11.1"
  s.dependency "RxSwift", "~> 4.2.0"
  s.default_subspec = 'Lite'

  s.subspec 'Lite' do |lite|
    lite.name = "Lite"
    #REMOTE 
lite.framework = "TiendeoCore"
    #REMOTE 
lite.vendored_frameworks = 'TiendeoCore.framework'
     #LOCAL#     lite.source_files     = ["Source/**/*.swift", "Source/Core.h"]
     #LOCAL#     lite.public_header_files = ["Source/Core.h"]
     #LOCAL#     lite.resource_bundles = {
     #LOCAL#       'TiendeoCore' => ['Source/**/*.{xib,png,jpg,json,xcdatamodeld,xcdatamodel,xcassets,ttf,lproj}']
     #LOCAL#     }
  end

  s.subspec 'Full' do |full|
    full.name = "Full"
    #REMOTE 
full.framework = "TiendeoCore"
    #REMOTE 
full.vendored_frameworks = 'TiendeoCore.framework'

    #LOCAL#     full.source_files     = ["Source/**/*.swift", "Source/Core.h"]
    #LOCAL#     full.public_header_files = ["Source/Core.h"]
    #LOCAL#     full.resource_bundles = {
    #LOCAL#       'TiendeoCore' => ['Source/**/*.{xib,png,jpg,json,xcdatamodeld,xcdatamodel,xcassets,ttf,lproj}']
    #LOCAL#     }
    full.xcconfig = {
         'OTHER_SWIFT_FLAGS' => '$(inherited) -DFULLTIENDEOCORE'
    }
    full.dependency "TiendeoAuth", "~> 0.0.6"
    full.dependency "FacebookCore", '~> 0.4.0'
  end


end

I'm building a TiendeoCore.framework for upload it to cocoapods with the command (I have an script that build .framework and copy the simulator's architectures, I'm showing the main commands of the script):

xcodebuild -workspace "${WORKSPACE_PATH}" -scheme "${TARGET_NAME}" -configuration ${CONFIGURATION} -sdk iphoneos ONLY_ACTIVE_ARCH=NO ARCHS='arm64 armv7' BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" ENABLE_BITCODE=YES OTHER_CFLAGS="-fembed-bitcode" BITCODE_GENERATION_MODE=bitcode clean build

xcodebuild -workspace "${WORKSPACE_PATH}" -scheme "${TARGET_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6' ONLY_ACTIVE_ARCH=NO ARCHS='i386 x86_64' BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" ENABLE_BITCODE=YES OTHER_CFLAGS="-fembed-bitcode" BITCODE_GENERATION_MODE=bitcode clean build

The upload of the framework to cocoapods finish successfully, but when I install the version on my project (build and run ok), the app throws this error on start:

dyld: Library not loaded: @rpath/Bolts.framework/Bolts
  Referenced from: /private/var/containers/Bundle/Application/43993CDF-61A7-405F-BA37-6FAD4B8B5FFF/ViewerPro-Demo.app/Frameworks/TiendeoCore.framework/TiendeoCore
  Reason: image not found

My podspec has two subspec (lite and full), I'm installing the lite version by default but at runtime TiendeoCore.framworks throws that needs a dependency of full subspec, Facebook in this case.

In my code, I have a preprocessing flag called FULLTIENDEOCORE to enclose source code that use dependencies of full version:

#if FULLTIENDEOCORE
import TiendeoAuth
#endif

So if the Flag is declared in OTHER_SWIFT_FLAGS then the code will be executed (this flag is added on the podspec in the full subspec).

I don't know what I'm missing.

Thanks in advance.

  • Have you solved this issue??? This is exact problem our team has run into. Maybe you can share some insights? Because I can't even successfully upload Pod, which have subspecs as are compiled vendored frameworks – Viktor Vostrikov Feb 26 '19 at 15:58
  • Hi Viktor! We didn't solve this issue, we are going to create two separate targets and generate two different .framework. And we are going to specify different sources for every subspec. We think that you can't have one .framework for two subspec with different dependencies. So we are going to have two. – Rubén López García Feb 27 '19 at 16:19
  • We have generated two different frameworks, but our main framework cannot reference code from another optional framework.. We use #if canImport() tag and it always fails... Please provide example, of how can we access code from optional framework in the main framework??? Can we chat in some private chat? Here is my linkedIn: https://www.linkedin.com/in/viktor-vostrikov-245975a7/ – Viktor Vostrikov Mar 09 '19 at 09:47

1 Answers1

0

Subspecs are designed to be merged so that consumers can choose a subset of the available subspecs. By using the same name for both vendored_frameworks, it is likely that the wrong one is getting referenced.

If that doesn't help you may want to investigate the current open subspec issues.

Paul Beusterien
  • 27,542
  • 6
  • 83
  • 139
  • Can you share an example of successfully including vendored frameworks as a subspecs? – Viktor Vostrikov Feb 26 '19 at 15:41
  • Firebase does it by wrapping the vendored_framework in another podspec that is a dependency of the subspec - https://github.com/CocoaPods/Specs/blob/master/Specs/0/3/5/Firebase/5.17.0/Firebase.podspec.json – Paul Beusterien Feb 26 '19 at 16:15
  • I did not found vendored_framework in that example.. Here is my attempt: mainFramework.subspec 'additionalFramework' do |additionalFramework| additionalFramework.name = "additionalFramework" additionalFramework.vendored_frameworks = "additionalFramework.framework" end Now I am referencing a fully compiled framework which is optional. I could also add CocoaPods dependencies to that 'additionalFramework' and also include static framework directly(I found your post in stackOverflow about it) **mainFramework.static_framework = true** Am I correct or absolutely wrong? – Viktor Vostrikov Feb 26 '19 at 18:13