interface builder - How do I use IBDesignable/IBInspectable with CocoaPods in an Objective-C only project -


my project obj-c only. via cocoapods, tried installing an obj-c library takes advantage of ibdesignable , ibinspectable. if add project library , run 'pod install' 2 errors when building/running:

error: ib designables: failed update auto layout status: failed load designables path (null) error: ib designables: failed render instance of pkcircleprogressview: failed load designables path (null) 

ok, apparently take advantage of ibdesignable/ibinspectable, code needs in framework, not static library. seems need add podfile:

use_frameworks! 

when that, i'm able see in interface builder, when build/run, can't find afnetworking.h. don't think error specific afnetworking, it's first pod in podfile.

if using swift, seems answer need add libraries podfile swift/obj-c bridging header.

even though i'm not using swift, still need create bridging header?

here's podfile (without downloadbutton pod, , without use_frameworks!):

platform :ios, '8.0' pod 'afnetworking' pod 'fmdb' pod 'hkcircularprogressview' #pod 'taplytics' pod 'papreferences' pod 'htmllabel' pod 'idmphotobrowser' pod 'mbprogresshud'  link_with 'langham', 'leela', 'las alcobas', 'siam', 'aka bh', 'ritz montreal', 'fullerton', 'fullerton bay'  # fix broken copy-resources phase per https://github.com/cocoapods/cocoapods/issues/1546 post_install |installer|     installer.pods_project.targets.each |target|         scriptbasename = "\"pods/target support files/#{target.name}/#{target.name}-resources\""         sh = <<eot         if [ -f #{scriptbasename}.sh ];             if [ ! -f #{scriptbasename}.sh.bak ];                 cp #{scriptbasename}.sh #{scriptbasename}.sh.bak;             fi;             sed '/wrapper_extension/,/fi\\n/d' #{scriptbasename}.sh > #{scriptbasename}.sh.temp;             sed '/*.xcassets)/,/;;/d' #{scriptbasename}.sh.temp > #{scriptbasename}.sh;             rm #{scriptbasename}.sh.temp;         fi; eot         `#{sh}`     end end 

correction

ibinspectable , ib_designable not swift related. can used in either swift or objective-c. it's matter of ios version, , of setting module in ib.

real life example

ios 7 not support ibinspectable, use .7 class both controls. if project targets ios 8+, should use tgpdiscreteslider & tgpcamellabels instead

create base class ios 7 (prior ibinspectable)

@interface tgpcamellabels7 : uicontrol...  @property (nonatomic, assign) cgfloat ticksdistance; @property (nonatomic, assign) nsuinteger value; // ... 

create child class ios 8

@interface tgpcamellabels : tgpcamellabels7  @property (nonatomic) ibinspectable cgfloat ticksdistance; @property (nonatomic) ibinspectable nsuinteger value; // ... 

in manner, pod can used in either mode. has been solved, in details, on tgpcontrols pod.

download project, find 2 examples xcode projects, 1 swift, 1 objective-c.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -