<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" xml:lang="en"><title type="text">Fabián Cañas' Blog</title><link rel="alternate" type="text/html" href="http://www.fabiancanas.com" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/FabianCanas" /><subtitle type="html">A personal blog on philosophy, science, coding, and anything else I find interesting.</subtitle><updated>1970-01-01T00:00:00+00:00</updated><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/FabianCanas" /><feedburner:info uri="fabiancanas" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><link rel="license" type="text/html" href="http://creativecommons.org/licenses/by-sa/3.0/" /><entry><title type="text">Per File ARC in CocoaPods</title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/FabianCanas/~3/M1CdnWTBnkw/per-file-arc-in-cocoapods" /><updated>2013-05-04T03:11:04-07:00</updated><id>http://www.fabiancanas.com/entry/per-file-arc-in-cocoapods</id><content type="html">&lt;p&gt;tl;dr&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Pod::Spec.new do |s|
  s.name = 'MyPod'
  ...
  non_arc_files = 'Classes/FirstNonARCClass.m',
    'Classes/SecondNonARCClass.m',
    'Classes/ThirdNonARCClass.m'
  s.requires_arc = true
  s.source_files = 'Classes/*.{h,m}'
  s.exclude_files = non_arc_files
  s.subspec 'no-arc' do |sna|
    sna.requires_arc = false
    sna.source_files = non_arc_files
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;ARC&lt;/h2&gt;

&lt;p&gt;Automatic reference counting (ARC) is a good thing. It's a great compile-time technology that makes it easier, in most cases, to not accidentally introduce trivial memory leaks in modern Objective-C apps.&lt;/p&gt;

&lt;p&gt;But sometimes, you have older code with traditional memory management; it's not really worth converting to ARC if it's correct, and possibly finely tuned. And sometimes ARC introduces &lt;a href="http://www.learn-cocos2d.com/2013/03/confirmed-arc-slow/"&gt;a little unnecessary overhead&lt;/a&gt; that can balloon out of control when handling large numbers of objects. There are also good reasons to put Objective-C objects into structs or other odd places that ARC prohibits or makes difficult (Objective-C++ anyone?).&lt;/p&gt;

&lt;p&gt;That said, ARC is almost always a good idea. And so disabling ARC should be the exception, not the rule.&lt;/p&gt;

&lt;h2&gt;CocoaPods&lt;/h2&gt;

&lt;p&gt;&lt;a href="http://cocoapods.org/"&gt;CocoaPods&lt;/a&gt; is an excellent dependency management system for Objective-C projects. Dependencies are distributed as 'Pods' which are described in podpecs. A podspec is a kind of build description, that specifies where the source is to be found, dependencies it has, and how it should be configured and compiled.&lt;/p&gt;

