遇到了一个问题,多平台共用一套功能代码,但是
source_files
不支持..
🏷️ 第一种解决方案:将功能代码复制到podspec
同级下
假设功能代码在internal
目录下,且internal
与podspec
同级
只需在podspec
文件中修改如下
s.source_files = 'Classes/**/*', 'internal/*'
再执行pod install
即可
🏷️ 第二种解决方案:为功能代码创建podspec
,在需要的地方,直接引入功能代码的podspec
假设创建的podspec
为common_sharedcodes.podspec
,内容如下
#
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
# Run `pod lib lint lscam_timeline_locator.podspec` to validate before publishing.
#
Pod::Spec.new do |s|
s.name = 'common_sharedcodes'
s.version = '0.0.1'
s.homepage = 'http://www.example.com'
s.source = { :path => '.' }
s.author = { 'example' => 'email@example.com' }
s.summary = 'A posepc for common shared codes.'
s.description = <<-DESC
A posepc for lscam_timeline shared codes.
DESC
s.license = { :file => 'LICENSE' }
# s.dependency 'FlutterMacOS'
# s.platform = :osx, '10.11'
# s.swift_version = '5.0'
s.source_files = 'internal/*.{cpp,hpp}'
s.public_header_files = 'internal/*.h'
s.pod_target_xcconfig = {
'HEADER_SEARCH_PATHS' => '$(inherited) "internal/*.h"',
}
end
在需要的地方,引用方式如下
podfile
target 'Runner' do
use_frameworks!
use_modular_headers!
# 此处 path 为common_sharedcodes.podspec所在的目录
pod 'common_sharedcodes', :path => '/workspace/project'
flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__))
target 'RunnerTests' do
inherit! :search_paths
end
end
podspec
s.dependency 'common_sharedcodes', '~> 0.0.1'
再执行pod install
即可
参考链接
https://github.com/CocoaPods/CocoaPods/issues/1259