appsquickly / typhoon

Powerful dependency injection for Objective-C ✨✨ (https://PILGRIM.PH is the pure Swift successor to Typhoon!!)✨✨
https://pilgrim.ph
Apache License 2.0
2.7k stars 269 forks source link

Crash on Swift and Objective-C assemblies collaboration #537

Closed Brain89 closed 7 years ago

Brain89 commented 7 years ago

Hello. I have an issue with v4-alpha version. If I try to inject an object from Objective-C assembly inside Swift assembly I receive EXC_BAD_ACCESS.

2016-11-21 15 14 59

But everything works fine when two Objective-C assemblies are collaborating.

Here is an example project. Have a look at ASObjectiveCAssembly and SwiftAssembly. TyphoonV4Test.zip

alexgarbarev commented 7 years ago

Looking..

alexgarbarev commented 7 years ago

To get that working, you should make your property declaration as:

dynamic var objectiveCAssembly: ASObjectiveCAssembly!

and objective-c method return type change to id:

@interface ASObjectiveCAssembly : TyphoonAssembly

- (id)objectiveCDefinition;

@end
alexgarbarev commented 7 years ago

Just checked and confirmed. Sample project doesn't work with stable Typhoon (3.5.1) as well.

Brain89 commented 7 years ago

It is very strange. I have at least one project in production with the similar code and Typhoon 3.5.x and everything works fine.

Brain89 commented 7 years ago

Your solution could be simpler: it works if I just add dynamic.