&lt;p&gt;CocoaPods lets you specify ARC on a spec or subspec basis, but doing so on a per-file basis is not planned for the spec DSL. The &lt;a href="https://github.com/CocoaPods/CocoaPods/issues/589#issuecomment-9350801"&gt;suggested way of doing this&lt;/a&gt; is a little unsatisfactory because it has you listing each file to exclude twice. Luckily we're working with ruby and we can just exctract the list of files to exclude into a list we can use to exclude from the sources and include in a non-ARC subspec.&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/FabianCanas?a=M1CdnWTBnkw:Pj63AuQkKjs:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FabianCanas?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/FabianCanas?a=M1CdnWTBnkw:Pj63AuQkKjs:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FabianCanas?i=M1CdnWTBnkw:Pj63AuQkKjs:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/FabianCanas/~4/M1CdnWTBnkw" height="1" width="1"/&gt;</content><feedburner:origLink>http://www.fabiancanas.com/entry/per-file-arc-in-cocoapods</feedburner:origLink></entry><entry><title type="text">CocoaPods and GYP</title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/FabianCanas/~3/Yx8cnx0gNY8/cocoapods-and-gyp" /><updated>2013-02-20T03:40:05-08:00</updated><id>http://www.fabiancanas.com/entry/cocoapods-and-gyp</id><content type="html">&lt;h2&gt;CocoaPods&lt;/h2&gt;

	&lt;p&gt;&lt;a href="http://cocoapods.org"&gt;CocoaPods&lt;/a&gt; is an excellent dependency management system for Objective-C projects. Dependencies are distributed as 'Pods&amp;#8217; which are almost exactly like &lt;a href="http://rubygems.org"&gt;gems&lt;/a&gt;. A podspec is a kind of build description, that specifies where the source is to be found, dependencies it has, and how it should be configured and compiled. The best part is that they&amp;#8217;re extremely legible.&lt;/p&gt;

	&lt;p&gt;This is a great improvement over the typical git submodule, or linked Xcode project for each dependency. To use CocoaPods, you specify your application&amp;#8217;s dependencies in a Podfile. This is typically a concise list of the pods required to build the application. CocoaPods generates a Pods project with a single target consisting of a single static library custom-built for your app to contain all the dependencies in one place. The Pods project that gets put into a workspace along with your project, so that everything plays nice with Xcode as both and &lt;span class="caps"&gt;IDE&lt;/span&gt; and as a build system. The Pods project doesn&amp;#8217;t get checked in to your repository because it can be completely regenerated from your Podfile.&lt;/p&gt;

 CocoaPods turns out to be a partial build system that takes some of the bite out of Xcode. With respect to dependencies, Xcode is now a mere &lt;span class="caps"&gt;IDE&lt;/span&gt; &amp;#8212; it&amp;#8217;s no longer the keeper of build configurations. But you still need a project to describe an build an application. I want to cut Xcode out of everything that&amp;#8217;s not building and day-to-day code writing. I want to write iOS apps and not check in Xcode project files.

	&lt;h2&gt;&lt;span class="caps"&gt;GYP&lt;/span&gt;&lt;/h2&gt;

	&lt;p&gt;&lt;a href="http://code.google.com/p/gyp/"&gt;GYP&lt;/a&gt; is a meta build specification that creates build specifications for real build systems. In simpler words, you use &lt;span class="caps"&gt;GYP&lt;/span&gt; to describe a build in a generic way in &lt;span class="caps"&gt;JSON&lt;/span&gt;, and &lt;span class="caps"&gt;GYP&lt;/span&gt; builds an Xcode project for you. I could probably extend CocoaPods to do this, and keep one format for specifying builds of dependencies &lt;em&gt;and&lt;/em&gt; targets. But &lt;span class="caps"&gt;GYP&lt;/span&gt; already exists. &lt;span class="caps"&gt;GYP&lt;/span&gt; was built and maintained by Google for the Chromium project.&lt;/p&gt;

	&lt;p&gt;Gathering tidbits from the web, here&amp;#8217;s what I&amp;#8217;ve been able to put together.&lt;/p&gt;

	&lt;p&gt;&lt;code&gt;pulse_poll.gyp&lt;/code&gt;&lt;/p&gt;

