文章目录
  1. 1. 准备
  2. 2. 下载编译
  3. 3. 打包完成
  4. 4. 参考资料
  5. 5. 文档信息

准备


这篇文章将要介绍如何编译 VLCKit 源码,将其打包成我们想要的类库,比如:支持 bitcode 的MoblieVLCKit 等。

首先我们要有足够的准备工作,俗话说:”工欲善其事,必先利其器”,好的工具和环境,有助于将事情变得更简单。

硬件条件:
网速方面:可以流畅的访问外网。
电脑配置:充裕的空余空间(30G 左右)

知识储备:
类库的后缀有
静态类库:.a | .framework
动态类库:.dylib | .framework
系统 .framework 是动态类库,我们可以自己建立自己的 .framework 动态类库。

了解 iOS CPU 架构,进行类库打包
目前 iOS 有以下 CPU 架构:
iPhoneOS(真机)
arm64
armv7
armv7s

iPhoneSimulator(模拟器)
x86_64
i386

关于包的CPU架构类型,有专门的查看工具 lipo , eg:
打包后的真机静态库:
lipo -info ./os/libMobileVLCKit.a
Architectures in the fat file: ./os/libMobileVLCKit.a are: armv7 armv7s arm64
打包后的模拟器静态库:
lipo -info ./sim/libMobileVLCKit.a
Architectures in the fat file: ./sim/libMobileVLCKit.a are: i386 x86_64
合成的静态库:
lipo -info ./MobileVLCKit.framework/MobileVLCKit
Architectures in the fat file: ./MobileVLCKit.framework/MobileVLCKit are: armv7 armv7s i386 x86_64 arm64

合成方法
lipo -create xxxx xxxx -output xxxx
eg:

1
2
3
4
5
$ rm -rf MobileVLCKit.framework && \
mkdir MobileVLCKit.framework && \
lipo -create ./Release-iphoneos/libMobileVLCKit.a ./Release-iphonesimulator/libMobileVLCKit.a -o MobileVLCKit.framework/MobileVLCKit && \
chmod a+x MobileVLCKit.framework/MobileVLCKit && \
cp -pr ./Release-iphoneos/MobileVLCKit ./MobileVLCKit.framework/Headers

拆分(提取)方法
lipo xxxx -thin cpu(armv7/arm64等) -output xxxx

移除方法
lipo -remove cpu(armv7/arm64等) xxxx -output xxxx

下载编译


首先把VLCKit的源码从网站上面拉下来.

git clone https://code.videolan.org/videolan/VLCKit.git
然后进入VLCKit目录

查看帮助命令 ./compileAndBuildVLCKit.sh -h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
usage: ./compileAndBuildVLCKit.sh [-s] [-v] [-k sdk]

OPTIONS
-k Specify which sdk to use (see 'xcodebuild -showsdks', current: )
-v Be more verbose (显示更多信息)
-s Build for simulator
-f Build framework for device and simulator (为设备和模拟器编译)
-d Enable Debug (debug 模式(支持断点))
-n Skip script steps requiring network interaction (跳过请求网络交互脚本)
-l Skip libvlc compilation (跳过 libvlc 编译)
-t Build for tvOS
-x Build for macOS / Mac OS X
-w Build a limited stack of non-scary libraries only
-y Build universal static libraries (编译通用静态库lib,未启用)
-b Enable bitcode (进入 bitcode)
-a Build framework for specific arch (all|i386|x86_64|armv7|armv7s|aarch64)
-e External VLC source path

从上面的命令选择中我们知道

1
2
3
[-l] 跳过libvlc编译
[-n] 跳过脚本请求网络交互步骤
[-b] 支持 bitcode

编译和打包,支持 bitcode, 支持 所有架构(真机和模拟器)为模拟器和设备编译一个支持bitcode动态库

1
$ ./compileAndBuildVLCKit.sh -v -f -b -a all

这个过程会创建 libvlc/vlc 文件夹,然后拉取 vlc 的源码进行编译

编译执行完后,出现的类包
打包完成

当我们看到 all done 的字样时,可以说 vlc 源码编译成功,后续如果不对其进行修改的话,可以使用 -l 命令避免重复编译。

编译执行完后,出现的类包
打包完成

在命令执行完后(自动打包),可在 VLCKit/build 文件夹中看到我们所打包编译出的类库。
编译执行完后,出现的类包
打包完成

若要重新打包,可执行以下命令,前提是 vlc 源码编译完成,且没有发生改变。
在后面添加参数 -l -n ,跳过 libvlc 编译 和 网络请求

1
$ ./compileAndBuildVLCKit.sh -v -f -b -a all -l -n

打包完成


lipo -info MobileVLCKit.framework
合成后类库支持的架构(设备和模拟器)
设备架构
设备架构
模拟器架构
模拟器架构

将合成的库拖入项目中,并在项目中添加所需的其他类库。一定不要忘记添加 libc++ 类库,可能会出现 not found for architecture x86_64 情况。

现在集成 MobileVLCKit 的方法有很多,其他集成方法:
1、使用 Cocoapods 集成 pod 'MobileVLCKit'
2、可以去其网站进行下载MobileVLCKit iOS,将其收到添加到项目中。手动添加一定要添加所需的其他类库,否者会编译失败。

具体使用方面可以参考官方开源客户端VLC-iOS

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
AudioToolbox.framework
AVFoundation.framework
CFNetwork.framework
CoreFoundation.framework
CoreGraphics.framework
CoreMedia.framework
CoreText.framework
CoreVideo.framework
Foundation.framework
libbz2.tbd
libiconv.tbd
OpenGLES.framework
QuartzCore.framework
Security.framework
VideoToolbox.framework
UIKit.framework

参考资料


文档信息


  • 版权声明:自由转载-保持署名-非商用-非衍生 ( CC BY-NC-ND 4.0 )
文章目录
  1. 1. 准备
  2. 2. 下载编译
  3. 3. 打包完成
  4. 4. 参考资料
  5. 5. 文档信息