<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Greg, you’ll need to do something like the following.<div class=""><pre class=" language-swift" style="font-family: Consolas, Monaco, 'Andale Mono', monospace; font-size: 0.9em; box-sizing: border-box; margin-top: 0.5em; margin-bottom: 0.5em; border: 1px solid rgb(227, 237, 243); width: 780px; padding: 1em; overflow: auto; background-color: rgb(245, 242, 240); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; text-shadow: white 0px 1px; direction: ltr; word-break: normal; line-height: 1.5; tab-size: 4; -webkit-hyphens: none;"><code class=" language-swift" style="font-family: Consolas, Monaco, 'Andale Mono', monospace; font-size: inherit; padding: 0px; border: none; background-color: transparent; border-top-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; text-shadow: white 0px 1px; direction: ltr; word-spacing: normal; word-break: normal; line-height: 1.5; tab-size: 4; -webkit-hyphens: none;">#<span class="token keyword" style="color: rgb(0, 119, 170);">if</span> <span class="token function" style="color: rgb(221, 74, 104);">os<span class="token punctuation" style="color: rgb(153, 153, 153);">(</span></span><span class="token builtin" style="color: rgb(102, 153, 0);">Linux</span><span class="token punctuation" style="color: rgb(153, 153, 153);">)</span>
    <span class="token keyword" style="color: rgb(0, 119, 170);">import</span> <span class="token builtin" style="color: rgb(102, 153, 0);">Glibc</span>
#<span class="token keyword" style="color: rgb(0, 119, 170);">else</span>
    <span class="token keyword" style="color: rgb(0, 119, 170);">import</span> <span class="token builtin" style="color: rgb(102, 153, 0);">Darwin</span>
#endif</code></pre><div class="">Also, take a look at this blog post.&nbsp;<a href="http://blog.krzyzanowskim.com/2015/12/04/swift-package-manager-and-linux-compatible/" class="">http://blog.krzyzanowskim.com/2015/12/04/swift-package-manager-and-linux-compatible/</a>&nbsp;Hope this helps.</div><div class=""><br class=""></div><div class="">Kwame</div><div class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On Dec 7, 2015, at 10:47 PM, Greg Skluzacek via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi new to Swift and I am really excited that Apple has open sourced it! I use macs at home an Linux at work, so now I may actually be able to develop in one language on both platforms (and not use Java).<div class=""><br class=""></div><div class="">That being said, is there a way open a file for either reading line by line and writing line by line that is done purely in Swift and is cross platform.</div><div class=""><br class=""></div><div class="">I did go through the Getting Started page and saw that one was able to import Glibc on Linux which implements the C fopen, etc., but when I tried to import it in the REPL on OS X, I got the error:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono'; color: rgb(0, 249, 0); background-color: rgb(0, 0, 0);" class="">repl.swift:1:8:&nbsp;<span style="color:rgb(195,55,32)" class="">error:&nbsp;</span>no such module 'Glibc'</div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);" class="">import Glibc</div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono'; color: rgb(52, 189, 38); background-color: rgb(0, 0, 0);" class="">&nbsp;&nbsp; &nbsp; &nbsp; ^</div></div><div class=""><br class=""></div><div class="">swift --version returns:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);" class="">Chateau-Louise:/ gskluzacek$ swift --version</div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);" class="">Apple Swift version 2.1 (swiftlang-700.1.101.6 clang-700.1.76)</div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);" class="">Target: x86_64-apple-darwin14.5.0</div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);" class="">Chateau-Louise:/ gskluzacek$&nbsp;</div></div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">-- Greg</div></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=ZL8E1FCzSL2PuJ8qR3quJ6vOWd-2BuKm-2BFtg-2FxgHMRmC0lOJ7yZQn-2BziCdv9Ne2HMjxSCGsTmta1Nk7mSiaoqaqCQmrGk-2FAM7RtvKD-2F6q1ZNayK9OTJZYsNd1C9Q27zF3abmI1bjbRBMd4KBpQcs12cQDH-2FYqFFg1vWaQxGsKJGD5Demxi7Oavh-2FAqPKnU1lGK1jRkFhfO2mSgRWFCeDaCHTNmr3h9T0LK17Udz82ZvlA-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></div></blockquote></div><br class=""></div></body></html>