<div dir="ltr">Thanks for that blog post... perhaps I wasn't clear in what my actual question was. Let me restate:<div><br></div><div>Obviously I can use Glibc on Linux to open a file and read it. And since there is no Glibc on OS X, is there some other way that would be both CROSS PLATFORM and done purely in swift instead of relying on some external C library?</div><div><br></div><div>I've taken a cursory look at some of the early swift resources and didn't see anything that mentioned how to open a file using JUST Native Swift code... One would surely think that a programing language as nifty and cool as Swift would have a easy way to read files. Maybe its obvious and I just am missing it.</div><div><br></div><div>But at the same time I get your point just use #if #else #endif to conditional import / call functions... but coding like that doesn't seem vary fun... reminds me of looking a C code that was meant to be compiled on different processor architectures. :-( </div><div><br></div><div>--Greg</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 7, 2015 at 9:51 PM, Kwame Bryan <span dir="ltr"><<a href="mailto:kwame.bryan@gmail.com" target="_blank">kwame.bryan@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi Greg, you’ll need to do something like the following.<div><pre style="font-family:Consolas,Monaco,'Andale Mono',monospace;font-size:0.9em;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;direction:ltr;word-break:normal;line-height:1.5"><code 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;direction:ltr;word-spacing:normal;word-break:normal;line-height:1.5">#<span style="color:rgb(0,119,170)">if</span> <span style="color:rgb(221,74,104)">os<span style="color:rgb(153,153,153)">(</span></span><span style="color:rgb(102,153,0)">Linux</span><span style="color:rgb(153,153,153)">)</span>
<span style="color:rgb(0,119,170)">import</span> <span style="color:rgb(102,153,0)">Glibc</span>
#<span style="color:rgb(0,119,170)">else</span>
<span style="color:rgb(0,119,170)">import</span> <span style="color:rgb(102,153,0)">Darwin</span>
#endif</code></pre><div>Also, take a look at this blog post. <a href="http://blog.krzyzanowskim.com/2015/12/04/swift-package-manager-and-linux-compatible/" target="_blank">http://blog.krzyzanowskim.com/2015/12/04/swift-package-manager-and-linux-compatible/</a> Hope this helps.</div><div><br></div><div>Kwame</div><div><br></div><div><blockquote type="cite"><div><div class="h5"><div>On Dec 7, 2015, at 10:47 PM, Greg Skluzacek via swift-users <<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>> wrote:</div><br></div></div><div><div><div class="h5"><div dir="ltr">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><br></div><div>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><br></div><div>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><br></div><div><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)">repl.swift:1:8: <span style="color:rgb(195,55,32)">error: </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)">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)"> ^</div></div><div><br></div><div>swift --version returns:</div><div><br></div><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)">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)">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)">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)">Chateau-Louise:/ gskluzacek$ </div></div><div><br></div><div>Thanks,</div><div>-- Greg</div></div>
</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="min-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">
_______________________________________________<br>swift-users mailing list<br><a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-users" target="_blank">https://lists.swift.org/mailman/listinfo/swift-users</a><br></div></blockquote></div><br></div></div></blockquote></div><br></div>