johnno1962 / InjectionIII

Re-write of Injection for Xcode in (mostly) Swift
MIT License
4.01k stars 318 forks source link

It doesn't work on Xcode 15.3 iOS 17.4 #493

Closed MsterLiNing closed 6 months ago

MsterLiNing commented 6 months ago

It doesn't work on Xcode 15.3 iOS 17.4 This could be due to one of the following:

  1. Injection does not work with Whole Module Optimization.
  2. There are restrictions on characters allowed in paths.
  3. File paths in the simulator are case sensitive.
  4. The modified source file is not in the current project.
  5. The source file is an XCTest that has not been run yet.
  6. Xcode has removed the build logs. Edit a file and re-run. Try a build clean then rebuild to make logs available or consult: "/Users/**/Library/Containers/com.johnholdsworth.InjectionIII/Data/tmp/command.sh".
micyx commented 6 months ago

I have the same problem!Not solved.

johnno1962 commented 6 months ago

HI, did it work before with the same project or do you think this is a new problem specific to Xcode 15.3?

micyx commented 6 months ago

HI, did it work before with the same project or do you think this is a new problem specific to Xcode 15.3?

I went back to Xcode 15.2 and it worked!

MsterLiNing commented 6 months ago

HI, did it work before with the same project or do you think this is a new problem specific to Xcode 15.3?

Yes, our project used to work normally. Since updating xcode to 15.3 the day before yesterday, it cannot be used normally.

johnno1962 commented 6 months ago

Hi, apologies for the delay getting back this morning. I've noticed recently Xcode is no longer logging all commands in a build but only those that were necessary (files that changed and their dependents etc.) InjectionII parses these build logs (.xcactivity files) to know how to recompile a file and if it doesn't find them you get the message you seen. The way to resolve this could be to do a clean build then the compilation commands for all files should be logged again. If you close and open a project only the last log file is kept so you may have to do this again some times. Injection also keeps a cache in /tmp once a file has been injected successfully so the picture may seem unpredictable. The cache is cleared when you reboot or there is a compilation error (Clearing out the cache completely when a file fails to compile was one of the changes in 1.8.3).

MsterLiNing commented 6 months ago

Hi, apologies for the delay getting back this morning. I've noticed recently Xcode is no longer logging all commands in a build but only those that were necessary (files that changed and their dependents etc.) InjectionII parses these build logs (.xcactivity files) to know how to recompile a file and if it doesn't find them you get the message you seen. The way to resolve this could be to do a clean build then the compilation commands for all files should be logged again. If you close and open a project only the last log file is kept so you may have to do this again some times. Injection also keeps a cache in /tmp once a file has been injected successfully so the picture may seem unpredictable. The cache is cleared when you reboot or there is a compilation error (Clearing out the cache completely when a file fails to compile was one of the changes in 1.8.3).

I performed a clean build operation, but the error persists. I restarted Xcode and also restarted the computer, but the error still persists.The following is the log in command.sh.

search through build logs, most recent first

cd "/Users/*/Library/Developer/Xcode/DerivedData/MyProjectName-dwtohbpjfizdzbaxydtsgfzpobmx/Logs/Build" && for log in `ls -t .xcactivitylog`; do

echo "Scanning $log"

/usr/bin/env perl "/Users/**/Library/Containers/com.johnholdsworth.InjectionIII/Data/tmp/eval101.pl" "$log"     >"/Users/**/Library/Containers/com.johnholdsworth.InjectionIII/Data/tmp/eval101.sh" 2>"/Users/**/Library/Containers/com.johnholdsworth.InjectionIII/Data/tmp/eval101.err" && exit 0

done exit 1;

johnno1962 commented 6 months ago

Are there any files in /Users//Library/Developer/Xcode/DerivedData/MyProjectName-dwtohbpjfizdzbaxydtsgfzpobmx/Logs/Build?

johnno1962 commented 6 months ago

This is most strange. I've been using Xcode 15.3 for a while and cleaned down derived data and retried and injection was working. The log scan is delegated to the script it mentions which would normally print out the compile command. If you could trace through that to try to get to the bottom of the problem that would help. Otherwise is TeamViewing an option?