&lt;pre&gt;
{
  &amp;#39;targets&amp;#39;: [
    {
      &amp;#39;target_name&amp;#39;: &amp;#39;PulsePoll&amp;#39;,
      &amp;#39;type&amp;#39;: &amp;#39;executable&amp;#39;,
      &amp;#39;mac_bundle&amp;#39;: 1,
      &amp;#39;include_dirs&amp;#39; : [
        &amp;#39;substructure&amp;#39;,
      ],
      &amp;#39;sources&amp;#39;: [
        &amp;#39;src/substructure/main.m&amp;#39;,
        &amp;#39;src/substructure/PPAppDelegate.h&amp;#39;,
        &amp;#39;src/substructure/PPAppDelegate.m&amp;#39;,
        &amp;#39;src/substructure/PulsePoll-Info.plist&amp;#39;,
      ],
      &amp;#39;link_settings&amp;#39;: {
        &amp;#39;libraries&amp;#39;: [
          &amp;#39;UIKit.framework&amp;#39;,
          &amp;#39;Foundation.framework&amp;#39;,
          &amp;#39;CoreGraphics.framework&amp;#39;,
        ],
      },
      &amp;#39;xcode_settings&amp;#39; : {
        &amp;#39;INFOPLIST_FILE&amp;#39; : &amp;#39;src/substructure/PulsePoll-Info.plist&amp;#39;,
        &amp;#39;SDKROOT&amp;#39;: &amp;#39;iphoneos&amp;#39;,
        &amp;#39;TARGETED_DEVICE_FAMILY&amp;#39;: &amp;#39;1,2&amp;#39;,
    	&amp;#39;CODE_SIGN_IDENTITY&amp;#39;: &amp;#39;iPhone Developer&amp;#39;,
        &amp;#39;IPHONEOS_DEPLOYMENT_TARGET&amp;#39;: &amp;#39;5.0&amp;#39;,
        &amp;#39;ARCHS&amp;#39;: &amp;#39;$(ARCHS_UNIVERSAL_IPHONE_OS)&amp;#39;,
        &amp;#39;HEADER_SEARCH_PATHS&amp;#39;: &amp;#39;$(inherited)&amp;#39;,
        &amp;#39;CLANG_ENABLE_OBJC_ARC&amp;#39;: &amp;#39;YES&amp;#39;,
      },
    },
  ]
}
&lt;/pre&gt;

	&lt;p&gt;The four source files are the minimum requirements to build and launch a conventional iOS app. &lt;code&gt;main&lt;/code&gt; is the code entry point (your projects have one whether you&amp;#8217;re aware of it or not), and &lt;code&gt;HSAppDelegate&lt;/code&gt; fulfills a role familiar to any iOS developer. The &lt;code&gt;plist&lt;/code&gt; is a standard one that you can lift from the XCode app template, or any existing app. Xcode will not be happy without one, and you won&amp;#8217;t be able to have a valid executable bundle without one either.&lt;/p&gt;

	&lt;h2&gt;CocoaPods and Caveats&lt;/h2&gt;

	&lt;p&gt;To integrate with CocoaPods, I only had to make one otherwise unnecessary change, and that is to specify the deployment target in the project&amp;#8217;s Podfile. The reason appears to be that &lt;span class="caps"&gt;GYP&lt;/span&gt; does not set its one and only target as the default target. This apparently confuses CocoaPods into thinking that the deployment target is iOS 4.3, and will then complain loudly if you include any pods that don&amp;#8217;t work on that system.&lt;/p&gt;

	&lt;p&gt;There was trouble around the frameworks. &lt;a href="http://code.google.com/p/gyp/wiki/GypUserDocumentation"&gt;GYP&amp;#8217;s documentation&lt;/a&gt; suggests using &lt;code&gt;$(SDKROOT)&lt;/code&gt; as a prefix for importing libraries. But this left the project unable to run on the simulator, though it would run on devices. This is clearly due to settings &lt;code&gt;SDKROOT&lt;/code&gt; to &lt;code&gt;iphoneos&lt;/code&gt;, but I couldn&amp;#8217;t see how to avoid that. Including frameworks as listed above shows them in red when see them in the project, but it builds and runs in both the simulator and on devices.&lt;/p&gt;

	&lt;p&gt;&lt;span class="caps"&gt;GYP&lt;/span&gt; doesn&amp;#8217;t support generating groups of source files in Xcode projects. It imposes its own structure separating out source files from Framworkds, build files, and Products. &lt;/p&gt;

	&lt;h2&gt;Thoughts&lt;/h2&gt;

	&lt;p&gt;I think the purpose of a source repository is to represent the knowledge required to build a product. For a CocoaPod, its podpec together with its source code and documentation serves that purpose beautifully. For a while, I will try and use &lt;span class="caps"&gt;GYP&lt;/span&gt; to capture the same &lt;/p&gt;

	&lt;p&gt;I&amp;#8217;m a little concerned with pinning the build description of an application to a technology that only exists to serve the Chromium project and that I have little interest in modifying and maintaining. But in the mean time, I&amp;#8217;m satisfied with &lt;span class="caps"&gt;GYP&lt;/span&gt; because it&amp;#8217;s a build specification I can read. It also lets me continue using Xcode as an &lt;span class="caps"&gt;IDE&lt;/span&gt;. But seeing just &lt;a href="http://src.chromium.org/svn/trunk/src/build/common.gypi"&gt;how large&lt;/a&gt; &lt;span class="caps"&gt;GYP&lt;/span&gt; files can get for a complex project makes me not want to really recommend &lt;span class="caps"&gt;GYP&lt;/span&gt; for any serious work. &lt;span class="caps"&gt;GYP&lt;/span&gt; really seems to shine if you&amp;#8217;re building a truly cross-platform project (It can generate Visual Studio projects as well as Xcode, ninja, and probably others). &lt;/p&gt;

	&lt;p&gt;I would like to see CocoaPods, or a tool more closely aligned with CocoaPods, become capable of specifying Xcode projects and targets. The foundations are there in CocoaPods and &lt;a href="https://github.com/CocoaPods/Xcodeproj"&gt;Xcodeproj&lt;/a&gt;. I might try and work that out some time.&lt;/p&gt;

	&lt;p&gt;Useful links&lt;br /&gt;&lt;a href="http://code.google.com/p/gyp/wiki/GypLanguageSpecification"&gt;&lt;span class="caps"&gt;GYP&lt;/span&gt; Language Specification&lt;/a&gt;&lt;br /&gt;&lt;a href="http://code.google.com/p/gyp/wiki/GypUserDocumentation"&gt;&lt;span class="caps"&gt;GYP&lt;/span&gt; User Documentation&lt;/a&gt;&lt;br /&gt;&lt;a href="https://code.google.com/p/skia/source/browse/trunk/gyp/SimpleiOSApp.gyp?r=5702"&gt;The Skia project&amp;#8217;s &lt;span class="caps"&gt;GYP&lt;/span&gt; file for iOS&lt;/a&gt;&lt;br /&gt;&lt;a href="http://groups.google.com/group/gyp-developer/browse_thread/thread/f683ae11a54301b1/8be8243080675559?lnk=gst&amp;#38;q=iphone#8be8243080675559"&gt;A usful post on GYP&amp;#8217;s Google Group&lt;/a&gt;&lt;br /&gt;&lt;a href="http://src.chromium.org/svn/trunk/src/build/common.gypi"&gt;A big chunk of Chromium&amp;#8217;s GYP&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/FabianCanas?a=Yx8cnx0gNY8:vLtcSiqhfeU:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FabianCanas?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/FabianCanas?a=Yx8cnx0gNY8:vLtcSiqhfeU:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FabianCanas?i=Yx8cnx0gNY8:vLtcSiqhfeU:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/FabianCanas/~4/Yx8cnx0gNY8" height="1" width="1"/&gt;</content><feedburner:origLink>http://www.fabiancanas.com/entry/cocoapods-and-gyp</feedburner:origLink></entry><entry><title type="text">Swirltastic</title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/FabianCanas/~3/6ETV45okz7M/new-app-swirltastic" /><updated>2012-08-27T00:08:44-07:00</updated><id>http://www.fabiancanas.com/entry/new-app-swirltastic</id><content type="html">&lt;p&gt;I just published a new app, &lt;a href='http://click.linksynergy.com/fs-bin/stat?id=OutMLIuPRIc&amp;offerid=146261&amp;type=3&amp;subid=0&amp;tmpid=1826&amp;RD_PARM1=http%253A%252F%252Fitunes.apple.com%252Fus%252Fapp%252Fswirltastic%252Fid552815931%253Fmt%253D8%2526uo%253D4%2526partnerId%253D30'&gt;Swirltastic&lt;/a&gt;, in the iOS app store. Swirltastic is both a toy and an art project. It’s a big mess of colorful swirls that respond to your touches.&lt;/p&gt;

	&lt;p&gt;My hope is to continue releasing updates that introduce new and interesting ways of interacting with the swirls. &lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/FabianCanas?a=6ETV45okz7M:F_dlFtF2KAM:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FabianCanas?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/FabianCanas?a=6ETV45okz7M:F_dlFtF2KAM:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/FabianCanas?i=6ETV45okz7M:F_dlFtF2KAM:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/FabianCanas/~4/6ETV45okz7M" height="1" width="1"/&gt;</content><feedburner:origLink>http://www.fabiancanas.com/entry/new-app-swirltastic</feedburner:origLink></entry></feed>
