3

After migrating to Cocoapods 1.0 none of my XIBs or Storyboards that uses custom IBDesignable renders correctly on dynamic framework projects. It fails with errors like this:

file:///Users/xxxxx/workspace/FooFramework/FooFramework/View.xib: error: IB Designables: Failed to update auto layout status: dlopen(FooFramework.framework, 1): Library not loaded: @rpath/Alamofire.framework/Alamofire
  Referenced from: FooFramework.framework
  Reason: image not found

file:///Users/xxxxx/workspace/FooFramework/FooFramework/View.xib: error: IB Designables: Failed to render instance of CustomView: dlopen(FooFramework.framework, 1): Library not loaded: @rpath/Alamofire.framework/Alamofire
  Referenced from: FooFramework.framework
  Reason: image not found

Steps to reproduce:

  1. Create a new iOS Framework project.
  2. Create and add any dependency to the Podfile file. For example:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

target 'FooFramework' do
pod 'Alamofire'
end
  1. Execute pod install and open .xcworkspace file.
  2. Create a custom IBDesignable UIView subclass. For example:
import UIKit

@IBDesignable class CustomView: UIView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        layer.cornerRadius = 10
    }

    required init?(coder aDecoder: NSCoder)
    {
        super.init(coder: aDecoder)
        layer.cornerRadius = 10
    }
}
  1. Create a new XIB or Storyboard and add the custom view.

At this point XCode will re-compile the code and will be unable to render the custom view. Giving the errors mentioned above.


However, the project compiles correctly, and the XIB created are successfully shown in simulator when executing. It only fails on render time on Interface Builder.

The same procedure using Cocoapods 0.38 or a executable project works as expected, no errors are obtained and the custom view is rendered correctly.

Am I missing any configuration parameter in the Podfile? Is it a Cocoapods bug? Is there any workaround?


Update:

Tried using different Runpath Search Paths and Installation Directory like described here and here with no luck.

Found a workaround using Cocoapods 0.39, that still works with no issue:

pod _0.39.0_ install
Community
  • 1
  • 1
redent84
  • 18,901
  • 4
  • 62
  • 85

1 Answers1

3

It seems a bug in Cocoapods due to default scoping not being supported by Interface Builder and Playgrounds.

Workarounds found until it's fixed:

  1. Fall back to 0.39 using pod _0.39.0_ install.
  2. Add the following code to the end of your Podfile:
post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['CONFIGURATION_BUILD_DIR'] = '$PODS_CONFIGURATION_BUILD_DIR'
        end
    end
end
redent84
  • 18,901
  • 4
  • 62
  • 85
  • I'm running CocoaPods version 1.0.1 and option #2 worked for me, considering [Playgrounds/IBDesignables can't use pod dependencies](https://github.com/CocoaPods/CocoaPods/issues/5334). Thank you! – Davey Johnson Jul 21 '16 at 23:18