Code Monkey home page Code Monkey logo

Comments (14)

johnno1962 avatar johnno1962 commented on June 5, 2024

Hi, you need to add the directory where FrameworkD/XXXX.h can be referenced to your project's "Header Search Paths". This would usually be adding something like $(SOURCE_ROOT)/Something/Something where this is the path to a directory from which the path FrameworkD/XXXX.h is valid. Note: you may have to do this in one of the framework sub-projects if you injecting a file in that framework.

from injectioniii.

StartToFly avatar StartToFly commented on June 5, 2024

First of all, thank you for your help. But I still have a few questions to consult with you.

1.My project compiles and runs just fine, except when I do a hot reload, it says I can't find the header file.
2.I tried FrameworkA. xcodeproj as configured
Header Search Paths like "$(SRCROOT)/.. /FrameworkC", because FrameworkA is on the same level as FrameworkC and the real storage path of FrameworkD is in the FrameworkC project directory. The reference to FrameworkD in FrameworkA actually refers to FrameworkD in the FrameworkC project directory,but it still can't find the header file.
3.In fact, I mainly produce FrameworkC, MainProject is just a Demo project of FrameworkC. FrameworkD is another Framework external dependency, I can't create it as a sub-project of mine.

I can't figure out how to configure my Header Search Paths to make hot reload work.

If my description is not clear, I will do an engineering Demo later and upload it to Github. I hope I can get some inspiration from you. Thank you very much.

from injectioniii.

johnno1962 avatar johnno1962 commented on June 5, 2024

The problem is that when you compile your project it has a particular working directory (generally $SRCROOT) from which relative paths work. Unfortunately, when you compile for injection this working directory isn't always replicated so relative paths don't work unless you add absolute paths to the "Header Search Paths" manually.

from injectioniii.

StartToFly avatar StartToFly commented on June 5, 2024

Ok, I will try to configure Header Search Paths again. If it still doesn't work according to my configuration way, I will provide you with a Demo project to see if you can give me some suggestions according to my project. Thanks again.

from injectioniii.

StartToFly avatar StartToFly commented on June 5, 2024

Hello, I tried setting the Header search path and it still didn't work, I uploaded a demo program, could you please take some time to help me check what was wrong with my project. git address is: https://github.com/StartToFly/InjectionIIIDemo.git

I configured Header Search Paths. When I ran my project, modified FrameworkBClass and Cmd+S saved, I still got the following error:

💉 Compiling /Users/XXX/Desktop/InjectionIIIDemo/FrameworkB/FrameworkB/FrameworkBClass.m
💉 ⚠️ Re-compilation failed (see: /var/folders/cs/sxkynxps2rdcdlb53vp6vtt40000gp/T/com.johnholdsworth.InjectionIII/command.sh)
In file included from /Users/XXX/Desktop/InjectionIIIDemo/FrameworkB/FrameworkB/FrameworkBClass.m:9:
/Users/XXXX/Library/Developer/Xcode/DerivedData/InjectionIIIDemo-fqmxnologzsguedugtktdcpbyokd/Build/Products/Debug-iphonesimulator/FrameworkC.framework/Headers/FrameworkCClass.h:9:9: fatal error: 'FrameworkD/FrameworkDClass.h' file not found
#import <FrameworkD/FrameworkDClass.h>
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
💉 ⚠️ Adjust the "Header Search Paths" in your project's Build Settings
image

I found that if I was inside the FrameworkCClas.m to #import <FrameworkD/FrameworkDClass.h>,hot reload should work.But I found that if I was inside the FrameworkCClas.h to #import <FrameworkD/FrameworkDClass.h>,it was error.

I hope that after you have seen my Demo project, you can give me some inspiration and suggestions for project configuration. No matter what the result is, I would like to thank you for your guidance and help throughout the process. Thank you very much.

from injectioniii.

johnno1962 avatar johnno1962 commented on June 5, 2024

Thanks for the demo project. It's always a big help. In your case it seemed to be an Xcode "feature" related to the combination of using a recursive "Header Search Path" with a path involving \$(SRCROOT)/.. which Xcode converts into a relative paths which don't work for the reason I mentioned above as the working directory is not always recovered correctly when you compile for injection. You can see this if you look at the script file it mentions which will contain relative include paths which won't work rather than absolute paths. The solution is to put an absolute path into the "Header Search Path" rather than $(SRCROOT)/... This isn't ideal and there is some code I can reinstate that caters for this particular edge case but at this stage I'd rather not be creating any new releases.

from injectioniii.

johnno1962 avatar johnno1962 commented on June 5, 2024

I rolled a new release in the end https://github.com/johnno1962/InjectionIII/releases/tag/4.6.4. If you try this it should resolve your problem, let me know if it doesn't. You may have to experiment a bit with the search path but you shouldn't run into the relative paths problem.

from injectioniii.

StartToFly avatar StartToFly commented on June 5, 2024

Thank you very much for your help. I will try to apply your suggestions or the latest release version you provided to solve my problem, and I will give you a reply as soon as possible

from injectioniii.

StartToFly avatar StartToFly commented on June 5, 2024

I just used the latest release version of InjectionIII that you specifically provided me with, which is very helpful to use. It has solved the problems that have been consistently encountered in my project and has successfully been hot reloaded.

Next, I will study and learn the true operating principles of Header Search Paths based on your suggestions, so that I can truly grasp the root cause of solving my problem.

Oh, by the way, after iOS13, in Debug mode, Apple has released the restriction on dlopen. Can InjectionIII consider supporting real machine hot reloading? 😁

Thank you again for your guidance and assistance throughout the entire process. Thank you very much.👍

from injectioniii.

johnno1962 avatar johnno1962 commented on June 5, 2024

Yes, a user told me about iOS 13 relaxing the restrictions on dlopen() so I re-enabled device injection a few months ago. Is there a place in the documentation that talks about it not being possible still? It's a little different to use as you can't load one of the injection bundles but use the HotReloading Swift Package instead.

from injectioniii.

StartToFly avatar StartToFly commented on June 5, 2024

I saw in the first line of the Chinese usage document that it does not yet support real device hot reloading, so I think we do not support real machine yet.

But after you told me that InjectionIII supports it, I carefully reviewed the documentation for HotReloading and found that InjectionIII already supports real machine hot reloading.

I can't wait to follow the instructions to configure my project to support hot overloading.

Finally, I would like to consult with you. Did you help me solve the problem of my project not being able to hot load through commit: b3b60d7?

Thank you very much.

from injectioniii.

johnno1962 avatar johnno1962 commented on June 5, 2024

Once you're up and running if you could file a PR on the Chinese usage document that would be very helpful. You can remove the part about -undefined dynamic lookup now since they fixed the linker when you use the -Xlinker -interposable flag. On-device injection is a bit fiddly getting a network connection but the capability is definitely there now you can dlopen() in the debugger. Yes, b3b60d7 was the commit where I reinstated the code that replicates the working directory a source was originally compiled under. I can't remember why I commented it out though I didn't want it interfering with more mainstream Swift injection. In the end I settled on restoring it in a way that won't cause the compile to fail if the directory is invalid.

from injectioniii.

StartToFly avatar StartToFly commented on June 5, 2024

Now both the simulator and the real device are running normally. Thank you very much for your help and understanding in the whole process. I will file a PR on the Chinese usage document as soon as possible. 😊

from injectioniii.

johnno1962 avatar johnno1962 commented on June 5, 2024

Happy to hear it! I updated the 4.6.4 release candidate if you want to download it again to make sure things are still working.

from injectioniii.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.