Carthage/Carthage

IBDesignables and IBInspectables

raulriera opened this issue · 19 comments

Might not be an issue of Carthage per say. But I have ran into problems using IB Designables and IB Inspectables on frameworks using Carthage. Have you encountered this before?

Two examples are MengTo/Spring#11 (comment) and https://github.com/raulriera/TextFieldEffects both are affected by this

robb commented

You happen to have a build log?

From carthage update? nothing stands out

*** Building scheme "Alamofire iOS" in Alamofire.xcworkspace
*** Building scheme "Alamofire OSX" in Alamofire.xcworkspace
*** Building scheme "KeychainAccess-iOS" in KeychainAccess.xcworkspace
*** Building scheme "KeychainAccess-Mac" in KeychainAccess.xcworkspace
*** Building scheme "OAuthSwift" in OAuthSwift.xcodeproj
*** Building scheme "Spring" in SpringApp.xcodeproj
*** Building scheme "SwiftyJSON" in SwiftyJSON.xcworkspace
*** Building scheme "TextFieldEffects" in TextFieldEffects.xcodeproj

Are the logs somewhere else?

robb commented

Hmm, maybe running the latest carthage with --verbose?

Running version 0.6.0

Rauls-MacBook-Pro:Swish raulriera$ carthage update --verbose
*** Fetching OAuthSwift
*** Fetching Alamofire
*** Fetching SwiftyJSON
*** Fetching TextFieldEffects
*** Fetching KeychainAccess
*** Fetching Spring
*** Checking out KeychainAccess at "v1.1.2"
*** Checking out OAuthSwift at "v0.3.1"
*** Checking out Alamofire at "1.1.4"
*** Checking out TextFieldEffects at "0.2.7"
*** Checking out Spring at "1.0.1"
*** Checking out SwiftyJSON at "2.1.3"
*** Building scheme "Alamofire iOS" in Alamofire.xcworkspace
Build settings from command line:
    SDKROOT = iphonesimulator8.2

=== BUILD TARGET Alamofire iOS OF PROJECT Alamofire WITH CONFIGURATION Release ===

Check dependencies

Write auxiliary files
write-file /Users/raulriera/Library/Developer/Xcode/DerivedData/Alamofire-amhdqsdrikewnseofmecbiymyieb/Build/Intermediates/Alamofire.build/all-product-headers.yaml

=== BUILD TARGET Alamofire iOS Tests OF PROJECT Alamofire WITH CONFIGURATION Release ===

Check dependencies

** BUILD SUCCEEDED **

Build settings from command line:
    SDKROOT = iphoneos8.2

=== BUILD TARGET Alamofire iOS OF PROJECT Alamofire WITH CONFIGURATION Release ===

Check dependencies

Write auxiliary files
write-file /Users/raulriera/Library/Developer/Xcode/DerivedData/Alamofire-amhdqsdrikewnseofmecbiymyieb/Build/Intermediates/Alamofire.build/all-product-headers.yaml

=== BUILD TARGET Alamofire iOS Tests OF PROJECT Alamofire WITH CONFIGURATION Release ===

Check dependencies

** BUILD SUCCEEDED **

*** Building scheme "Alamofire OSX" in Alamofire.xcworkspace
Build settings from command line:
    SDKROOT = macosx10.10

=== BUILD TARGET Alamofire OSX OF PROJECT Alamofire WITH CONFIGURATION Release ===

Check dependencies

Write auxiliary files
write-file /Users/raulriera/Library/Developer/Xcode/DerivedData/Alamofire-amhdqsdrikewnseofmecbiymyieb/Build/Intermediates/Alamofire.build/all-product-headers.yaml

=== BUILD TARGET Alamofire OSX Tests OF PROJECT Alamofire WITH CONFIGURATION Release ===

Check dependencies

** BUILD SUCCEEDED **

*** Building scheme "KeychainAccess-iOS" in KeychainAccess.xcworkspace
Build settings from command line:
    SDKROOT = iphonesimulator8.2

=== BUILD TARGET KeychainAccess-iOS OF PROJECT KeychainAccess WITH CONFIGURATION Release ===

Check dependencies

Write auxiliary files
write-file /Users/raulriera/Library/Developer/Xcode/DerivedData/KeychainAccess-cppqcrfovwbmstejuakttxewmqiu/Build/Intermediates/KeychainAccess.build/all-product-headers.yaml

