GRMustache.swift icon indicating copy to clipboard operation
GRMustache.swift copied to clipboard

Boxed NSObjects fail for Cocoapods installation

Open kylealanhale opened this issue 9 years ago • 7 comments

When installing the framework via Cocoapods, NSObject subclasses aren't properly boxed, due to the compiler conditional in Box.swift.

Here's a temporary workaround hook for a project's Podfile:

post_install do |installer|
    installer.pods_project.targets.each do |target|
        if target.name == "GRMustache.swift"
            target.build_configurations.each do |config|
                config.build_settings['OTHER_SWIFT_FLAGS'] ||= ['$(inherited)', '-DOBJC']
            end
        end
    end
end

kylealanhale avatar Apr 05 '16 02:04 kylealanhale

@kylealanhale Thank you for the notice, let me have a look.

groue avatar Apr 05 '16 03:04 groue

Damned, I forgot this issue for the 2.0.0 release.

groue avatar Oct 23 '16 12:10 groue

@kylealanhale, @AMTourky Do you know what is needed in the podspec for the OBJC swift flag to be automatically set?

groue avatar Oct 23 '16 12:10 groue

Currently having this issue... Thought I'd have to manually override for boxed items! Any update on this?

sahandnayebaziz avatar May 15 '18 18:05 sahandnayebaziz

@groue @sahandnayebaziz It's been a while, but I'm not sure that it was a problem with the podspec; if so, maybe the modification I made to my podfile in the original report will be helpful. But if I'm remembering correctly, it would be better to remove the OBJC check and handle that scenario differently. (Also, it looks like the code in question was moved during the 2.0.0 refactor; it's now here.)

kylealanhale avatar May 29 '18 23:05 kylealanhale

I've lost some hours debugging this when switching from the ObjC version GRMustache to GRMustache.swift for rendering of my NSObject, so I propose at least adding a note to the README with https://github.com/groue/GRMustache.swift/pull/71.

herrernst avatar Jan 30 '20 10:01 herrernst

Same problem also happens when using as Swift package, probably not fixable because in a Swift package it's not possible to have Obj-C source files.

But maybe GRMustacheKeyAccess could be rewritten in Swift now? At least the problematic example in the implementation note from here now works in Swift: https://github.com/groue/GRMustache.swift/blob/7befd1a197335af6d39bffd5662a520d7414d441/ObjC/GRMustacheKeyAccess.h#L25-L51

Screen Shot 2020-02-07 at 13 54 42

Unfortunately I'm not able to do it ATM.

herrernst avatar Feb 07 '20 12:02 herrernst