{"id":4103,"date":"2014-03-30T07:42:59","date_gmt":"2014-03-30T07:42:59","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/ocmock-failing-at-runtime-collection-of-common-programming-errors\/"},"modified":"2014-03-30T07:42:59","modified_gmt":"2014-03-30T07:42:59","slug":"ocmock-failing-at-runtime-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/ocmock-failing-at-runtime-collection-of-common-programming-errors\/","title":{"rendered":"OCMock Failing at runtime-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;m trying to use OCMock for the first time in my test cases. It&#8217;s a Mac project, built on and targeting Lion, in Xcode 4.3. The main app and the test bundle both have ARC turned on, and so every time I execute the tests I see the following log message:<\/p>\n<p><code>GC: forcing GC OFF because OBJC_DISABLE_GC is set<\/code><\/p>\n<p>That&#8217;s fine, as I&#8217;m using ARC so I don&#8217;t care about GC. When I build my unit tests, linked against the latest stable release of OCMock (2.0.1), the build has no issues. At runtime, after the above log statement, I get the following:<\/p>\n<p><code>The test bundle at \/Users\/___\/Library\/Developer\/Xcode\/DerivedData\/___-ayizwpehemunvodsdvczckkvarsh\/Build\/Products\/Debug\/___Tests.octest could not be loaded because its Objective-C runtime information does not match the runtime information required by the test rig. This is likely because the test rig is being run with Objective-C garbage collection disabled, but the test bundle requires Objective-C garbage collection. To enable Objective-C garbage collection for the test rig, run it in an environment without the OBJC_DISABLE_GC environment variable. 2012-03-06 10:29:32.812 otest[8486:203] *** NSTask: Task create for path '\/Users\/___\/Library\/Developer\/Xcode\/DerivedData\/___-ayizwpehemunvodsdvczckkvarsh\/Build\/Products\/Debug\/___Tests.octest\/Contents\/MacOS\/___Tests' failed: 22, \"Invalid argument\". Terminating temporary process.<\/code><\/p>\n<p>The message implies that garbage collection is the most common culprit, but as mentioned, there is no way I&#8217;m using GC. So, what other settings could be messing me up at runtime? I didn&#8217;t think I&#8217;m doing anything atypical, and I&#8217;ve looked through my test project&#8217;s settings to be sure, and didn&#8217;t see anything weird.<\/p>\n<p><strong>Update<\/strong><\/p>\n<p>I was able to reproduce this with a new empty project.<\/p>\n<ol>\n<li>Create a new project and have it create unit tests, with ARC enabled<\/li>\n<li>Clear the <code>Test Host<\/code> setting from the unit test bundle&#8217;s build settings<\/li>\n<li>Link to the OCMock framework<\/li>\n<li>Execute the tests, and witness the same error I reported above<\/li>\n<\/ol>\n<p>Also, when I turn off ARC and make garbage collection <strong>Required<\/strong>, then <code>clang<\/code> reports a mach-o linker error, so the build doesn&#8217;t succeed. If I remove the link to the OCMock framework, it builds fine. This supports my initial thought that the problem lies somewhere other than garbage collection.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m trying to use OCMock for the first time in my test cases. It&#8217;s a Mac project, built on and targeting Lion, in Xcode 4.3. The main app and the test bundle both have ARC turned on, and so every time I execute the tests I see the following log message: GC: forcing GC OFF [&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-4103","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4103","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=4103"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4103\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4103"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}