- 下载ijkplayer
git clone https://github.com/bilibili/ijkplayer
- 执行脚本下载ffmpeg
./init-ios.sh
- 进入ios目录,对脚本进行处理 compile-ffmpeg.sh compile-openssl.sh
./compile-ffmpeg.sh clean
./compile-ffmpeg.sh all
// 初始化
./init-ios-openssl.sh
// 进入ios目录添加配置
echo 'export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-openssl"' >> ../config/module.sh
// clean
./compile-ffmpeg.sh clean
// 开始编译
./compile-openssl.sh all
// 编译ffmpeg
./compile-ffmpeg.sh all
- 以上完成之后,IJKMediaDemo便可播放ssl的连接了。
-
打开target->IJKMediaFramework->build
-
在Products->Release-iphoneos->IJKMediaFramework.framework
// 查看支持的指令 lipo -info IJKMediaFramework.framework/IJKMediaFramework 'Architectures in the fat file: IJKMediaFramework.framework/IJKMediaFramework are: arm64 armv7'
-
用模拟器在build一遍,将两个framework拷贝出来再合并。
lipo -create IJKMediaFramework.framework/IJKMediaFramework sim/IJKMediaFramework.framework/IJKMediaFramework -output out/IJKMediaFramework
-
这里会出现合并失败的错误,原因是xcode12的模拟器也包含了arm64指令,删除其中的一个即可。
lipo -remove IJKMediaFramework -o IJKMediaFramework
-
合并后可以看到更多的支持指令
lipo -info IJKMediaFramework // Architectures in the fat file: IJKMediaFramework are: armv7 i386 x86_64 arm64
-
完成以上步骤后,我们将得到一个可运行的IJKMediaFramework.framework
-
接下来构建私有的pod
pod lib create BWPlayer
- 在BWPlayer.podspec中
Pod::Spec.new do |s| s.name = 'BWPlayer' s.version = '0.1.0' s.summary = 'A short description of BWPlayer.' s.description = <<-DESC TODO: Add long description of the pod here. DESC s.homepage = 'https://github.com/bairdweng/BWPlayer' s.license = { :type => 'MIT', :file => 'LICENSE' } s.author = { 'bairdweng' => 'bairdweng@gmail.com' } s.source = { :git => 'https://github.com/bairdweng/BWPlayer.git', :tag => s.version.to_s} s.requires_arc = true s.ios.deployment_target = '9.0' s.swift_version = "4.2" // 已经构建好的IJKMediaFramework.framework存放目录 s.vendored_frameworks = "BWPlayer/Frameworks/*.framework" // 需要依赖的系统库 s.frameworks = "AudioToolbox", "AVFoundation", "CoreGraphics", "CoreMedia", "CoreVideo", "MediaPlayer", "MobileCoreServices", "OpenGLES", "QuartzCore", "UIKit", "VideoToolbox" s.libraries = 'bz2','z','stdc++' s.pod_target_xcconfig = { 'VALID_ARCHS' => 'arm64 armv7 armv7s'} end
- 构建完成后打开Example,此时可以顺利运行到手机。
-
创建私有的Spec Repo
// 成功之后将在~/.cocoapods/repo中看到 BWSpecs pod repo add BWSpecs https://github.com/bairdweng/BWSpecs.git
-
设置tag,注意tag要跟s.version保持一致
-
验证
pod lib lint BWPlayer.podspec --skip-import-validation --allow-warnings
-
提交podspec
// 本地的Space名称 & podspec pod repo push BWSpecs BWPlayer.podspec --skip-import-validation --allow-warnings
-
Podfile中
// 设置源 source 'https://github.com/bairdweng/BWSpecs.git' use_frameworks! platform :ios, '9.0' target 'BWPlayer_Example' do pod 'BWPlayer' end
-
大文件的处理
// 初始化 git lfs install // 添加大文件 git lfs track "/BWPlayer/Frameworks/IJKMediaFramework.framework/IJKMediaFramework" // 正常上传即可
-
注册cocoapods
pod trunk register 644672334@qq.com "bairdweng" --description="bairdweng"