Code Monkey home page Code Monkey logo

Comments (14)

johnno1962 avatar johnno1962 commented on June 12, 2024

Hi, The defaulting to your home directory for the file watcher is normal as there is no way to know where your project is from inside the app. The error is not normal however and is likely due to characters special to shell in your derived data path causing the shell script to fail completely. Are you able to post the command.sh file it mentions here? Or, run it from the command line which will tell you what the error is.

from hotreloading.

robgtsoftware avatar robgtsoftware commented on June 12, 2024

My apologies, I saw the image in the readme with the expected console logs, so assumed the fact that it only found my home directly was part of the problem.

If I start from a clean install onto a simulator. After running the application and changing a source file, I see:

🔥 ⚠️ Error reading /Users/rowen/Library/Developer/CoreSimulator/Devices/2C9AB6F7-A555-493D-B719-4D9C9634BAB3/data/Containers/Data/Application/7B2EFA25-E09A-4818-B5C3-0B879196E394/tmp/eval101.sh, scanCommand: /Users/rowen/Library/Developer/CoreSimulator/Devices/2C9AB6F7-A555-493D-B719-4D9C9634BAB3/data/Containers/Data/Application/7B2EFA25-E09A-4818-B5C3-0B879196E394/tmp/command.sh

File contents of the command.sh file:

cd "/Users/rowen/Library/Developer/Xcode/DerivedData/ArcticFox-fcbqjfisyjvvpbaillfniccyhupr/Logs/Build" &&
for log in `ls -t *.xcactivitylog`; do
    #echo "Scanning $log"
    /usr/bin/env perl "/Users/rowen/Library/Developer/CoreSimulator/Devices/2C9AB6F7-A555-493D-B719-4D9C9634BAB3/data/Containers/Data/Application/7B2EFA25-E09A-4818-B5C3-0B879196E394/tmp/eval101.pl" "$log"     >"/Users/rowen/Library/Developer/CoreSimulator/Devices/2C9AB6F7-A555-493D-B719-4D9C9634BAB3/data/Containers/Data/Application/7B2EFA25-E09A-4818-B5C3-0B879196E394/tmp/eval101.sh" 2>"/Users/rowen/Library/Developer/CoreSimulator/Devices/2C9AB6F7-A555-493D-B719-4D9C9634BAB3/data/Containers/Data/Application/7B2EFA25-E09A-4818-B5C3-0B879196E394/tmp/eval101.err" && exit 0
done
exit 1;

File itself is not executable and trying to run it gives a permission denied error.
-rw-r--r--@ 1 rowen staff 809 28 Aug 14:00 /Users/rowen/Library/Developer/CoreSimulator/Devices/2C9AB6F7-A555-493D-B719-4D9C9634BAB3/data/Containers/Data/Application/7B2EFA25-E09A-4818-B5C3-0B879196E394/tmp/command.sh

In the tmp folder, there is only command.sh and eval101.pl

After chmod I can run it which generates eval101.err, eval101.pl, eval101.sh and filelist.txt and don't see any errors on the command line. Also, the eval101.err is empty, but eval101.sh and filelist.txt have info in them. The only thing I see which looks strange is that the filelist has a blank line part way through:

/Users/rowen/Documents/Development/ArcticFox/Logbook/Logbook/Utility/UIViewControllerExtensions.swift

/Users/rowen/Documents/Development/ArcticFox/Logbook/Logbook/ViewControllers/ThemeViewController.swift

If I run the project again and make a change to a source file and save I see this

Compiling 
/path/to/TableViewController.swift

However I don't see hot reloading.

Any changes to a storyboard result in this error:

Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSCocoaErrorDomain Code=260 "The file “eval103.sh” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/Users/rowen/Library/Developer/CoreSimulator/Devices/2C9AB6F7-A555-493D-B719-4D9C9634BAB3/data/Containers/Data/Application/E2DE8E57-3CB1-407F-ADD9-4FC573711FB6/tmp/eval103.sh, NSUnderlyingError=0x60000274b060 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}: file HotReloading/SwiftEval.swift, line 323

Looking at the command.sh file in that location (the original files are gone now)

cd "/Users/rowen/Library/Developer/Xcode/DerivedData/ArcticFox-fcbqjfisyjvvpbaillfniccyhupr/Logs/Build"
for log in `ls -t *.xcactivitylog`; do
    #echo "Scanning $log"
    /usr/bin/env perl <(cat <<'PERL'
        use English;
        use strict;

        # line separator in Xcode logs
        $INPUT_RECORD_SEPARATOR = "\r";

        # format is gzip
        open GUNZIP, "/usr/bin/gunzip <\"$ARGV[0]\" 2>/dev/null |" or die;

        # grep the log until to find codesigning for product path
        my $realPath;
        while (defined (my $line = <GUNZIP>)) {
            if ($line =~ /^\s*cd /) {
                $realPath = $line;
            }
            elsif (my ($product) = $line =~ m@/usr/bin/ibtool.*? --link (([^\ ]+\\ )*\S+\.app)@o) {
                print $product;
                exit 0;
            }
        }

        # class/file not found
        exit 1;
PERL
    ) "$log" >"/Users/rowen/Library/Developer/CoreSimulator/Devices/2C9AB6F7-A555-493D-B719-4D9C9634BAB3/data/Containers/Data/Application/E2DE8E57-3CB1-407F-ADD9-4FC573711FB6/tmp/eval103.sh" && exit 0
done
exit 1;

And running it gives:

