因此,针对1.0+的GStreamer文档似乎……至少可以说没有。 GStreamer SDK有一些helpul tips,但不幸的是,它们没有达到要求。

所以,这就是我所做的。我已经在 /Library/GStreamer.Framework/ 中构建了一个调用GStreamer的应用程序

我使用命令行工具进行构建。这是我可以构建此应用程序的唯一方式。我不能使用XCode GUI。

我想将此应用程序提交到商店,但是这样做不能将其作为软件包提交(因此我可以 bundle GStreamer软件包安装程序),这意味着我必须将GStreamer.framework与我的应用程序 bundle 在一起。

在上面的GStreamer SDK文档中,您会注意到一个名为osxrelocator.py的工具。很好,因为它将 /Library/GStreamer.Framework 的所有引用更改为 @executable_path /../ Frameworks / GStreamer.framework /



不幸的是,所有GStreamer .dylibs都有一个问题...您需要使用install_name_tool -id更改其路径,因为install_name_tool -change不会更改其自身的路径!

因此,例如使用otool:

$ otool -L Application.app/Contents/Frameworks/GStreamer.framework/Versions/1.0/lib/libgstreamer-1.0.0.dylib
Application.app/Contents/Frameworks/GStreamer.framework/Versions/1.0/lib/libgstreamer-1.0.0.dylib:
    Library/Frameworks/GStreamer.framework/Versions/1.0/lib/libgstreamer-1.0.0.dylib (compatibility version 402.0.0, current version 402.0.0)
    Library/Frameworks/Frameworks/GStreamer.framework/Versions/1.0/lib/libgobject-2.0.0.dylib (compatibility version 4001.0.0, current version 4001.0.0)
    Library/Frameworks/GStreamer.framework/Versions/1.0/lib/libffi.6.dylib (compatibility version 7.0.0, current version 7.1.0)
    Library/Frameworks/GStreamer.framework/Versions/1.0/lib/libgmodule-2.0.0.dylib (compatibility version 4001.0.0, current version 4001.0.0)
    Library/Frameworks/Frameworks/GStreamer.framework/Versions/1.0/lib/libglib-2.0.0.dylib (compatibility version 4001.0.0, current version 4001.0.0)
    Library/Frameworks/Frameworks/GStreamer.framework/Versions/1.0/lib/libintl.8.dylib (compatibility version 10.0.0, current version 10.2.0)
    Library/Frameworks/Frameworks/GStreamer.framework/Versions/1.0/lib/libiconv.2.dylib (compatibility version 8.0.0, current version 8.1.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
    /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 855.14.0)

然后使用osxrelocator.py(调用install_name_tool -change):
./osxrelocator.py Application.app/Contents/MacOS /Library/Frameworks/GStreamer.framework/Versions/Current/lib @executable_path/../Frameworks/GStreamer.framework/Versions/Current/lib -r

给出:
$ otool -L Application.app/Contents/Frameworks/GStreamer.framework/Versions/1.0/lib/libgstreamer-1.0.0.dylib
Application.app/Contents/Frameworks/GStreamer.framework/Versions/1.0/lib/libgstreamer-1.0.0.dylib:
    /Library/Frameworks/GStreamer.framework/Versions/1.0/lib/libgstreamer-1.0.0.dylib (compatibility version 402.0.0, current version 402.0.0)
    @executable_path/../Frameworks/GStreamer.framework/Versions/1.0/lib/libgobject-2.0.0.dylib (compatibility version 4001.0.0, current version 4001.0.0)
    @executable_path/../Frameworks/GStreamer.framework/Versions/1.0/lib/libffi.6.dylib (compatibility version 7.0.0, current version 7.1.0)
    @executable_path/../Frameworks/GStreamer.framework/Versions/1.0/lib/libgmodule-2.0.0.dylib (compatibility version 4001.0.0, current version 4001.0.0)
    @executable_path/../Frameworks/GStreamer.framework/Versions/1.0/lib/libglib-2.0.0.dylib (compatibility version 4001.0.0, current version 4001.0.0)
    @executable_path/../Frameworks/GStreamer.framework/Versions/1.0/lib/libintl.8.dylib (compatibility version 10.0.0, current version 10.2.0)
    @executable_path/../Frameworks/GStreamer.framework/Versions/1.0/lib/libiconv.2.dylib (compatibility version 8.0.0, current version 8.1.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
    /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 855.14.0)

