tanersener / mobile-ffmpeg

FFmpeg for Android, iOS and tvOS. Not maintained anymore. Superseded by FFmpegKit.
https://tanersener.github.io/mobile-ffmpeg
GNU General Public License v3.0
3.87k stars 791 forks source link

Post-script to solve duplicite FFMPEG framework #582

Closed mkj-is closed 4 years ago

mkj-is commented 4 years ago

Description When having both MobileVLCKit and MobileFFMPEG installed in the project and running pod install or pod update will break the fix recommended in the Wiki:

https://github.com/tanersener/mobile-ffmpeg/wiki/Using-Multiple-FFmpeg-Implementations-In-The-Same-iOS-Application

It is even more important if you are not commiting your Pods folder to version control system. Then the fix is just local. (This is normal practice, see https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control)

Expected behavior I think the documentation could be improved so the fix is not so fragile.

I propose to adding the guidance and this post-script to Wiki:

post_install do |installer|
    installer.pods_project.targets.each do |target|
        if target.name == "Pods-MYPROJECT"
            puts "Updating #{target.name} OTHER_LDFLAGS"
            target.build_configurations.each do |config|
                xcconfig_path = config.base_configuration_reference.real_path

                # read from xcconfig to build_settings dictionary
                build_settings = Hash[*File.read(xcconfig_path).lines.map{|x| x.split(/\s*=\s*/, 2)}.flatten]

                # modify OTHER_LDFLAGS
                vlc_flag = ' -framework "MobileVLCKit"'
                build_settings['OTHER_LDFLAGS'].gsub!(vlc_flag, "")
                build_settings['OTHER_LDFLAGS'].gsub!("\n", "")
                build_settings['OTHER_LDFLAGS'] += vlc_flag + "\n"

                # write build_settings dictionary to xcconfig
                File.open(xcconfig_path, "w") do |file|
                  build_settings.each do |key,value|
                    file.write(key + " = " + value)
                  end
                end
            end
        end
    end
end

I also added the solution here for reference: https://stackoverflow.com/a/64502938/3887546

Current behavior I needed to experiment and write my own script to fix the issue.

Logs

pod install
Analyzing dependencies
Downloading dependencies
Generating Pods project
Updating Pods-MYPROJECT OTHER_LDFLAGS
Integrating client project
Pod installation complete! There are 19 dependencies from the Podfile and 32 total pods installed.

Environment

Other I can't submit a PR to the Wiki, that's why I'm opening this issue.

tanersener commented 4 years ago

Thanks for sharing this. Updated the wiki with your post install script.

mkj-is commented 4 years ago

No problem, thanks for adding it to the documentation. I hope it will be helpful for others.

luotao001 commented 3 years ago

Hi @mkj-is :

Does't work ! I have try this,but i can't run my app,Please try like below:

1)Create a new app project (Just create a new project) 2)Edit podfile like this:

platform :ios, '12.1' target 'ffmpegTest' do pod 'mobile-ffmpeg-full', '~> 4.4' pod 'MobileVLCKit', '~>3.3.0' post_install do |installer| installer.pods_project.tar..............

3)Run pod install 4)Run app

I get some errors: Unable To Install “ffmpegTest” Please try again later. Failed to load Info.plist from bundle at path /Users/XXXXXXXX/Library/Developer/CoreSimulator/Devices/616EA04F-F09A-48AE-8B86-DF04043B0A5A/data/Library/Caches/com.apple.mobile.installd.staging/temp.FR5Mrc/extracted/ffmpegTest.app/Frameworks/mobileffmpeg.framework; Extra info about Info.plist: Couldn't stat /Users/XXXXXXXXX/Library/Developer/CoreSimulator/Devices/616EA04F-F09A-48AE-8B86-DF04043B0A5A/data/Library/Caches/com.apple.mobile.installd.staging/temp.FR5Mrc/extracted/ffmpegTest.app/Frameworks/mobileffmpeg.framework/Info.plist: No such file or directory

My Xcode is Version 12.4 (12D4e) sorry about my poor english!