/Users/rowen/Library/Developer/CoreSimulator/Devices/2C9AB6F7-A555-493D-B719-4D9C9634BAB3/data/Containers/Data/Application/E2DE8E57-3CB1-407F-ADD9-4FC573711FB6/tmp/command.sh: line 5: syntax error near unexpected token `('

/Users/rowen/Library/Developer/CoreSimulator/Devices/2C9AB6F7-A555-493D-B719-4D9C9634BAB3/data/Containers/Data/Application/E2DE8E57-3CB1-407F-ADD9-4FC573711FB6/tmp/command.sh: line 5: ` /usr/bin/env perl <(cat <<'PERL''

Happy to provide what other information would be helpful and thanks for the help

from hotreloading.

johnno1962 avatar johnno1962 commented on June 12, 2024

Any chance you could move the project out of the ~/Documents folder and try again? This can cause problems though not normally the ones you're seeing. The other possibility is the migration from bash to zsh. What macOS version is this? Leave the storyboard issue to one side for a moment as it is a manifestation of the same problem. Once recompiling is working you should see messages it has injected various type then to see injection working you need to make sure the swizzled code paths are called again using say, and @objc fun injected() method.

from hotreloading.

robgtsoftware avatar robgtsoftware commented on June 12, 2024

Mac 12.15.1
zsh 5.8.1 (x86_64-apple-darwin21.0)

Moving the folder up to ~/ still gives me the first set of errors when running the project and no change in behaviour if I chmod, etc.

from hotreloading.

johnno1962 avatar johnno1962 commented on June 12, 2024

I've not seen this before but it would be good to get to the bottom of it in case it affects other users. Have you tried the InjectionIII app which asks you to load a bundle instead of adding a swift package and is more commonly used? This should avoid the problems the simulator seems to be having writing to these files.

from hotreloading.

robgtsoftware avatar robgtsoftware commented on June 12, 2024

I have used it previously on this project on a branch, but not actively. I tried again yesterday, but I had errors about not being able to load the correct version of SwiftTrace. Let me do a bit more on my end. I will try a new project to see if I can get it working in a simpler case and to try again with the Injection app in both cases. Will let you know.

from hotreloading.

johnno1962 avatar johnno1962 commented on June 12, 2024

Thanks for the time you're spending on this! You need to do a clean build after switching from HotReloading to iOSInjection.bundle or an incompatible version of SwiftTrace.framework is left in DerivedData which it tries to use. Is hanging out an option?

from hotreloading.

robgtsoftware avatar robgtsoftware commented on June 12, 2024

Of course, happy to help..its a great bit of code and I would love to use it more. Thanks for the switching tip. I can't do much more tonight as it is latish in my timezone and have family commitments. However, if we can find another time I am game to help troubleshoot this a bit more real time, but I have to ask, how would we "hang out". Feel like I am going to be either showing my age or lack or experience in these matters. :-)

from hotreloading.

johnno1962 avatar johnno1962 commented on June 12, 2024

TBH I'm not sure what the options are now. I would say TeamView but I only have a very old copy. Google hangouts used to work but did they deprecate that? Do you have "tuple"? For now let's see if we can get you up and running with the more mainstream app and perhaps we can look at HotReloading sometime later.

from hotreloading.

robgtsoftware avatar robgtsoftware commented on June 12, 2024

Tuple looks very cool, but alas I don't have it.

OK, sorry finally got back to this.

  1. On a simple test project, hot reloading works perfectly, so must be something in my project.
  2. On said project, InjectionIII works fine for code changes, but for storyboard changes I get the following:

Thread 1: Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSCocoaErrorDomain Code=260 "The file “eval103.sh” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/Users/rowen/Library/Developer/CoreSimulator/Devices/2C9AB6F7-A555-493D-B719-4D9C9634BAB3/data/Containers/Data/Application/C44FEB93-7C47-40D5-AD80-9D66953ED0A2/tmp/eval103.sh, NSUnderlyingError=0x600003e54660 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}

from hotreloading.

johnno1962 avatar johnno1962 commented on June 12, 2024

I guess that's progress, so at least we know it's not an OS problem. I have my doubts code injection is 100%. For the failing project does the directory these temporary files should be in exist? I guess it does or you wouldn't have been able to post the command.sh. What aspect of a project could possibly affect permissions on the tmp directory?

from hotreloading.

johnno1962 avatar johnno1962 commented on June 12, 2024

An idle thought: I remember a problem where if your app had thousands of temporary files there could be problems creating new ones. Have you tried deleting you app from the simulator and then re-running? Or you could trying cloning the HotReloading project and dragging it onto your app's project to take precedence and changing the temporary directory to say, /tmp at line 32 of Sources/HotReloading/StandaloneInjection.swift

from hotreloading.

robgtsoftware avatar robgtsoftware commented on June 12, 2024

I will have to do some more exploration on the permissions side of things. On your second question, yes, I have tried a clean install and a completely clean simulator with the same results. Will keep playing around as I can..thx again.

from hotreloading.

johnno1962 avatar johnno1962 commented on June 12, 2024

Hi, I spent more time on this looking at another issue (mentioned above) and there were two problems here. The App Store version of injection will only work in a >= iOS 14 simulator on Apple Silicon and for different reasons the HotReloading project is only able to receive file change events for iOS >= 13. More confident I have the technology under control now but in general it's best to target a more recent simulator, particularly on Apple Silicon as simulators < iOS 14 contain only Intel architecture which causes problems for the sandboxed search of logs.

from hotreloading.

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.