注意,.dylib引用自身的第一行吗?除非您调用install_name_tool -id,否则它不会更改为@executable_path /../ Frameworks / GStreamer.framework /。这发生在GStreamer框架中的每个.dylib上!它们有数百个,我敢肯定,手动执行此操作肯定会导致错误。

希望我已经阐明了我的问题。有人对做什么有任何建议吗?

谢谢!

最佳答案

我创建了一个简单的Xcode项目,向您展示如何 bundle 框架:
https://github.com/corrosion/gstreamer-osx-bundle.git

对于库重定位,请使用:
https://github.com/tito/osxrelocator

安装程序以使用XCode构建项目:

  • 安装gstreamer-1.0-1.5.2-x86_64.pkg
  • 安装gstreamer-1.0-devel-1.5.2-x86_64.pkg
  • 将/Library/Frameworks/GStreamer.framework移至$(PROJECT_DIR)/GStreamer-devel.framework
  • 转到$(PROJECT_DIR)并运行以下命令:
  • osxrelocator ./GStreamer-devel.framework/Versions/Current /Library/Frameworks/GStreamer.framework/ pwd /GStreamer-devel.framework/
  • install_name_tool -id @executable_path/../Frameworks/GStreamer.framework/GStreamer ./GStreamer-devel.framework/Versions/Current/GStreamer
  • 将“$(PROJECT_DIR)/GStreamer-devel.framework/Headers”添加到标题搜索路径
  • 将“GStreamer-devel.framework / GStreamer”文件添加到Xcode项目



  • 准备运行时框架:
  • 安装gstreamer-1.0-1.5.2-x86_64.pkg
  • 将/Library/Frameworks/GStreamer.framework移至$(PROJECT_DIR)/GStreamer.framework
  • 对框架进行一些清理:
  • rm ./GStreamer.framework/Headers ./GStreamer.framework/Commands
  • rm ./GStreamer.framework/Versions/Current/Commands
  • rm -r ./GStreamer.framework/Versions/Current/bin/
  • rm -r ./GStreamer.framework/Versions/Current/etc/
  • rm -r ./GStreamer.framework/Versions/Current/share/
  • 迁移框架的.dylibs:
  • osxrelocator -r ./GStreamer.framework/Versions/Current /Library/Frameworks/GStreamer.framework/ @executable_path/../Frameworks/GStreamer.framework/
  • 由于在gst_init期间执行了gst-plugin-scanner,因此它还必须能够找到所有库。
    因此,在libexec目录中创建指向“Frameworks”的链接,以解析@executable_path /../ Frameworks / GStreamer.framework /
  • ln -sf ../../../../ GStreamer.framework/Versions/Current/libexec/Frameworks
  • 在项目的Build Phases设置中,创建新的Copy Files Phase并将GStreamer.framework复制到Fameworks


  • 在调用gst_init()之前,在代码中设置GST_PLUGIN_SCANNER和GST_PLUGIN_SYSTEM_PATH环境变量:
    // Setup GSTreamer environment
    NSString *frameworksPath = [[NSBundle mainBundle] privateFrameworksPath];
    NSString *scannerPath = [NSString stringWithFormat:@"%@/%s", frameworksPath,
                             "GStreamer.framework/Versions/1.0/libexec/gstreamer-1.0/gst-plugin-scanner"];
    NSString *pluginsPath = [NSString stringWithFormat:@"%@/%s", frameworksPath,
                             "GStreamer.framework/Versions/1.0/lib"];
    setenv("GST_PLUGIN_SCANNER", [scannerPath UTF8String], 1);
    setenv("GST_PLUGIN_SYSTEM_PATH", [pluginsPath UTF8String], 1);
    
    // Initialize GStreamer
    gst_init(&argc, (char ***) &argv);
    

    关于macos - 用Mac OS X应用程序部署GStreamer框架的最佳方法?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25912978/

    10-10 13:43