krzysztofzablocki / Inject

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

Not working in AppCode #57

Closed icedice closed 1 year ago

icedice commented 1 year ago

I'm trying to get this to work in AppCode (it works fine in Xcode) but I keep seeing this, any one knows whats going on?

πŸ’‰ Compiling /Users/user/git/MyApp/MyApp.swift πŸ’‰ Loading .dylib ... πŸ’‰ ⚠️ dlopen() error: dlopen(/Users/user/Library/Developer/CoreSimulator/Devices/3B86055C-0B91-4BCB-894C-F9AE1495D42C/data/Containers/Data/Application/CCFD64A8-BC92-446E-BD13-7601EC4422AD/tmp/eval102.dylib, 0x0002): tried: '/Users/user/Library/Caches/JetBrains/AppCode2022.2/DerivedData/News-ebmudasepawfrxgusfsadmvllwph/Build/Products/debug-iphonesimulator/eval102.dylib' (no such file), '/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.2.simruntime/Contents/Resources/RuntimeRoot/Users/user/Library/Developer/CoreSimulator/Devices/3B86055C-0B91-4BCB-894C-F9AE1495D42C/data/Containers/Data/Application/CCFD64A8-BC92-446E-BD13-7601EC4422AD/tmp/eval102.dylib' (no such file), '/Users/user/Library/Developer/CoreSimulator/Devices/3B86055C-0B91-4BCB-894C-F9AE1495D42C/data/Containers/Data/Application/CCFD64A8-BC92-446E-BD13-7601EC4422AD/tmp/eval102.dylib' (mach-o file (/Users/user/Library/Developer/CoreSimulator/Devices/3B86055C-0B91-4BCB-894C-F9AE1495D42C/data/Containers/Data/Application/CCFD64A8-BC92-446E-BD13-7601EC4422AD/tmp/eval102.dylib), but incompatible platform (have 'iOS', need 'iOS-sim')), '/usr/lib/eval102.dylib' (no such file)

johnno1962 commented 1 year ago

Hi, what version of the injectionIII app/Xcode/iOS is this? Can you try downloading the most recent build please: https://github.com/johnno1962/InjectionIII/releases?

icedice commented 1 year ago

Sorry I realise that was not a lot of info I gave. I was using the 4.5.0, just updated to 4.5.1 but it did not seem to solve it. Weird thing is that it only happens in AppCode not in Xcode...

Im on a M1 pro macbook with macOS 13.0. I'm using Xcode 14.1. For AppCode I tried 2022.2.4 (which officially does not support either MacOS 13 or Xcode 14) and the newest 2022.3 EAP both gave me the result above...

I tried a bunch of different iOS simulators, but the main one i tested with was iPhone 14 Pro Max iOS 16.1

johnno1962 commented 1 year ago

Are you able to export and send GitHub at johnholdsworth.com the build logs of the project?

icedice commented 1 year ago

Not sure I follow. Is it the build logs from AppCode you want?

johnno1962 commented 1 year ago

Never mind, I've just downloaded the EAP and it seems to be working for me. This sort of problem can occur when InjectionIII selects the wrong logs to find the command to recompile. Can you try loading the bundle but not running the InjectionIII app which should fall back to the new "standalone" version of injection and let me know how you get on?

icedice commented 1 year ago

I managed to get it working. I tried on another macbook with same setup and it worked.

After uninstalling everything jetbrains releated and deleting all caches and files related to jetbrains in installed the EAP again and now it's working. I have no clue what caused this but AppCode has been giving me so many issues lately that I'm thinking about going back to Xcode...

Whats the difference between running the app and the standalone version? When the app is not running it outputs this

/Users/user/Library/Caches/JetBrains/AppCode2022.3/DerivedData/News-ebmudasepawfrxgusfsadmvllwph/Build/Products/debug-iphonesimulator/News.app πŸ’‰ Not falling back to standalone HotReloading as you are using the β€˜Inject’ package. Use MenuBar app to control Injection status or opt in by using INJECTION_STANDALONE env var. 2022-11-15 12:23:55.641873+0100 News[3703:30627] Could not connect: Connection refused

icedice commented 1 year ago

setting the INJECTION_STANDALONE flag also seems to be working great. Is there any disadvantage to this way of doing it?

johnno1962 commented 1 year ago

"Standalone" mode is a recent development where it is possible to implement all of injection from inside the bundle at a stretch. It also has a slightly more reliable, automatic way to locate the build logs by searching for the .xcactivitylog file of the most recent project built, a convention AppCode also uses. There shouldn't be major disadvantages as it's the same code and it's probably the way forward except that as it runs the swift compiler from inside the simulator(😱) the filesystem is case sensitive and it is important the casing of the actual filename matches that in the project. Extra points to you for using the INJECTION_STANDALONE env var!

icedice commented 1 year ago

Thank you for the explanation and for this excellent tool! I think I have your book somewhere I really should dig into how all this black magic works soon...

Anyways, everything seems to be working now and was apparently caused by a bad AppCode installation somehow.