背景:之前只是简单的使用flutter或自己创建一个工程简单的玩一下ios,最近打算使用一些第三方的公共库,就需要使用pod工具,在此记录下来。
1.安装cocoapods
sudo gem install cocoapods
2.进入工程目录下,使用pod
pod install
第一次安装需要时间比较长后面就会快一些
3.编译
下面以luaview为例,进行整体接入测试:
1.新建工程
2.在工程目录下执行 pod init
3.打开生成的Podfile文件,添加pod 依赖
target 'LuaViewDemo' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# Pods for LuaViewDemo
target 'LuaViewDemoTests' do
inherit! :search_paths
# Pods for testing
end
target 'LuaViewDemoUITests' do
inherit! :search_paths
# Pods for testing
end
pod 'LuaViewSDK', :git => 'https://github.com/alibaba/LuaViewSDK.git'
pod 'liblua', :git => 'https://github.com/alibaba/LuaViewSDK.git'
end
4.安装依赖文件,pod install
5.编译运行
错误问题1:该问题是找不到本地私有库中的类,配置路径也没有问题
Lexical or Preprocessor Issue '***.h' file not found
解决办法1:Build Settings->将代码路径加入的Header Search Paths中
解决办法2:将pod依赖关系删掉
platform :ios, "8.0"
use_frameworks!
target 'Demo' do
pod 'MJRefresh'
pod 'SDWebImage', '3.7.5'
# pod 'LuaViewSDK', :path => '../../'
# pod 'liblua', :path => '../../'
end
将代码通过 右键-> Add Files to "Demo"
两种方法均能解决该问题
问题2:Error: The source control operation failed because the
每次打开文件的时候,都会弹框提示
解决办法:需要git add 这个文件,之后才能解决