title: Theos on Mavericks: symbols not found
body: <p><strong>Please scroll down, update below</strong></p>
  
  <hr>
  
  <p>I used this tutorial to get my hands dirty on Theos and jailbreak tweak development:
  <a href="http://iphonedevwiki.net/index.php/Theos/Getting_Started" rel="nofollow noreferrer">http://iphonedevwiki.net/index.php/Theos/Getting_Started</a></p>
  
  <p>The question has been posted before ( <a href="https://stackoverflow.com/questions/20942087/theos-for-armv7-and-arm64">Theos for armv7 and arm64</a> ), but it hasn't been answered.</p>
  
  <p>To start, I just want to make a console message appear whenever I unlock the device. I followed the tutorial, but had to install <code>dpkg</code> via MacPorts to get <code>ldid</code> up and running.</p>
  
  <p>Here's my code:</p>
  
  <p>Tweak.xm:</p>
  
  <pre><code>%hook SBAwayLockBar
  
  - (void)unlock {
      %orig;
      NSLog( @"SBAwayLockBar.unlock()" );
  }
  
  %end
  </code></pre>
  
  <p>makefile:</p>
  
  <pre><code>include theos/makefiles/common.mk
  
  TWEAK_NAME = TweakTest01
  TweakTest01_FILES = Tweak.xm
  TweakTest01_FRAMEWORKS = UIKit
  
  include $(THEOS_MAKE_PATH)/tweak.mk
  
  after-install::
      install.exec "killall -9 SpringBoard"
  </code></pre>
  
  <p>This happens when I try to either <code>make</code> or <code>make package install</code>:</p>
  
  <pre><code>/tmp/theos/makefiles/targets/Darwin/iphone.mk:41: Deploying to iOS 3.0 while building for 6.0 will generate armv7-only binaries.
  Making all for tweak TweakTest01...
   Linking tweak TweakTest01...
  ld: warning: ignoring file /tmp/theos/lib/libsubstrate.dylib, missing required architecture armv7 in file /tmp/theos/lib/libsubstrate.dylib (2 slices)
  Undefined symbols for architecture armv7:
    "_MSHookMessageEx", referenced from:
        _logosLocalInit() in Tweak.xm.6991e5bc.o
  ld: symbol(s) not found for architecture armv7
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  make[2]: *** [obj/TweakTest01.dylib.ba964c90.unsigned] Error 1
  make[1]: *** [internal-library-all_] Error 2
  make: *** [TweakTest01.all.tweak.variables] Error 2
  </code></pre>
  
  <p>I tried a <code>/usr/bin/xcode-select --install</code> (as suggested by <a href="https://stackoverflow.com/questions/20776753/failed-to-build-sauriks-ldid-utility">Failed to build Saurik&#39;s ldid utility</a>), but that didn't help at all - mainly because I had all Xcode tools already installed.</p>
  
  <p>Any hints?</p>
  
  <hr>
  
  <p><strong>UPDATE 2014-03-25</strong></p>
  
  <p>So... it seems like the problem was a space in the path names that I worked in. After renaming the folder from "jailbreak stuff" to "jailbreakstuff", <code>make</code> ran fine. But since the tweak I wrote didn't really do anything, I started from scratch.</p>
  
  <p>Here's what I did:</p>
  
  <ol>
  <li>Get a theos installer script from <a href="https://gist.github.com/tom-go/3342263" rel="nofollow noreferrer">https://gist.github.com/tom-go/3342263</a></li>
  <li>Edit <code>install_theos.sh</code> line 40 to <code>msdeb="mobilesubstrate_0.9.5001_iphoneos-arm.deb"</code> (newest version when browsing <a href="http://apt.saurik.com/debs/" rel="nofollow noreferrer">http://apt.saurik.com/debs/</a> )</li>
  <li><p>I noticed getting <code>ldid</code> from the given Dropbox URL resulted in an error because the file that had been downloaded only included some HTML ("You will be redirected..."); so I referred back to <a href="http://iphonedevwiki.net/index.php/Theos/Getting_Started#For_Mac_OS_X" rel="nofollow noreferrer">http://iphonedevwiki.net/index.php/Theos/Getting_Started#For_Mac_OS_X</a> and executed step #4</p>
  
  <pre><code>git clone git://git.saurik.com/ldid.git
  cd ldid
  git submodule update --init
  ./make.sh
  cp -f ./ldid $THEOS/bin/ldid
  </code></pre></li>
  </ol>
  
  <p>Here are my sources:</p>
  
  <p><strong>Tweak.mm/Tweak.mm (symlink)</strong></p>
  
  <pre><code>#import &lt;Foundation/Foundation.h&gt;
  #import &lt;UIKit/UIKit.h&gt;
  #import &lt;SpringBoard/SpringBoard.h&gt;
  
  %hook SBAwayLockBar
  
  - (void)unlock {
       %orig;
       %log;
  
      // Call flash on SBScreenFlash =&gt; will flash Screen
      [[%c(SBScreenFlash) sharedInstance] flash];
  }
  
  %end
  </code></pre>
  
  <p><strong>makefile</strong></p>
  
  <pre><code>export ARCHS = armv7 armv7s arm64
  export TARGET = iphone:clang:7.1:7.1
  
  include theos/makefiles/common.mk
  
  TWEAK_NAME = TweakTest01
  TweakTest01_FILES = Tweak.xm
  TweakTest01_FRAMEWORKS = UIKit Foundation
  
  include $(THEOS_MAKE_PATH)/tweak.mk
  
  after-install::
      install.exec "killall -9 SpringBoard"
  </code></pre>
  
  <p>Here's some console output of <code>make package</code> (I replaced "mycompanyname" before posting here):</p>
  
  <pre><code>Making all for tweak TweakTest01...
   Preprocessing Tweak.xm...
   Compiling Tweak.xm...
   Linking tweak TweakTest01...
   Stripping TweakTest01...
   Signing TweakTest01...
  Making stage for tweak TweakTest01...
  dpkg-deb: Baue Paket »com.mycompanyname.tweaktest01« in »./com.mycompanyname.tweaktest01_0.0.1-9_iphoneos-arm.deb«.
  </code></pre>
  
  <p>Now I transfer the file with iFunBox and install the package by selecting it in iFile. Installation works fine. I respring my device, unlock it... and no flash, no log output. The only thing the (Xcode - Organizer) log shows is</p>
  
  <pre><code>SpringBoard[4602] &lt;Notice&gt;: MS:Notice: Loading: /Library/MobileSubstrate/DynamicLibraries/TweakTest01.dylib
  SpringBoard[4602] &lt;Warning&gt;: MS:Warning: nil class argument for selector unlock
  </code></pre>
  
  <p>I tried two different <code>libsubstrate.dylib</code> versions</p>
  
  <ul>
  <li><a href="https://github.com/kokoabim/iOSOpenDev/blob/master/lib/libsubstrate.dylib" rel="nofollow noreferrer">https://github.com/kokoabim/iOSOpenDev/blob/master/lib/libsubstrate.dylib</a></li>
  <li><a href="http://cdn.hbang.ws/dl/libsubstrate_arm64.dylib" rel="nofollow noreferrer">http://cdn.hbang.ws/dl/libsubstrate_arm64.dylib</a> (renamed to <code>$THEOS/lib/libsubstrate.dylib</code>)</li>
  </ul>
  
  <p>but the behaviour is the same. What's next? :)</p>