Skip to content

Commit 1860449

Browse files
authored
Merge pull request #194 from filiph/fix/libopus_temporary_fix
fix: libopus and libogg build issue on macOS
2 parents 85b4a06 + f86b762 commit 1860449

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

macos/flutter_soloud.podspec

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,19 @@ Flutter audio plugin using SoLoud library and FFI
1919
# `../src/*` so that the C sources can be shared among all target platforms.
2020
s.source = { :path => '.' }
2121
s.source_files = 'Classes/**/*.{h,mm}'
22-
s.source_files = 'Classes/**/*.{h,mm}'
2322
s.dependency 'FlutterMacOS'
2423
s.platform = :osx, '10.15'
2524

26-
# Check if opus and ogg libraries are available
27-
has_opus_ogg = system("[ -f /usr/local/lib/libogg.dylib -o -f /opt/homebrew/lib/libogg.dylib ] && [ -f /usr/local/lib/libopus.dylib -o -f /opt/homebrew/lib/libopus.dylib ]")
25+
# Check if all opus and ogg libraries are available (both x86_64 and arm64)
26+
# To get these libraries, you'll need to run `brew` both in arm64 mode
27+
# and in x86_64 mode.
28+
# See https://github.com/alnitak/flutter_soloud/issues/191#issuecomment-2692671697
29+
#
30+
# This is a temporary fix just to get things building.
31+
#
32+
# IMPORTANT: Apps won't work correctly on user's machines unless they happen
33+
# to have libopus and libogg installed.
34+
has_opus_ogg = system("[ -f /usr/local/lib/libogg.dylib] && [ -f /opt/homebrew/lib/libogg.dylib ] && [ -f /usr/local/lib/libopus.dylib] && [ -f /opt/homebrew/lib/libopus.dylib ]")
2835

2936
preprocessor_definitions = ['$(inherited)']
3037
if has_opus_ogg
@@ -43,9 +50,11 @@ Flutter audio plugin using SoLoud library and FFI
4350
'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386',
4451
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
4552
"CLANG_CXX_LIBRARY" => "libc++",
46-
'OTHER_LDFLAGS' => has_opus_ogg ? '-L/usr/local/lib -L/opt/homebrew/lib -logg -lopus' : '',
53+
'OTHER_LDFLAGS[arch=arm64]' => has_opus_ogg ? '-L/opt/homebrew/lib -logg -lopus' : '',
54+
'OTHER_LDFLAGS[arch=x86_64]' => has_opus_ogg ? '-L/usr/local/lib -logg -lopus' : '',
4755
'OTHER_CFLAGS' => '-msse -msse2 -msse3 -msse4.1 -O3 -ffast-math -flto',
48-
'OTHER_CPLUSPLUSFLAGS' => '-msse -msse2 -msse3 -msse4.1 -O3 -ffast-math -flto'
56+
'OTHER_CPLUSPLUSFLAGS' => '-msse -msse2 -msse3 -msse4.1 -O3 -ffast-math -flto',
57+
'VALID_ARCHS' => 'x86_64 arm64',
4958
}
5059

5160
s.swift_version = '5.0'

0 commit comments

Comments
 (0)