=== BUILD TARGET KeychainAccess-iOSTests OF PROJECT KeychainAccess WITH CONFIGURATION Release ===

Check dependencies

** BUILD SUCCEEDED **

Build settings from command line:
    SDKROOT = iphoneos8.2

=== BUILD TARGET KeychainAccess-iOS OF PROJECT KeychainAccess WITH CONFIGURATION Release ===

Check dependencies

Write auxiliary files
write-file /Users/raulriera/Library/Developer/Xcode/DerivedData/KeychainAccess-cppqcrfovwbmstejuakttxewmqiu/Build/Intermediates/KeychainAccess.build/all-product-headers.yaml

=== BUILD TARGET KeychainAccess-iOSTests OF PROJECT KeychainAccess WITH CONFIGURATION Release ===

Check dependencies

** BUILD SUCCEEDED **

*** Building scheme "KeychainAccess-Mac" in KeychainAccess.xcworkspace
Build settings from command line:
    SDKROOT = macosx10.10

=== BUILD TARGET KeychainAccess-Mac OF PROJECT KeychainAccess WITH CONFIGURATION Release ===

Check dependencies

Write auxiliary files
write-file /Users/raulriera/Library/Developer/Xcode/DerivedData/KeychainAccess-cppqcrfovwbmstejuakttxewmqiu/Build/Intermediates/KeychainAccess.build/all-product-headers.yaml

=== BUILD TARGET KeychainAccess-MacTests OF PROJECT KeychainAccess WITH CONFIGURATION Release ===

Check dependencies

** BUILD SUCCEEDED **

*** Building scheme "OAuthSwift" in OAuthSwift.xcodeproj
Build settings from command line:
    SDKROOT = iphonesimulator8.2

=== BUILD TARGET OAuthSwift OF PROJECT OAuthSwift WITH CONFIGURATION Release ===

Check dependencies

Write auxiliary files
write-file /Users/raulriera/Library/Developer/Xcode/DerivedData/OAuthSwift-fkzcstfheshntzfeppqgdcufkpva/Build/Intermediates/OAuthSwift.build/all-product-headers.yaml

** BUILD SUCCEEDED **

Build settings from command line:
    SDKROOT = iphoneos8.2

=== BUILD TARGET OAuthSwift OF PROJECT OAuthSwift WITH CONFIGURATION Release ===

Check dependencies

Write auxiliary files
write-file /Users/raulriera/Library/Developer/Xcode/DerivedData/OAuthSwift-fkzcstfheshntzfeppqgdcufkpva/Build/Intermediates/OAuthSwift.build/all-product-headers.yaml

** BUILD SUCCEEDED **

*** Building scheme "Spring" in SpringApp.xcodeproj
Build settings from command line:
    SDKROOT = iphonesimulator8.2

=== BUILD TARGET Spring OF PROJECT SpringApp WITH CONFIGURATION Release ===

Check dependencies

Write auxiliary files
write-file /Users/raulriera/Library/Developer/Xcode/DerivedData/SpringApp-ecjveguuknkpdmfmolgqugtwfecf/Build/Intermediates/SpringApp.build/all-product-headers.yaml

** BUILD SUCCEEDED **

Build settings from command line:
    SDKROOT = iphoneos8.2

=== BUILD TARGET Spring OF PROJECT SpringApp WITH CONFIGURATION Release ===

Check dependencies

Write auxiliary files
write-file /Users/raulriera/Library/Developer/Xcode/DerivedData/SpringApp-ecjveguuknkpdmfmolgqugtwfecf/Build/Intermediates/SpringApp.build/all-product-headers.yaml

** BUILD SUCCEEDED **

*** Building scheme "SwiftyJSON" in SwiftyJSON.xcworkspace
Build settings from command line:
    SDKROOT = iphonesimulator8.2

=== BUILD TARGET SwiftyJSON OF PROJECT SwiftyJSON WITH CONFIGURATION Release ===

Check dependencies

Write auxiliary files
write-file /Users/raulriera/Library/Developer/Xcode/DerivedData/SwiftyJSON-elstjcxdskukxabbgfdtjqqeyymk/Build/Intermediates/SwiftyJSON.build/all-product-headers.yaml

