title: Chromium : GN / Ninja - linking to OS X Framework via Build.gn failing
body: <p>TL:DR - What is the correct invocation within a Build.gn file to properly link Chromium to a third party Mac OS X Framework (and additionally include it in the Contents/Frameworks/ app bundle path)? </p>
  
  <p>See below for my Build.gn and path setups.</p>
  
  <hr>
  
  <p>I am customizing a Chrome browser by adding support for video capture via a 3rd party library. Ive modified existing Build.gn files to find my third party deps and compile my new source. Ive modified an existing Chromium Build.gn to include my new dependency:</p>
  
  <p>media/capture/video/mac/DEPS:</p>
  
  <pre><code>include_rules = [
  "+third_party/decklink",
  "+third_party/Syphon",
  </code></pre>
  
  <p>]</p>
  
  <p>Which correctly finds my new Build.gn for my Framework, Syphon: </p>
  
  <p>My Build.gn is below:</p>
  
  <pre><code>if (is_mac) {
   loadable_module("Syphon") {
   lib_dirs = ["//third_party/Syphon/mac/"]
   libs = ["Syphon.framework"]
  }
  </code></pre>
  
  <p>Compilation works, but building fails if I attempt to use objects from the Framework I'm including. I'm used to these linking errors on OS X / Xcode, but with Ninja/GN I'm unclear on the correct way to resolve them.</p>
  
  <p>The output of Ninja:</p>
  
  <p>Note - The resulting linker arguments has a linker flag to properly use -L /path/to/third_party/Syphon/mac/ which holds Syphon.framework, however, the -framework command does not find Syphon. </p>
  
  <p>I've attempted to use different Build.gn commands (like ldflags) but all result in the same issue.</p>
  
  <p>Thank you. </p>
  
  <pre><code> ninja -C out/Default
    ninja: Entering directory `out/Default'
   [4/5095] SOLINK libcapture.dylib libcapture.dylib.TOC
    FAILED: libcapture.dylib libcapture.dylib.TOC 
    if [ ! -e "./libcapture.dylib" -o ! -e "./libcapture.dylib.TOC" ] || otool -l "./libcapture.dylib" | grep -q LC_REEXPORT_DYLIB ; then TOOL_VERSION=1484604693 ../../build/toolchain/mac/linker_driver.py ../../third_party/llvm-build/Release+Asserts/bin/clang++ -shared  -Wl,-install_name,@rpath/"libcapture.dylib" -stdlib=libc++ -arch x86_64 -Werror -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.9 -Wl,-ObjC -Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/../../.. -o "./libcapture.dylib" -Wl,-filelist,"./libcapture.dylib.rsp" -framework AVFoundation -framework CoreFoundation -framework CoreGraphics -framework CoreMedia -framework CoreVideo -framework Foundation -framework IOKit ./libbase.dylib ./libbase_i18n.dylib ./libmedia.dylib ./libskia.dylib ./libdisplay.dylib ./libgfx.dylib ./libicui18n.dylib ./libicuuc.dylib ./libshared_memory_support.dylib ./libbindings.dylib ./libmojo_public_system_cpp.dylib ./libmojo_public_system.dylib ./libdisplay_types.dylib ./libgeometry.dylib ./librange.dylib &amp;&amp; { otool -l "./libcapture.dylib" | grep LC_ID_DYLIB -A 5; nm -gP "./libcapture.dylib" | cut -f1-2 -d' ' | grep -v U$$; true; } &gt; "./libcapture.dylib.TOC"; else TOOL_VERSION=1484604693 ../../build/toolchain/mac/linker_driver.py ../../third_party/llvm-build/Release+Asserts/bin/clang++ -shared  -Wl,-install_name,@rpath/"libcapture.dylib" -stdlib=libc++ -arch x86_64 -Werror -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.9 -Wl,-ObjC -Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/../../.. -o "./libcapture.dylib" -Wl,-filelist,"./libcapture.dylib.rsp" -framework AVFoundation -framework CoreFoundation -framework CoreGraphics -framework CoreMedia -framework CoreVideo -framework Foundation -framework IOKit ./libbase.dylib ./libbase_i18n.dylib ./libmedia.dylib ./libskia.dylib ./libdisplay.dylib ./libgfx.dylib ./libicui18n.dylib ./libicuuc.dylib ./libshared_memory_support.dylib ./libbindings.dylib ./libmojo_public_system_cpp.dylib ./libmojo_public_system.dylib ./libdisplay_types.dylib ./libgeometry.dylib ./librange.dylib &amp;&amp; { otool -l "./libcapture.dylib" | grep LC_ID_DYLIB -A 5; nm -gP "./libcapture.dylib" | cut -f1-2 -d' ' | grep -v U$$; true; } &gt; "./libcapture.dylib.tmp" &amp;&amp; if ! cmp -s "./libcapture.dylib.tmp" "./libcapture.dylib.TOC"; then mv "./libcapture.dylib.tmp" "./libcapture.dylib.TOC" ; fi; fi
    Undefined symbols for architecture x86_64:
   "_OBJC_CLASS_$_SyphonServerDirectory", referenced from:
    objc-class-ref in video_capture_device_syphon_mac.o
   "_SyphonServerDescriptionAppNameKey", referenced from: media::VideoCaptureDeviceSyphonMac::EnumerateDevices(std::__1::vector&lt;media::VideoCaptureDeviceDescriptor, std::__1::allocator&lt;media::VideoCaptureDeviceDescriptor&gt; &gt;*) in video_capture_device_syphon_mac.o "_SyphonServerDescriptionNameKey", referenced from:media::VideoCaptureDeviceSyphonMac::EnumerateDevices(std::__1::vector&lt;media::VideoCaptureDeviceDescriptor, std::__1::allocator&lt;media::VideoCaptureDeviceDescriptor&gt; &gt;*) in video_capture_device_syphon_mac.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    Traceback (most recent call last):
    File "../../build/toolchain/mac/linker_driver.py", line 229, in &lt;module&gt;
  Main(sys.argv)
    File "../../build/toolchain/mac/linker_driver.py", line 79, in Main
  subprocess.check_call(compiler_driver_args)
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 540, in check_call
  raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['../../third_party/llvm-build/Release+Asserts/bin/clang++', '-shared', '-Wl,-install_name,@rpath/libcapture.dylib', '-stdlib=libc++', '-arch', 'x86_64', '-Werror', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk', '-mmacosx-version-min=10.9', '-Wl,-ObjC', '-Wl,-rpath,@loader_path/.', '-Wl,-rpath,@loader_path/../../..', '-o', './libcapture.dylib', '-Wl,-filelist,./libcapture.dylib.rsp', '-framework', 'AVFoundation', '-framework', 'CoreFoundation', '-framework', 'CoreGraphics', '-framework', 'CoreMedia', '-framework', 'CoreVideo', '-framework', 'Foundation', '-framework', 'IOKit', './libbase.dylib', './libbase_i18n.dylib', './libmedia.dylib', './libskia.dylib', './libdisplay.dylib', './libgfx.dylib', './libicui18n.dylib', './libicuuc.dylib', './libshared_memory_support.dylib', './libbindings.dylib', './libmojo_public_system_cpp.dylib', './libmojo_public_system.dylib', './libdisplay_types.dylib', './libgeometry.dylib', './librange.dylib']' returned non-zero exit status 1
   [13/5095] CXX obj/third_party/WebKit/Source/wtf/wtf_unittests/ListHashSetTest.o
    ninja: build stopped: subcommand failed.
  </code></pre>