programing tip

IB Designable의 인스턴스를 렌더링하지 못했습니다.

itbloger 2020. 12. 11. 07:56
반응형

IB Designable의 인스턴스를 렌더링하지 못했습니다.


Objective-C 및 Swift 혼합 동적 프레임 워크가 있습니다. 그리고 혼합 프레임 워크는 두 개의 순수한 Objective-C 동적 프레임 워크와 연결되었습니다.

혼합 프레임 워크의 클래스를 IB Designable로 표시하고 해당 클래스를 스토리 보드 나 펜촉에서 사용하려고 할 때 Xcode는 항상 해당 인스턴스가 렌더링에 실패했다고 말합니다.

그리고 오류 메시지가 있습니다.

IB Designables : WZUITokenField의 인스턴스를 렌더링하지 못했습니다. dlopen (WZUIKit.framework, 1) : 라이브러리가로드되지 않음 : /Library/Frameworks/WZFoundation.framework/WZFoundation 참조 위치 : WZUIKit.framework 이유 : 이미지를 찾을 수 없음

IB Designables : 자동 레이아웃 상태 업데이트 실패 : dlopen (WZUIKit.framework, 1) : 라이브러리가로드되지 않음 : @ rpath / WZFoundation.framework / WZFoundation 참조 위치 : WZUIKit.framework 이유 : 이미지를 찾을 수 없음

WZUIKit 프레임 워크는 Objective-C 및 Swift 혼합 프레임 워크이며 WZFoundation은 순수한 Objective-C입니다.

또한 이러한 모든 sutff는 장치 또는 시뮬레이터에서 작동합니다.


마지막으로 $(CONFIGURATION_BUILD_DIR)대상의 빌드 설정 Runpath Search Paths필드 를 추가하여이 문제를 해결했습니다 .

또한 Xcode로 수행해야 할 몇 가지 추가 단계가 있습니다.

  1. 프로젝트에 대한 Xcode 파생 데이터를 지 웁니다. 그들은~/Library/Developer/Xcode/DerivedData
  2. 눌러서 현재 빌드를 청소하십시오. K
  3. 프로젝트 구축
  4. 스토리 보드에서 Editor메뉴 로 이동하여 수행하십시오 Refresh All Views. 빌드가 완료되고 오류가 사라질 때까지 기다립니다.

@Mojtaba에 대한 크레딧


Mac 앱을 빌드하는 데 동일한 문제가있는 경우에 추가하면이 문제 @loader_path/../FrameworksRunpath Search Paths해결되었습니다.


나를 위해 xcode를 닫고 다시 열 수 있습니다. 이후 오류가 없습니다. 감사.


흥미 롭군.

첫째, WeZZard의 대답은 올바른 방향으로 나아갈 수 있었지만 정확히 내 솔루션은 아니 었습니다.

내 iOS 프로젝트에서 무언가가 Runpath Search Paths내 대상 필드를 재정의했습니다 . 다음과 같이 보였습니다.

LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";

나는 추가하는 그의 해결책을 시도 $(CONFIGURATION_BUILD_DIR)했지만 그것은 나를 위해 작동하지 않았습니다. 작동하지 않았기 때문에 습관적으로 구성 항목을 삭제했습니다 (프로젝트 기본값으로 돌아 가기). 내가했을 때 다음으로 재설정되었습니다.

LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'

xcconfig 파일을 파헤쳐 보면 Cocoapods에서 나온 것처럼 보입니다.

@loader_pathis key는 Alex와 동일 해 보이지만 iOS에서는 Mac OS X와는 약간 다른 경로입니다.


IBDesignables가 포함 된 프레임 워크에서이 오류가 발생했습니다.

내 프레임 워크 대상에 설정 을 추가 $(FRAMEWORK_SEARCH_PATHS)해야했습니다 LD_RUNPATH_SEARCH_PATHS.

실행 경로 설정을 업데이트하고, 스토리 보드에서보기를 빌드하고 새로 고친 후 오류가 사라졌습니다. 빌드 폴더를 정리할 필요조차 없었습니다.

여기에 이미지 설명 입력


Xcode 6.4에서 동일한 문제가 발생했습니다. 스토리 보드에 테스트 대상 멤버십을 추가하면 이러한 오류가 해결되었습니다.

또한 내 테스트 대상은 원래 대상이 아닌 테스트 대상에 @loader_path/Frameworks설정되었습니다 Runpath Search Paths.

여기에 이미지 설명 입력


제 경우에 또 다른 이유를 알아 냈습니다.