=== BUILD TARGET SwiftyJSONTests OF PROJECT SwiftyJSON WITH CONFIGURATION Release ===

Check dependencies

** BUILD SUCCEEDED **

Build settings from command line:
    SDKROOT = iphoneos8.2

=== BUILD TARGET SwiftyJSON OF PROJECT SwiftyJSON WITH CONFIGURATION Release ===

Check dependencies

Write auxiliary files
write-file /Users/raulriera/Library/Developer/Xcode/DerivedData/SwiftyJSON-elstjcxdskukxabbgfdtjqqeyymk/Build/Intermediates/SwiftyJSON.build/all-product-headers.yaml

=== BUILD TARGET SwiftyJSONTests OF PROJECT SwiftyJSON WITH CONFIGURATION Release ===

Check dependencies

** BUILD SUCCEEDED **

*** Building scheme "TextFieldEffects" in TextFieldEffects.xcodeproj
Build settings from command line:
    SDKROOT = iphonesimulator8.2

=== BUILD TARGET TextFieldEffects OF PROJECT TextFieldEffects WITH CONFIGURATION Release ===

Check dependencies

Write auxiliary files
write-file /Users/raulriera/Library/Developer/Xcode/DerivedData/TextFieldEffects-btvosowgienyuuevjqlkbsxsfnag/Build/Intermediates/TextFieldEffects.build/all-product-headers.yaml

** BUILD SUCCEEDED **

Build settings from command line:
    SDKROOT = iphoneos8.2

=== BUILD TARGET TextFieldEffects OF PROJECT TextFieldEffects WITH CONFIGURATION Release ===

Check dependencies

Write auxiliary files
write-file /Users/raulriera/Library/Developer/Xcode/DerivedData/TextFieldEffects-btvosowgienyuuevjqlkbsxsfnag/Build/Intermediates/TextFieldEffects.build/all-product-headers.yaml

** BUILD SUCCEEDED **
robb commented

Hmm, seems to build correctly. If you build the framework without Carthage and integrate it, do your custom views show up correctly in Interface Builder?

Hmmm, building the project and the adding the resulting framework from the derived data folder has the same result (can't be used in Storyboards)... Maybe I am doing something wrong here with these frameworks

robb commented

I'm tentatively closing this one then, since it seems to be either a configuration issue or an issue with Xcode. Feel free to reopen this if you have any new insights ✌️

Apparently this is a limitation in frameworks? when they are compiled all the IBDesignable and IBInspectable information is lost.

Have you guys ever created a reusable .framework file that supports them?

I had the same issue. It looks a limitation of a built framework. Check the header file (TargetName-Swift.h) in the built framework folder. It has no information for IBDesignable and IBInspectable though IBOutlet can be marked to properties in the header file. For now, the framework project must be added to your product project to enable IBDesignable and IBInspectable, or just use User Defined Runtime Attributes instead. I hope a future update of Xcode solve the issue.

Still no good on Xcode 7 Beta 6

Has anyone else filed an issue with Apple yet?

https://openradar.appspot.com/23114017

I did, it was marked as duplicate a loooong time ago

The issue was reported 16 months ago and there is still no ideal solution.

I have a workaround for this problem and I posted it onto stackoverflow: http://stackoverflow.com/questions/29933691/ibdesignable-from-external-framework/37631860#37631860 The basic idea is to create a sub class for the view in the destination app:

@IBDesignable
class MyCustomView: CustomView {

    @IBInspectable override var bgColor: NSColor {
        get {
            return super.bgColor
        }
        set {
            super.bgColor = newValue
        }
    }
}

Please read here for more details: http://stackoverflow.com/questions/29933691/ibdesignable-from-external-framework/37631860#37631860

If you like it please vote up. 👍

I found a way to have designables work with Cocoa Touch frameworks. You can supply a source file where designable attributes are provided on categories, and which clients can then use when compiling their project.

For full details, please read http://stackoverflow.com/a/39999914/760435

Forgive me commenting after closed, but I want to add a simple conclusion to this issue. It's sometimes hard to read all comments in SO for non-native English reader.

For library author, this solves the issue.
expose-ibbrabra

Xcode 8 and Swift 3, 1 year later, still no solution ???

Still no solution to this issue ?

Bump. Any word?

mdiep commented

This is an Apple/Xcode limitation. It’s not something that Carthage can fix.