TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

iOS Static Libraries Are, Like, Really Bad

95 pointsby woosterover 11 years ago

13 comments

itripnover 11 years ago
I had a pretty detailed discussion with iOS engineers at a WWDC a couple of years back. It was a somewhat frustrating conversation, mostly because of how badly I wanted true user generated Framework support, but also because the engineers had decent reasons for the existing state of things. Primarily that Frameworks (in their fullest expression) are dynamically loaded.<p>Apple has made a decision that allowing 3rd parties to dynamically load code (outside of Apple certified frameworks) is a security issue on a mobile platform in particular. I don&#x27;t have a solid counter argument, although there are certainly some technical constraints they could put in place to help mitigate the risk.<p>Anyway, agree with your essay in general. But I also understand how we got here.<p>Cheers
评论 #7048234 未加载
评论 #7047693 未加载
评论 #7047851 未加载
评论 #7047515 未加载
评论 #7047821 未加载
评论 #7047601 未加载
fleitzover 11 years ago
If you can distribute source Cocoapods is an excellent alternative to static libs.<p>And if you have to distribute static libs Cocapods again makes it much easier.
评论 #7047549 未加载
评论 #7048033 未加载
mwcampbellover 11 years ago
I wish that embedding resources in programs as const byte arrays were more common. I think that approach leads to a tightly integrated, low-overhead app, especially on platforms (not iOS) where users and third-party programs are free to do stupid things with the file system; the app either works completely or isn&#x27;t there at all.
评论 #7047790 未加载
评论 #7047658 未加载
评论 #7049681 未加载
pjmlpover 11 years ago
I really don&#x27;t see why dynamic libraries couldn&#x27;t be allowed per app, in a similar vein to other mobile OS.<p>It is also sad state of affairs that Objective-C builds up on C&#x27;s tradition of not having proper namespace support.
评论 #7049989 未加载
jherikoover 11 years ago
As much as I generally dislike the iOS ecosystem, Xcode and Apple in general this feels like complaining about nothing much of importance to me...<p>If you want to share code this becomes a non-issue - you include the code which can detect things like architecture and target at compile time and then its possible to not just transcend the boundary between iOS and OS X, but also Windows Desktop + RT, Android, other *nix flavours and that great operating system that will be released in 7 years time that we don&#x27;t even know about yet...<p>a static library is a convenience of pre-compiled code, but also an inconvenience where you can&#x27;t see inside or implement the many cool things you can with the preprocessor, meta-programming or even scripts that generate code or enforce constraints if you feel so inclined...<p>Why do you really want static libraries to be usable? Are they really a good thing? Is it really any more convenient than just including a folder of source code in the project?<p>The only real argument I can see is if you want to keep your code secret which I am philosophically opposed to in the general case...
评论 #7050091 未加载
malkiaover 11 years ago
I miss one feature - ffi, and this is not only limited to iOS - with a .dylib&#x2F;.so&#x2F;.dll and some kind of readable interface (&quot;C&quot;) you can export functions for other languages. For exampe luajit, python (ctypes, cffi), common lisp (cffi), etc.<p>Another thing is &quot;replacement&quot; - switch one version with another. This way I&#x27;ve found that sqlite 3.8.2 was misbehaving for us lately, which points to be some kind of MSVC related error (compiled 64-bit for windows using VS2010).<p>Quickly switching to the previous one, without recompiling did another thing - I had to think less about other possible changes, since only one component changed - not the whole executable.<p>Then there are times where I wished everything was statically compiled :) - On all fronts (Linux, OSX, Windows) there are too many gotchas of pointing the right way to your dlls.<p>I seem to favor Windows (get the DLLs first from the apps&#x27; folder... well not strictly, but in general) - but then that&#x27;s because Windows did not have good place to put the dlls to begin with (unlike unix).
scooprover 11 years ago
I&#x27;ve always thought that since an (iOS) app needs to be fully self contained, having only static linking makes perfect sense. You also gain dead code stripping, and linking only the archs that the main binary supports as well.<p>Most libraries I&#x27;ve dealt with have mostly amounted to interfaces to respective web apis. In those, having source code distribution makes perfect sense, even preferable when the libraries are fairly simple and that gives the freedom to compile them as one wishes. Doing it with sub-xcode projects I&#x27;ve found to be fairly simple, even if mucking around with header search paths is still a pain.<p>Granted, I haven&#x27;t really experienced library author side of things, but most of these issues are about drag&#x27;n&#x27;drop ease of use, which I don&#x27;t think <i>requires</i> dynamic libs but is more of a tooling side problem, and frankly has always been a problem in the c&#x2F;c++ land at least.<p>The lack of two-level namespace is a real problem that I&#x27;ve actually encountered. Then it was a simple rename of a class name away, but I can easily fathom a situation where it isn&#x27;t that easy (like the example of embedded sqlite3).<p>Also I hadn&#x27;t realised that the simulator and device builds are lipo&#x27;ed manually, that indeed should have a better way. But would dynamic libs really help in that situation, you would still ship x86+arm glued together without notion of the platform, even worse, you might be shipping the x86 as extra weight on appstore builds.
评论 #7049801 未加载
memracomover 11 years ago
Why use dynamic libraries if you don&#x27;t need to save storage space or RAM?<p>We have moved beyond the era of scarcity and even on desktop platforms, lots of people are including static libraries so that they are not dependent on the upstream developers&#x27; idea of what is needed. So much of this code is open source that it makes sense to build your own static library, and maybe leave out cruft that you don&#x27;t need.<p>Sure it would be nice to have a choice, but static libraries are not evil.
belluchanover 11 years ago
I can&#x27;t read this article without resizing my browser window. Fluid text width is awful. And yes wikipedia has the same problem.
评论 #7048035 未加载
评论 #7048037 未加载
评论 #7050594 未加载
评论 #7048143 未加载
rburhumover 11 years ago
Besides maintainability, there is the issue of not being able to use certain open source libraries (without some legal complexity) when you statically link libraries. IMHO, that is a much greater problem.
评论 #7048481 未加载
jarjouraover 11 years ago
Xcode (and the entire tool-chain) has support for static frameworks that would negate any distribution problems the OP wants. Apple snips that functionality out of the iOS SDK for some unknown reason, but I suspect that would be a much better request to ask for.<p>I do agree that the iPhoneSimulator and iPhoneOS SDKs should be better integrated at compile time. Yet, they were architected as completely different environments, so I suspect that won&#x27;t be an easy request to fulfill.<p>Anyway, what benefit would having a dynamically loaded library give you when each app runs sandboxed? I can just imagine a scenario where one framework uses a version of ASINetworking and another uses AFNetworking and they both attempt to use some version of JSONKit to parse out the result. Objective-C and its amazing namespace collision management will just carefully (and by carefully, I mean, not at all) pick one implementation over the other and leave a happy warning for all to see.
评论 #7048237 未加载
wesnerm2over 11 years ago
A workaround is to write iOS applications in Monotouch, which does support DLLs.
评论 #7047980 未加载
ID_HOMEover 11 years ago
Apple doesn&#x27;t want small developers on iOS. I thought this was clear 5 years ago. Every thing they&#x27;ve done in both the market, the UI, and the OS makes it difficult for small developers to get a leg up and for new technologies to be adopted. To Apple, integrating 3rd party libraries is not a concern of there&#x27;s, that&#x27;s for the professionals to try to get to work, then use as a competitive barrier, thus increasing the quality of the top apps in the market, the only apps that matter.
评论 #7047674 未加载
评论 #7047996 未加载