'Editor-> Debug Selected Views'를 사용했을 때 CoreGraphics를 사용하여 이미지를 만들고 버튼의 배경 이미지로 사용했기 때문에 충돌이 발생하는 것을 보았습니다.

class func imageWithColor(color: UIColor, size: CGSize) -> UIImage {

    let rect = CGRectMake(0.0, 0.0, size.width, size.height);
    UIGraphicsBeginImageContextWithOptions(rect.size, false, 0.0);
    let context = UIGraphicsGetCurrentContext();    // It's alraedy nil here :(

    CGContextSetFillColorWithColor(context, color.CGColor);
    CGContextFillRect(context, rect);

    let image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    return image;

}

그 이유는 단순히 크기가 (0.0, 0.0)이기 때문입니다. 왜 그런 겁니까? 난 전화하고있어

super.setBackgroundImage(UIImage.imageWithColor(bgColor, size: self.bounds.size), forState: .Normal)

그러나 IB에서 self.bounds.size는이 시점에서 여전히 0입니다! 그래서 한 줄을 변경했습니다.

let rect = CGRectMake(0.0, 0.0, max(size.width, 1.0), max(size.height, 1.0));

그리고 이제 작동합니다 :)

Apple은 IB와 관련하여해야 할 일과하지 말아야 할 일 목록을 제공해야합니다.


I also experienced this on a Mac project and Xcode 7.3.1. In my case, the framework referenced in the Failed to Render error message was not related to drawing at all.

Simply going to the target's General/Linked Frameworks and Libraries tab and changing the offending framework's Status from Required to Optional allowed the IBDesignables to update and draw properly in IB.

선택적 상태


In my case, I was doing the next in the initWithFrame/initWithCoder methods to create the view:

className = NSStringFromClass([self class]);
self.view = [[[NSBundle mainBundle] loadNibNamed:className owner:self options:nil] firstObject];

But It looks like I was not supposed to use the Main Bundle but the bundle of the class. So I replaced that code for the following and it worked:

bundle = [NSBundle bundleForClass:[self class]];
className = NSStringFromClass([self class]);
self.view = [[bundle loadNibNamed:className owner:self options:nil] firstObject];

I thought maybe this might help somebody.


I had this problem in an OS X project.

In my case, the problem was an old project (NMSSH) containing a framework target with bad build settings. Specifically:

  • INSTALL_PATH was set to @executable_path/../Frameworks, but the correct setting is /Library/Frameworks
  • SKIP_INSTALL was not set and defaults to NO, but the correct setting is YES
  • DYLIB_INSTALL_NAME_BASE was not set, but the correct setting is @rpath

Note that all of the correct settings are what you get automatically for a newly-created framework target.

After changing the settings to the correct values, Xcode was able to load my @IBDesignable view in the storyboard.


Follow the below steps:

  1. If there are any conflicts in the storyboard, resolve them correctly, check if the xml is correctly validated.(These is main step.)
  2. Clean the project.
  3. Delete the derived data folder.
  4. Quit Xcode and restart it again. (I had to do this twice.)

I had a similar error which was caused by my Framework's views not having public initialisers:

public override init(frame: CGRect) {
    super.init(frame:frame)
    commonInit()
}

required public init(coder: NSCoder) {
    super.init(coder: coder)
    commonInit()
}

Clear Derived Data . Quit Xcode, Reopen again.


제 경우에는 개인 포드 내부에 있습니다. Xcode 버전 10.3 (10G8)렌더링 오류 발생

colution 내 경우는 매우 간단합니다 - 그냥 추가하는 것을 잊지 public 에-사이의@IBInspectable var

올바른 변형 :

import UIKit

@IBDesignable public class BorderedView: UIView {
    @IBInspectable public var borderColor: UIColor? = UIColor.white {
        didSet {
            if let actualColor = borderColor {
                layer.borderColor = actualColor.cgColor
            } else {
                layer.borderColor = UIColor.white.cgColor
            }

            setNeedsDisplay()
        }
    }
    @IBInspectable public var borderWidth: CGFloat = 1 {
        didSet {
            layer.borderWidth = borderWidth
            setNeedsDisplay()
        }
    }
}

추신 : 편집기-> 선택한 뷰 디버그 내 경우에는 아무것도하지 않았습니다.

PS2 : 내 개인 포드의 종속성에서 AlignedCollectionViewFlowLayout 포드 이며이 문제와 관련이 없습니다.

PS3 : 여전히 여기에 문제

참고 URL : https://stackoverflow.com/questions/26799054/failed-to-render-instance-of-ib-designables

반응형