krzysztofzablocki / Inject

Hot Reloading for Swift applications!
MIT License
2.36k stars 118 forks source link

TCA support? #86

Closed tvidenov closed 9 months ago

tvidenov commented 10 months ago

Can we use it with the latest version of TCA (1.6.0) and how? I saw there is a little mentioned in the readme about the fork of The Browser Company, but it is very hard to navigate.

johnno1962 commented 10 months ago

Since the introduction of ReducerProtocol you can use Inject with TCA without support code. It's important to add the "Other Linker Flags": -Xlinker -interposable though.

tvidenov commented 10 months ago

Ok, so I obviously do something wrong but can't figure it out yet:

`πŸ’‰ Compiling /.../Settings.swift

πŸ’‰ Loading .dylib ... πŸ’‰ ⚠️ dlopen() error: dlopen(/Users/.../Library/Developer/CoreSimulator/Devices/DA06D4B2-5CE7-4262-BA0D-CDD77CFA337F/data/Containers/Data/Application/EA7F2C38-392A-474E-800B-6CE929C7C732/tmp/eval101.dylib, 0x0002): Library not loaded: @rpath/libswift_Concurrency.dylib Referenced from: /Users/.../Library/Developer/CoreSimulator/Devices/DA06D4B2-5CE7-4262-BA0D-CDD77CFA337F/data/Containers/Data/Application/EA7F2C38-392A-474E-800B-6CE929C7C732/tmp/eval101.dylib Reason: tried: '/Users/.../Library/Developer/Xcode/DerivedData/...-hcowozjxxavdbactjmvsvjltvvwd/Build/Products/Debug-iphonesimulator/libswift_Concurrency.dylib' (no such file), '/Library/Developer/CoreSimulator/Volumes/iOS_21C62/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.2.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/introspection/libswift_Concurrency.dylib' (no such file), '/Library/Developer/CoreSimulator/Volumes/iOS_21C62/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.2.simruntime/Contents/Resources/RuntimeRoot/Users/.../Library/Developer/CoreSimulator/Devices/DA06D4B2-5CE7-4262-BA0D-CDD77CFA337F/data/Containers/Data/Application/EA7F2C38-392A-474E-800B-6CE929C7C732/tmp/libswift_Concurrency.dylib' (no such file), '/Users/.../Library/Developer/CoreSimulator/Devices/DA06D4B2-5CE7-4262-BA0D-CDD77CFA337F/data/Containers/Data/Application/EA7F2C38-392A-474E-800B-6CE929C7C732/tmp/libswift_Concurrency.dylib' (no such file), '/Library/Developer/CoreSimulator/Volumes/iOS_21C62/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.2.simruntime/Contents/Resources/RuntimeRoot/Users/.../Library/Developer/CoreSimulator/Devices/DA06D4B2-5CE7-4262-BA0D-CDD77CFA337F/data/Containers/Data/Application/EA7F2C38-392A-474E-800B-6CE929C7C732/tmp/libswift_Concurrency.dylib' (no such file), '/Users/.../Library/Developer/CoreSimulator/Devices/DA06D4B2-5CE7-4262-BA0D-CDD77CFA337F/data/Containers/Data/Application/EA7F2C38-392A-474E-800B-6CE929C7C732/tmp/libswift_Concurrency.dylib' (no such file), '/Library/Developer/CoreSimulator/Volumes/iOS_21C62/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.2.simruntime/Contents/Resources/RuntimeRoot/Users/.../Library/Developer/Xcode/DerivedData/...-hcowozjxxavdbactjmvsvjltvvwd/Build/Products/Debug-iphonesimulator/PackageFrameworks/libswift_Concurrency.dylib' (no such file), '/Users/.../Library/Developer/Xcode/DerivedData/...-hcowozjxxavdbactjmvsvjltvvwd/Build/Products/Debug-iphonesimulator/PackageFrameworks/libswift_Concurrency.dylib' (no such file), '/Users/.../Library/Developer/CoreSimulator/Devices/DA06D4B2-5CE7-4262-BA0D-CDD77CFA337F/data/Containers/Bundle/Application/9FC77364-B3D0-47A4-BDD1-4150DBB0D0B3/....app/Frameworks/libswift_Concurrency.dylib' (no such file), '/Users/.../Library/Developer/CoreSimulator/Devices/DA06D4B2-5CE7-4262-BA0D-CDD77CFA337F/data/Containers/Bundle/Application/9FC77364-B3D0-47A4-BDD1-4150DBB0D0B3/....app/libswift_Concurrency.dylib' (no such file), '/Library/Developer/CoreSimulator/Volumes/iOS_21C62/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.2.simruntime/Contents/Resources/RuntimeRoot/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/lib/darwin/libswift_Concurrency.dylib' (no such file), '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/lib/darwin/libswift_Concurrency.dylib' (no such file), '/Library/Developer/CoreSimulator/Volumes/iOS_21C62/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.2.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libswift_Concurrency.dylib' (no such file)`

