groue / GRMustache.swift

Flexible Mustache templates for Swift
http://mustache.github.com/
MIT License
597 stars 155 forks source link

Boxed NSObjects fail for Cocoapods installation #28

Open kylealanhale opened 8 years ago

kylealanhale commented 8 years ago

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
groue commented 8 years ago

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

groue commented 7 years ago

Damned, I forgot this issue for the 2.0.0 release.

groue commented 7 years ago

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

sahandnayebaziz commented 6 years ago

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

kylealanhale commented 6 years ago

@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.)

herrernst commented 4 years ago

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 commented 4 years ago

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.