hnzlk2014 commented 6 months ago

I have the same problem!

johnno1962 commented 6 months ago

I've produced a new release candidate with improved logging if someone would like to try it out and let me know if if provides any more information https://github.com/johnno1962/InjectionIII/releases/tag/4.8.4RC1

qmkCamel commented 6 months ago

The xcactivitylog has changed since 15.3, so the grep log failed.

The following code is a test command when I delete the line https://github.com/johnno1962/HotReloading/blob/82e4ea05a4a1f5fa41439dab5b520b9b944749f0/Sources/HotReloading/SwiftEval.swift#L918

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -ivfsstatcache /Users/edge/Library/Developer/Xcode/DerivedData/SDKStatCaches.noindex/iphoneos17.4-21E210-99a79c02cfa501706f5b564e46d84afe.sdkstatcache -fmessage-length\=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit\=0 -fno-color-diagnostics -fmodules-prune-interval\=86400 -fmodules-prune-after\=345600 -fbuild-session-file\=/Users/edge/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror\=non-modular-include-in-framework-module -Wno-trigraphs -Wno-missing-field-initializers -Wno-missing-prototypes -Werror\=return-type -Wdocumentation -Wunreachable-code -Wno-implicit-atomic-properties -Werror\=deprecated-objc-isa-usage -Wno-objc-interface-ivars -Werror\=objc-root-class -Wno-arc-repeated-use-of-weak -Wimplicit-retain-self -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wnon-literal-null-conversion -Wobjc-literal-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wdeprecated-implementations -Wno-implicit-fallthrough -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -Wno-sign-conversion -Winfinite-recursion -Wcomma -Wblock-capture-autoreleasing -Wstrict-prototypes -Wno-semicolon-before-method-body -Wunguarded-availability -index-store-path /Users/edge/Library/Developer/Xcode/DerivedData/hot_reload-gayvlvbtqyhllgghfunhlhbkhmlo/Index.noindex/DataStore @/Users/edge/Library/Developer/Xcode/DerivedData/hot_reload-gayvlvbtqyhllgghfunhlhbkhmlo/Build/Intermediates.noindex/hot_reload.build/Debug-iphoneos/hot_reload.build/Objects-normal/arm64/e6072d4f65d7061329687fe24e3d63a7-common-args.resp -MMD -MT dependencies -MF /Users/edge/Library/Developer/Xcode/DerivedData/hot_reload-gayvlvbtqyhllgghfunhlhbkhmlo/Build/Intermediates.noindex/hot_reload.build/Debug-iphoneos/hot_reload.build/Objects-normal/arm64/DemoViewController.d --serialize-diagnostics /Users/edge/Library/Developer/Xcode/DerivedData/hot_reload-gayvlvbtqyhllgghfunhlhbkhmlo/Build/Intermediates.noindex/hot_reload.build/Debug-iphoneos/hot_reload.build/Objects-normal/arm64/DemoViewController.dia -c /Users/edge/work/hot_reload_demo/hot_reload/DemoViewController.m -o /Users/edge/Library/Developer/Xcode/DerivedData/hot_reload-gayvlvbtqyhllgghfunhlhbkhmlo/Build/Intermediates.noindex/hot_reload.build/Debug-iphoneos/hot_reload.build/Objects-normal/arm64/DemoViewController.o -index-unit-output-path /hot_reload.build/Debug-iphoneos/hot_reload.build/Objects-normal/arm64/DemoViewController.o

By the way, on device inject, the parsePlatform will not work.

johnno1962 commented 6 months ago

Ahhhh, ObjectiveC! I've uploaded a new pre-release with your fix. Thanks @qmkCamel!

https://github.com/johnno1962/InjectionIII/releases/tag/4.8.4RC2

qmkCamel commented 6 months ago

By the way, on device Objective-C inject, the parsePlatform will not work too on Xcode 15.3. https://github.com/johnno1962/HotReloading/blob/82e4ea05a4a1f5fa41439dab5b520b9b944749f0/Sources/HotReloading/SwiftEval.swift#L524

johnno1962 commented 6 months ago

Good point, I've updated the release candidate, now build #8005.