johnno1962 commented 10 months ago

That’s unusual and probably not related to using TCA. Can you supply more details of your environment? macOS version, Xcode and iOS target version etc.

tvidenov commented 10 months ago

Yes, sorry. Should have provided it in the first place: The project was based on TCA 1.6.0 but now is 1.7.0 Target: iOS17 Xcode 15.2 macOS: Sonoma 14.3

I will try to make an example app to see if I can reproduce it.

johnno1962 commented 10 months ago

Interesting, TCA uses Concurrency (libswift_Concurrency.dylib) which is in a different directory so I may need to adjust the "rpath". Any chance you have a small example project setup showing the problem? This would save me a lot of time fixing it.

johnno1962 commented 10 months ago

Can you try adjusting your project's "Runpath Search Paths" to include /Applications/Xcode.app//Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/iphonesimulator ?

tvidenov commented 10 months ago

Here's a simple project - https://github.com/tvidenov/tca-inject

johnno1962 commented 10 months ago

Thanks for that but I get: No such module 'AppFeature'. Am I holding it wrong?

tvidenov commented 10 months ago

Sorry, didn't commit everything as I was in a hurry. I actually made it working on this example project, so this means it is something off with my main.

johnno1962 commented 10 months ago

Thatt's good news for InectionIII I guess. Did you try the "Runpath Search Paths" suggestion?

rhenz commented 9 months ago

I am also getting similar issue on my end:

πŸ’‰ Compiling /Users/.../.../HotReloadExample/HotReloadExample/ContentView.swift
πŸ’‰ Loading .dylib ...
πŸ’‰ ⚠️ dlopen() error: dlopen(/Users/.../Library/Developer/CoreSimulator/Devices/5D4024F3-9D68-45AA-82AF-294AD3CC1A44/data/Containers/Data/Application/43FF81B8-2D8D-40E5-A992-9DED9E30C188/tmp/eval101.dylib, 0x0002): symbol not found in flat namespace '_$s7SwiftUI4ViewP6InjectE15enableInjectionQryFQOMg'
πŸ’‰ ⚠️ Loading .dylib has failed, This is likely because Swift code being injected references a function using a default argument or a member with access control that is too restrictive or perhaps an XCTest that depends on code not normally linked into your application. Rebuilding and re-running your project (without a build clean) can resolve this.

How can I resolve this?

johnno1962 commented 9 months ago

Hi, that's probably related to something unrelated to do with symbol visibility called "unhiding" which should have run in the background when you get this error. If you restart your app and try again does it go away?

rhenz commented 9 months ago

Hi, that's probably related to something unrelated to do with symbol visibility called "unhiding" which should have run in the background when you get this error. If you restart your app and try again does it go away?

Hmmm that's weird.. I am pretty sure I restarted the test app I did yesterday, and it did not go away, but today it did! Yeah now it works. Thanks!