<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>IOKit &#8211; Gary&#039;s &#8230;Lasamia</title>
	<atom:link href="https://garynil.tw/tag/iokit/feed/" rel="self" type="application/rss+xml" />
	<link>https://garynil.tw</link>
	<description>🍎 📱 🖥 🔨 😄</description>
	<lastBuildDate>Sat, 25 Feb 2017 18:36:42 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.3</generator>

<image>
	<url>https://i0.wp.com/garynil.tw/wp-content/uploads/2017/01/cropped-Gary_v3.0.jpg?fit=32%2C32&#038;ssl=1</url>
	<title>IOKit &#8211; Gary&#039;s &#8230;Lasamia</title>
	<link>https://garynil.tw</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">147732124</site>	<item>
		<title>[Tutorial] Import IOKit framework into Xcode project</title>
		<link>https://garynil.tw/2017/01/298/tutorial-import-iokit-framework-into-xcode-project/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=tutorial-import-iokit-framework-into-xcode-project</link>
					<comments>https://garynil.tw/2017/01/298/tutorial-import-iokit-framework-into-xcode-project/#comments</comments>
		
		<dc:creator><![CDATA[Gary]]></dc:creator>
		<pubDate>Thu, 26 Jan 2017 18:44:03 +0000</pubDate>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[IOKit]]></category>
		<category><![CDATA[Xcode]]></category>
		<category><![CDATA[Yalu]]></category>
		<guid isPermaLink="false">https://garynil.tw/?p=298</guid>

					<description><![CDATA[<p>While you&#8217;re developing iOS project on Xcode, you may need IOKit framework for some reason, such as get UDID of iDevice &#8230;etc, or using on Yalu&#8217;s project&#8230; The I/O Kit framework implements non-kernel access to I/O Kit objects (drivers and nubs) through the device-interface mechanism. So, in this article, I tried to write down how I import IOKit framework into a Xcode project....</p>
<p>這篇文章 <a rel="nofollow" href="https://garynil.tw/2017/01/298/tutorial-import-iokit-framework-into-xcode-project/">[Tutorial] Import IOKit framework into Xcode project</a> 最早出現於 <a rel="nofollow" href="https://garynil.tw">Gary&#039;s ...Lasamia</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>While you&#8217;re developing iOS project on Xcode, you may need IOKit framework for some reason, such as <a href="http://www.cnblogs.com/liyy2015/p/6090204.html" target="_blank">get UDID of iDevice</a> &#8230;etc, or using on <a href="https://garynil.tw/2017/01/295" target="_blank">Yalu&#8217;s project</a>&#8230;</p>
<p><citation>The I/O Kit framework implements non-kernel access to I/O Kit objects (drivers and nubs) through the device-interface mechanism.</citation></p>
<p>So, in this article, I tried to write down how I import IOKit framework into a Xcode project.</p>
<p>Things you need are：</p>
<ul>
<li>Xcode 8 (This sample was builded on Xcode version 8 in macOS 10.12)</li>
<li>iOS SDK (It should be installed with your Xcode)</li>
<li><a href="https://github.com/benjamin-42/Trident" target="_blank">Trident</a> &#8211; IOKit header files</li>
</ul>
<h3>Import Error</h3>
<p>When you try to use IOKit, for instance：<br />
<code>#import &lt;IOKit/IOKitLib.h&gt;</code></p>
<p>you may meet error like this：<br />
<a href="https://flic.kr/p/RkUc9q"><img data-recalc-dims="1" fetchpriority="high" decoding="async" src="https://i0.wp.com/farm1.staticflickr.com/746/32386678372_f82d859a17_z.jpg?resize=640%2C425&#038;ssl=1" alt="螢幕快照 2017-01-27 上午1.32.08" width="640" height="425" /></a></p>
<p><span id="more-298"></span></p>
<h3>Step 1：Import IOKit Framework</h3>
<p>Different from IOKit as a libraries on iOS 5, <a href="https://developer.apple.com/library/content/documentation/DeviceDrivers/Conceptual/IOKitFundamentals/Introduction/Introduction.html" target="_blank">Apple</a> change IOKit from library into framework on iOS 7.<br />
So first of all, we need to import the IOKit framework in Xcode.app into our project</p>
<p>if you try to type in your terminal<br />
<code>$ find /Applications/Xcode.app/ -name IOKit.framework</code><br />
you will find 5 different IOKit framework of 5 different platforms in Xcode.app<br />
<a href="https://flic.kr/p/QhPHhQ"><img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/farm1.staticflickr.com/667/31695497964_c298971de2_z.jpg?resize=640%2C495&#038;ssl=1" alt="螢幕快照_2017-01-27_上午1_42_38" width="640" height="495" /></a></p>
<p>We need &#8220;<em>iPhoneOS.platform</em>&#8221; recently, the path is：</p><pre class="urvanov-syntax-highlighter-plain-tag">/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/IOKit.framework</pre><p><a href="https://flic.kr/p/RzoiHB"><img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/farm1.staticflickr.com/702/32539278065_09c7ae89df_z.jpg?resize=640%2C396&#038;ssl=1" alt="螢幕快照_2017-01-27_上午1_45_25" width="640" height="396" /></a></p>
<p>Then go to application Target → General in Xcode project tab, and find &#8220;<em>Link Frameworks and Libraries</em>&#8220;.<br />
<a href="https://flic.kr/p/QhPHbC"><img data-recalc-dims="1" loading="lazy" decoding="async" src="https://i0.wp.com/farm1.staticflickr.com/496/31695497604_2600718c01_z.jpg?resize=640%2C364&#038;ssl=1" alt="螢幕快照_2017-01-27_上午1_49_33" width="640" height="364" /></a></p>
<p>Press the add button on the bottom left and use &#8220;<em>Add Other</em>&#8221; button to find the framework in the specific path.<br />
<a href="https://flic.kr/p/QhPHvq"><img data-recalc-dims="1" loading="lazy" decoding="async" src="https://i0.wp.com/farm1.staticflickr.com/680/31695498694_73e3f57dd2_z.jpg?resize=640%2C364&#038;ssl=1" alt="螢幕快照 2017-01-27 上午1.54.51" width="640" height="364" /></a></p>
<p>Find the IOKit.framework on the path I mentioned above and add it, after you finish it, it will show up in the area of &#8220;<em>Link Frameworks and Libraries</em>&#8221;</p>
<p>Also remember check if the IOKit.framework also shows up at the area of &#8220;<em>Link Binary with Libraries</em>&#8221; at application Target → Build Phases in Xcode project tab<br />
<a href="https://flic.kr/p/RzoiDZ"><img data-recalc-dims="1" loading="lazy" decoding="async" src="https://i0.wp.com/farm1.staticflickr.com/346/32539277855_ecf3a74c2f_z.jpg?resize=640%2C364&#038;ssl=1" alt="螢幕快照_2017-01-27_上午1_55_00" width="640" height="364" /></a></p>
<h3>Step 2：Add header files of IOKit</h3>
<p>I read some article on internet said that header files of IOKit framework will be at</p><pre class="urvanov-syntax-highlighter-plain-tag">Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/IOKit.framework/Headers</pre><p>but I couldn&#8217;t find any header files in the path, so I tried another way.<br />
I use the header files in <a href="https://github.com/benjamin-42/Trident" target="_blank">Trident</a> and add it to my project.<br />
First, download it form GitHub, what we need is a folder in it <code>Trident-master/Headers/IOKit</code> called IOKit<br />
<a href="https://flic.kr/p/RkUbPh"><img data-recalc-dims="1" loading="lazy" decoding="async" src="https://i0.wp.com/farm1.staticflickr.com/363/32386677262_71be98136d_z.jpg?resize=640%2C327&#038;ssl=1" alt="螢幕快照_2017-01-27_上午2_01_45" width="640" height="327" /></a></p>
<p>Copy the IOKit folder to $(SRCROOT) &#8211; the path to the directory containing your Xcode project<br />
<a href="https://flic.kr/p/QhQ2zw"><img data-recalc-dims="1" loading="lazy" decoding="async" src="https://i0.wp.com/farm1.staticflickr.com/566/31695559484_917c7d9dd0_z.jpg?resize=640%2C327&#038;ssl=1" alt="螢幕快照_2017-01-27_上午2_02_05" width="640" height="327" /></a></p>
<p><a href="https://flic.kr/p/RzoizF"><img data-recalc-dims="1" loading="lazy" decoding="async" src="https://i0.wp.com/farm1.staticflickr.com/658/32539277605_84c0909ec7_z.jpg?resize=640%2C347&#038;ssl=1" alt="螢幕快照_2017-01-27_上午2_11_45" width="640" height="347" /></a><br />
Then link the folder to your project, drag the folder to the project&#8217;s &#8220;Groups &amp; Files&#8221; area</p>
<p><a href="https://flic.kr/p/RzoiKv"><img data-recalc-dims="1" loading="lazy" decoding="async" src="https://i0.wp.com/farm1.staticflickr.com/770/32539278175_44154a11d6_z.jpg?resize=640%2C364&#038;ssl=1" alt="螢幕快照 2017-01-27 上午2.13.46" width="640" height="364" /></a></p>
<h3>Step 3：Make Xcode find header files you added</h3>
<p>Go to application Target → Build Setting in Xcode project tab, and search &#8220;<code2>Header Search Paths</code2>&#8221; by search bar on the top right of navigator.<br />
<a href="https://flic.kr/p/RkWqf1"><img data-recalc-dims="1" loading="lazy" decoding="async" src="https://i0.wp.com/farm1.staticflickr.com/278/32387112652_b665723ba9_z.jpg?resize=640%2C364&#038;ssl=1" alt="螢幕快照_2017-01-27_上午2_31_26" width="640" height="364" /></a></p>
<p>and add <code>$(SRCROOT)</code> into the item, remember change the option to &#8220;recursive&#8221;<br />
<a href="https://flic.kr/p/RozLaz"><img data-recalc-dims="1" loading="lazy" decoding="async" src="https://i0.wp.com/farm1.staticflickr.com/473/32417031811_b96b2c0c71_z.jpg?resize=640%2C429&#038;ssl=1" alt="螢幕快照 2017-01-27 上午2.50.58" width="640" height="429" /></a></p>
<p>Then it done.<br />
Remember to clean your project (CMD+SHIFT+K) and build it again</p>
<p>這篇文章 <a rel="nofollow" href="https://garynil.tw/2017/01/298/tutorial-import-iokit-framework-into-xcode-project/">[Tutorial] Import IOKit framework into Xcode project</a> 最早出現於 <a rel="nofollow" href="https://garynil.tw">Gary&#039;s ...Lasamia</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://garynil.tw/2017/01/298/tutorial-import-iokit-framework-into-xcode-project/feed/</wfw:commentRss>
			<slash:comments>6</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">298</post-id>	</item>
	</channel>
</rss>
