Build fails when using methods from I/O Kit on XCode
<p>I need to perform some operations in my C++ app upon sleep and wake up of Mac OS. I am being pointed to using I/O Kit.</p>

<p>I followed <a href="https://developer.apple.com/library/mac/qa/qa1340/_index.html" rel="nofollow">this guide</a>, specifically "Listing 3". No build errors occurred with the <code>#include</code> directives for <code>IOKit</code>.</p>

<p>However, build fails when I uncomment <code>IOAllowPowerChange()</code> or <code>IOCancelPowerChange()</code>:</p>

<pre><code>Undefined symbols for architecture x86_64:
  "_IOAllowPowerChange", referenced from:
      SleepCallback(void*, unsigned int, unsigned int, void*) in MyAppFrameWork.a(PowerWatcher.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
</code></pre>

<p>I tried adding <code>IOKit.framework</code> in Project Settings > Build Phases > Link Binary With Libraries, which didn't change anything.</p>

<p>What am I missing?</p>

<p><strong>EDIT</strong></p>

<p>Same error occurs when using any method from I/O Kit, including: <code>IONotificationPortGetRunLoopSource()</code> and <code>IORegisterForSystemPower()</code>.</p>

<p>No errors though when declaring variables, for example for <code>IONotificationPortRef</code></p>