Search code examples
cocoapodstravis-citvosxctool

Can't build tvOS app with Cocoapod dependencies with xctool


I have a project that has a small number of dependencies managed with Cocoapods. I can build it fine from Xcode but when I try to build it using xctool, or travisci, I get an error:

  xcodebuild clean VideoStationViewer
  Pods / SwiftyJSON (Debug)
     ✗ Check dependencies (37 ms)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Check dependencies
    target 'SwiftyJSON' has bitcode disabled (ENABLE_BITCODE = NO), but it is required for the 'appletvos' platform
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  1 errored, 0 warning (38 ms)

  Pods / Alamofire (Debug)
    ✗ Check dependencies (38 ms)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  Check dependencies
    target 'Alamofire' has bitcode disabled (ENABLE_BITCODE = NO), but it is required for the 'appletvos' platform
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  1 errored, 0 warning (38 ms)

  Pods / OHHTTPStubs (Debug)
    ✗ Check dependencies (40 ms)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  Check dependencies
    target 'OHHTTPStubs' has bitcode disabled (ENABLE_BITCODE = NO), but it is required for the 'appletvos' platform
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  1 errored, 0 warning (47 ms)

I'm guessing that xctool is using different parameters to build than Xcode does but not sure what is different or how to tell xctool to use those settings and then how to configure Travisci to use it too.


Solution

  • @Campbell_Souped’s answer works great for tvOS-only projects, but if you try to also build for OS X, you’ll get an error that Bitcode is not supported. This version checks the platform before enabling Bitcode:

    post_install do |installer|
      installer.pods_project.targets.each do |target|
        if target.platform_name == :tvos || target.platform_name == :watchos then
          target.build_configurations.each do |config|
              config.build_settings['ENABLE_BITCODE'] = 'YES'
          end
        end
      end
    end