如何创建nginx rtmp module的xcode工程
Nov 20, 2016 · 1 minute read · Comments适用于MacOS Sierra新系统,感谢 https://github.com/Akagi201/ffmpeg-xcode
step1 编译nginx-1.8.1和nginx-rtmp-module模块
找一个位置放置好nginx和nginx-rtmp-module的代码,比如:
nginx-1.8.1 ├── CHANGES ├── CHANGES.ru ├── LICENSE ├── Makefile ├── README ├── auto ├── conf ├── configure ├── contrib ├── html ├── man ├── nginx-rtmp-module ├── objs └── src
进入nginx目录,执行configure命令,configure命令可能会因不同机器而不同,可以参考在我的mac上的命令如下:
./configure --prefix=/Users/duanbingnan_mt/nginx --add-module=./nginx-rtmp-module --with-debug --with-http_ssl_module --with-cc-opt="-I/usr/local/Cellar/pcre/8.37/include -I/usr/local/opt/openssl/include" --with-ld-opt="-L/usr/local/Cellar/pcre/8.37/lib -L/usr/local/opt/openssl/lib"
开始编译 make -j4
step2 新建一个空的xcode目录
创建一个空的xcode项目
然后选一个地方保存xcode的工程文件。
step3 将nginx源码(包含nginx-rtmp-module)拖拽到xcode项目中
将nginx整个源码目录拖拽进xcode项目中的nginx-rtmp-xcode目录下
下一步,这里一定不要勾选”Create external build system project”
下一步,这里一定要勾选”Add to target”下的”nginx-rtmp-xcode”,否则看代码时无法跳转,写代码时也没有提示
step4 添加一个target
File -> New -> Target -> Cross Platform -> other -> External Build System
target命名为nginx-rtmp-make,确认你的make工具在/usr/bin/make路径下
target切换到nginx-rtmp-make
step5 修改nginx-rtmp-make的源码路径
打开nginx-rtmp-xcode工程配置页面,选择nginx-rtmp-make这个target,在”info”中输入nginx源码的路径:
step6 修改编译参数
用鼠标点击xode界面左上角的切换target按钮,选择”Edit Scheme”, 在”Run”标签页中的”Info”下选择第一步编译出来的Nginx可执行二进制文件路径
在Arguments下可以添加启动参数,对于nginx来说,可以指定Nginx.conf的路径
step7 调试
修改nginx.conf,加上下面几个配置项
master_process off; worker_processes 1; daemon off;
下断点,调试