I have multi project iOS app which used cocoapods
podspec
to maintain each project as a dynamic
framework
. Each project has its own images in Assets.xcasset
and multiple other resource (xib
, ttf
, json
...).
I'm using below podspec
(which use resource_bundles
to separate resource for each pod (my pod xcassets
contain of multiple vector pdf
file imageset
)
Pod::Spec.new do |spec|
moduleName = 'UIComponent'
spec.name = moduleName
spec.version = '0.0.7'
spec.summary = "#{spec.name} function"
spec.description = <<-DESC
#{spec.name} helpful function
DESC
spec.homepage = 'https://bitbucket.org/ascendcorp/ami-ios-customer-app'
spec.license = 'MIT'
spec.author = { 'xxxx' => 'xxx' }
spec.platform = :ios, '13.0'
spec.ios.deployment_target = '13.0'
spec.swift_version = '5.3'
spec.source = {
git: '#{my_git}',
branch: 'develop',
# tag: "#{spec.version}",
}
spec.source_files = "#{spec.name}", "#{spec.name}/**/*.{h,m,swift}"
spec.resource_bundles = {
"#{spec.name}" => [
"#{spec.name}/**/*.{lproj,xcdatamodeld,xib,json,ttf,xcassets}",
],
}
spec.exclude_files = "#{spec.name}/Exclude"
spec.public_header_files = "#{spec.name}/**/*.h"
spec.static_framework = false
spec.dependency 'Core'
spec.dependency 'RxSwift'
spec.dependency 'RxCocoa'
spec.dependency 'CoreList'
spec.dependency 'SVProgressHUD'
spec.dependency 'Material'
spec.dependency 'Nuke'
end
The problem is with
spec.resource_bundles = {
"#{spec.name}" => [
"#{spec.name}/**/*.{lproj,xcdatamodeld,xib,json,ttf,xcassets}",
],
}
I can see all the resouce being copy to my Development Pods
(including xib
, Assets.xcassets
folder) but seem our normal reference not working (get bellow error)
Could not load the "ic_xxx" image referenced from a nib in the bundle with identifier "org.cocoapods.xxxx"
even my normal xib allocation also not work
super.init(nibName: "SplashViewController", bundle: Bundle(for: SplashViewController.self))
for image also not work
img = UIImage(named: name, in: Bundle(for: aClass), compatibleWith: nil)
What is the correct way to reference resource
(Assets.xcassets
, xib
...) using spec.resource_bundles
? Note: I cannot use spec.resources
as it will cause duplicate and fail the build.