{"id":5555,"date":"2014-04-01T02:47:43","date_gmt":"2014-04-01T02:47:43","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/01\/static-library-and-weak-lsystem-collection-of-common-programming-errors\/"},"modified":"2014-04-01T02:47:43","modified_gmt":"2014-04-01T02:47:43","slug":"static-library-and-weak-lsystem-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/01\/static-library-and-weak-lsystem-collection-of-common-programming-errors\/","title":{"rendered":"Static Library and -weak-lSystem-Collection of common programming errors"},"content":{"rendered":"<p>I build a static library that links against other frameworks, particularly CoreLocation. I want to use features provided by iOS 5 but be compatible with 4.3.<\/p>\n<p>My app crash at launch when I start it on iOS devices in 4.3 with this error :<\/p>\n<pre><code>Date\/Time:       2012-08-22 16:44:53.900 +0200\nOS Version:      iPhone OS 4.3.3 (8J3)\nReport Version:  104\n\nException Type:  EXC_BREAKPOINT (SIGTRAP)\nException Codes: 0x00000001, 0xe7ffdefe\nCrashed Thread:  0\n\nDyld Error Message:\n  Symbol not found: _UIKeyboardDidChangeFrameNotification\n<\/code><\/pre>\n<p>The problem I encounter is described in this post : iOS 4 app crashes at startup on iOS 3.1.3: Symbol not found: __NSConcreteStackBlock.<\/p>\n<p>But how do you deal with that when building a static library ?? I can&#8217;t compile when I set the -weak-lSystem flag. Here is a trace :<\/p>\n<pre><code>\/Applications\/Xcode.app\/Contents\/Developer\/Toolchains\/XcodeDefault.xctoolchain\/usr\/bin\/libtool: -dynamic not specified, -all_load invalid\n\/Applications\/Xcode.app\/Contents\/Developer\/Toolchains\/XcodeDefault.xctoolchain\/usr\/bin\/libtool: -dynamic not specified the following flags are invalid: -ObjC \n\/Applications\/Xcode.app\/Contents\/Developer\/Toolchains\/XcodeDefault.xctoolchain\/usr\/bin\/libtool: can't locate file for: -weak-lSystem\n\/Applications\/Xcode.app\/Contents\/Developer\/Toolchains\/XcodeDefault.xctoolchain\/usr\/bin\/libtool: file: -weak-lSystem is not an object file (not allowed in a library)\n\/Applications\/Xcode.app\/Contents\/Developer\/Toolchains\/XcodeDefault.xctoolchain\/usr\/bin\/libtool: file: \/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/SDKs\/iPhoneOS5.1.sdk\/usr\/lib\/libxml2.2.dylib is a dynamic library, not added to the static library\n\/Applications\/Xcode.app\/Contents\/Developer\/Toolchains\/XcodeDefault.xctoolchain\/usr\/bin\/libtool: file: \/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/SDKs\/iPhoneOS5.1.sdk\/usr\/lib\/libxml2.2.dylib is a dynamic library, not added to the static library\n\/Applications\/Xcode.app\/Contents\/Developer\/Toolchains\/XcodeDefault.xctoolchain\/usr\/bin\/libtool: file: \/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/SDKs\/iPhoneOS5.1.sdk\/usr\/lib\/libz.dylib is a dynamic library, not added to the static library\n\/Applications\/Xcode.app\/Contents\/Developer\/Toolchains\/XcodeDefault.xctoolchain\/usr\/bin\/libtool: file: \/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/SDKs\/iPhoneOS5.1.sdk\/usr\/lib\/libz.dylib is a dynamic library, not added to the static library\nCommand \/Applications\/Xcode.app\/Contents\/Developer\/Toolchains\/XcodeDefault.xctoolchain\/usr\/bin\/libtool failed with exit code 1\n<\/code><\/pre>\n<p><strong>Resolved<\/strong><\/p>\n<p>See accepted answer below and do not forget to mark libraries used in different versions as Optional in Xcode. Ex: I use UIKit new notification for iOS 5 but my deployement target is 4.3 so I need to mark this library as Optional in order to make things work. It is the same for CoreLocation CLGeocoder new iOS 5 class.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I build a static library that links against other frameworks, particularly CoreLocation. I want to use features provided by iOS 5 but be compatible with 4.3. My app crash at launch when I start it on iOS devices in 4.3 with this error : Date\/Time: 2012-08-22 16:44:53.900 +0200 OS Version: iPhone OS 4.3.3 (8J3) Report [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5555","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5555","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5555"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5555\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5555"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5555"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5555"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}