podspec中引用父级目录的功能代码

遇到了一个问题,多平台共用一套功能代码,但是source_files 不支持..

🏷️ 第一种解决方案:将功能代码复制到podspec同级下

假设功能代码在internal目录下,且internalpodspec同级

只需在podspec文件中修改如下

s.source_files     = 'Classes/**/*', 'internal/*'

再执行pod install 即可

🏷️ 第二种解决方案:为功能代码创建podspec ,在需要的地方,直接引入功能代码的podspec

假设创建的podspeccommon_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

  • 7
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

倾云鹤

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值