krzysztofzablocki / Inject

Hot Reloading for Swift applications!
MIT License
2.1k stars 114 forks source link

unable to use it in all files with @_exported import Inject #77

Closed statusunknown418 closed 1 year ago

statusunknown418 commented 1 year ago

The Readme doesn't really explain how to setup Inject to watch all files in a project.

@_exported import Inject 

Where should this be used? it says on targets but I'm not sure if under .xcodeproj or where. Any help is appreciated, SwiftUI beginner here.

statusunknown418 commented 1 year ago

update: I got Injection to work by adding

import Inject

struct View {
   @ObserveInjection var inject

   ...
   .enableInjection()
}

however I'm still unable to make it work globally with the @_exported which is what I actually want

johnno1962 commented 1 year ago

Hi, @_exported import Inject is just to make @ObserveInjection and .enableInjection() symbols available globally to your Swift code. Unfortunately, you have to add these to every View struct in your application that you want to be able to inject either manually or using the Prepare Project feature of the Injection.app.

statusunknown418 commented 1 year ago

@johnno1962 thanks I understand, and in any case those dependancies and code will be stripped out in production builds right?

johnno1962 commented 1 year ago

Yes, the code isn't stripped out but it optimises down to a no-operation for a Release build.