Giter VIP home page Giter VIP logo

hotreloading's People

Contributors

byohay avatar davidbalbert avatar johnno1962 avatar kingtous avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hotreloading's Issues

HotReloading not linking to project

Xcode 13.4.1
Hotloading package (main or most recent version via SPM)
iOS Project iOS 12+
iPhone Simulator running 13.7 and 15.5

  1. Added the package
  2. Added the linker flags

image

When the app runs, all I see related to the framework at the start of the logs is:

🔥 HotReloading available for sources under ["/Users/rowen"]

So it is not even finding the project.

If I try to change/save a source file I get:

⚠️ Error reading /Users/rowen/Library/Developer/CoreSimulator/Devices/2C9AB6F7-A555-493D-B719-4D9C9634BAB3/data/Containers/Data/Application/664FEB1C-8ADD-4B9B-A4E6-4B368C9CA5A4/tmp/eval103.sh, scanCommand: /Users/rowen/Library/Developer/CoreSimulator/Devices/2C9AB6F7-A555-493D-B719-4D9C9634BAB3/data/Containers/Data/Application/664FEB1C-8ADD-4B9B-A4E6-4B368C9CA5A4/tmp/command.sh

Am I missing something in the setup?

Problems using HotReloading as a Swift package

I added HotReloading as a Swift package for device Injection on an iOS device. Since it didn't connect, I tried to follow the instructions in the README:

If your device doesn't connect, clone this project and configure your mac's WiFi IP address into the hostname variable in Package.swift. Then drag the clone onto your project to have it take the place of the configured Swift Package.

However it seems like a non trivial task to replace the Swift package with a local copy. Adding it as a local package doesn't work -There are no HotReloading prints at all (I think that this is caused by the fact that it won't let you select any products for a local package, as opposed to using a remote package). Changing the URL to my local copy in the .pbxproj file didn't work either. In fact the only thing that worked was to go to the checkouts folder of the app's derived data folder and replace the HotReloading package with a symlink to my local copy.
Even after that, when changing code in HotReloading and compiling my app, the change wasn't reflected the first time I compiled the app and I had to try several times until it worked.

Questions:

  1. Is there an easier way to use a local copy of HotReloading? If so, can you elaborate on it in the readme?
  2. After I changed code in HotReloading, is there a way to guarantee that the new code will be used in the app when I compile it? If I were to use HotReloading as a subproject instead, Xcode would create a dependency between my app and HotReloading, which would guarantee that the new code of HotReloading is used by the app.
  3. Assuming the answers to the previous questions is no, is there an alternative way to use device injection with HotReloading? If not, is it worth looking into?

P.S. Thanks for this really amazing project!!

Does it support C functions 、variable in other files?

I tried the C functions 、variable in one file, it does works. But when I test it in another file, it doesn`t work.

// when change the b_func() print, and call from main(), it doesn`t work.
// file A 
extern b_func();
int main()
{
   b_func();
   return 0;
}


// file B
void b_func() 
{
   printf("b_func");
}

Breakpoint not work after injection

After I changed my code, the breakpoint will not work correctly.

This is the Example.zip

MacOS: 12.3
XCode: 13.3
iPhone: iPhone 7 Plus 14.7.1

🔥 HotReloading connected /Users/xxx/Project/Example/Example.xcodeproj
🔥 Watching files under /Users/xxx/Project/Example
🔥 Watching files under /Users/xxx/Project/HotReloading
🔥 Compiling /Users/xxx/Project/Example/Example/ViewController.m
🔥 InjectionLoader: ⚠️ This implementation is available to evaluate until Thu Sep 15
🔥 ⚠️ Number of class refs 4 does not equal []
🔥 ⚠️ Could not locate descriptors section
🔥 As class ViewController has an @objc injected() method, HotReloading will perform a "sweep" of live instances to determine which objects to message. If this fails, subscribe to the notification "INJECTION_BUNDLE_NOTIFICATION" instead.
🔥 (note: notification may not arrive on the main thread)
🔥 Starting sweep [ViewController], []...
2022-04-07 10:37:36.857295+0800 Example[27267:5538503] Application tried to push a nil view controller on target <UINavigationController: 0x108019200>.

AppCode Support

I'm aware of the fact that AppCode's InjectionIII plugin is available separately. But, I wish I can use HotReloading project directly due to the fact that it is super easy to integrate with Swift Package Manager.

After importing HotReloading via SPM, the app launches but hot reloading doesn't seem to work. I'm guessing the intermediate path used by AppCode is different. (just guessing...) Anyway, I wish HotReloading works with AppCode too.

Thanks for this awesome project.

🔥 ⚠️ Error reading /.../evalXXX.sh, scanCommand: /.../command.sh

I'm using HotReloading straight from the main branch.

I tried to use HotReloading in our project, and quite often I get error message.
I managed to reproduce the same on an empty project, seems to happen more frequent on iOS 12 than 13 (when testing on 13 I also bump the minimum deployment target).

🔥 ⚠️ Error reading /Users/mariuszwisniewski/Library/Developer/CoreSimulator/Devices/805D1E12-6F50-4175-8C9E-E8B19D7059D6/data/Containers/Data/Application/5C1C27AC-C253-4379-9DFE-0EA8863BF855/tmp/eval144.sh, scanCommand: /Users/mariuszwisniewski/Library/Developer/CoreSimulator/Devices/805D1E12-6F50-4175-8C9E-E8B19D7059D6/data/Containers/Data/Application/5C1C27AC-C253-4379-9DFE-0EA8863BF855/tmp/command.sh

When this error appears in the console, the file mentioned in the error does not exist (so e.g. eval144.sh is not present), just its .pl version and the command.sh file.

When debugging SwiftEval.swift I can see that return runner.run(script: cmdfile) does return true so all should be fine. When I run command.sh manually, it does create mentioned eval144.sh.

What I also tried, was to put a breakpoint before

        var compileCommand: String
        do {
            compileCommand = try String(contentsOfFile: "\(tmpfile).sh")

and at this point run command.sh from terminal, which does create the file. It does help in a sense that the error does not appear anymore (even for the next evaluations), but the app is not refreshed (i.e. my code changes are not taken into acccount).

I also tried the standalone version of InjectIII app combined with https://github.com/krzysztofzablocki/Inject which seems to work fine.

Is there any other info I could provide to help debug the issue?

Error: builtin-swiftDriverJobExecution

Greetings.
I added HotReloading + HotSwiftUI dependencies as Swift Package to my project and got an error:

🔥 ⚠️ Re-compilation failed (see: /Users/moon/Library/Developer/CoreSimulator/Devices/A8E4ECAD-23CE-4855-8643-5475F921ED7B/data/Containers/Data/Application/7C7AE435-B722-4BA6-9376-995B2064DED7/tmp/command.sh)
/Users/moon/Library/Developer/CoreSimulator/Devices/A8E4ECAD-23CE-4855-8643-5475F921ED7B/data/Containers/Data/Application/7C7AE435-B722-4BA6-9376-995B2064DED7/tmp/command.sh: line 1: builtin-swiftDriverJobExecution: command not found

That say: command.sh: line 1: builtin-swiftDriverJobExecution: command not found.
I don't know which command.

I also built your fork project SwiftUI-Kit and got the same error:

🔥 HotReloading connected /Users/moon/Developer/Swift/Applications/SwiftUI-Kit/SwiftUI Kit.xcodeproj
🔥 Watching files under /Users/moon/Developer/Swift/Applications/SwiftUI-Kit
🔥 Compiling /Users/moon/Developer/Swift/Applications/SwiftUI-Kit/Shared/ContentView.swift
🔥 ⚠️ Re-compilation failed (see: /Users/moon/Library/Developer/CoreSimulator/Devices/A8E4ECAD-23CE-4855-8643-5475F921ED7B/data/Containers/Data/Application/7C7AE435-B722-4BA6-9376-995B2064DED7/tmp/command.sh)
/Users/moon/Library/Developer/CoreSimulator/Devices/A8E4ECAD-23CE-4855-8643-5475F921ED7B/data/Containers/Data/Application/7C7AE435-B722-4BA6-9376-995B2064DED7/tmp/command.sh: line 1: builtin-swiftDriverJobExecution: command not found

Maybe I'm doing something wrong?

Xcode 13.2 (Build 13C90)
Swift 5.5
macOS Monterey 12.1

Screen Shot 2021-12-17 at 02 52 02

Crasing in SwiftInjection

Hey,

at first it was occasional, now almost every other app build/start, I get crashes in SwiftInjection.swift
Screenshot 2023-03-10 at 22 17 32
Could it be related to some unit test files are not building at this moment? I cann't figure out what could trigger this. Updated to latest version 4.10.3 and latest InjectionIII app too, didn't help.

Crash on device

After injected, my project always crash at 'injected_code' line 23.
Then I type 'p HotReloading.stack()', get info as below:

#0 0x108ad43d0 0x108ad43d0 0x108ad43d0? ?/dyld 0x108ad4214
#1 0x10583fefc main/Demo 0x10583febc
#2 0x1849e93d0 UIApplicationMain/UIKitCore 0x1849e9280
#3 0x184c4fc50 <redacted>/UIKitCore 0x184c4f818
#4 0x1a2c89988 GSEventRunModal/GraphicsServices 0x1a2c898e8
#5 0x182454c30 CFRunLoopRunSpecific/CoreFoundation 0x1824549f4
#6 0x1824419dc <redacted>/CoreFoundation 0x1824415e8
#7 0x182446454 <redacted>/CoreFoundation 0x1824461ec
#8 0x18247521c <redacted>/CoreFoundation 0x1824751fc
#9 0x1848c0dcc <redacted>/UIKitCore 0x1848c0d78
#10 0x185f73164 <redacted>/QuartzCore 0x185f72ea0
#11 0x185f6a67c <redacted>/QuartzCore 0x185f6a4ac
#12 0x185f56c90 <redacted>/QuartzCore 0x185f56c0c
#13 0x185f63edc <redacted>/QuartzCore 0x185f63ccc
#14 0x1848e6738 <redacted>/UIKitCore 0x1848e5d3c
#15 0x184a239c8 <redacted>/UIKitCore 0x184a238e8
#16 0x184af39dc <redacted>/UIKitCore 0x184af3938
#17 0x184c128c0 <redacted>/UIKitCore 0x184c12560
#18 0x1849fd0cc <redacted>/UIKitCore 0x1849fd00c
#19 0x184a00924 <redacted>/UIKitCore 0x184a00878
#20 0x184907a4c <redacted>/UIKitCore 0x184907650
#21 0x1849051d4 <redacted>/UIKitCore 0x18490516c
#22 0x113b52bd4 @objc Demo.SignatureViewController.viewDidLoad() -> () $s8Demo23SignatureViewControllerC11viewDidLoadyyFTo/SignatureViewController.swift 0x113b52bb0
#23 0x113b516e4 Demo.SignatureViewController.viewDidLoad() -> () $s8Demo23SignatureViewControllerC11viewDidLoadyyF/SignatureViewController.swift 0x113b51688
#24 0x113b51f10 Demo.SignatureViewController.(configUI in _4F337A67922A028DD279ED751156E17A)() -> () $s8Demo23SignatureViewControllerC8configUI33_4F337A67922A028DD279ED751156E17ALLyyF/SignatureViewController.swift 0x113b516fc
#25 0x10583febc main/Demo 0x10583febc
#26 0x12a268a5c 0x12a268a5c 0x12a268a5c? ?/bad image 0x10583febc
#27 0x105dd2340 static HotReloading.HotReloading.stack.getter : () $s12HotReloadingAAV5stackytvgZ/Demo 0x105dd2334
#28 0x10bbdfb6c injection_stack/SwiftTrace 0x10bbdfb14
(Void) $R0 = {}
  Fix-it applied, fixed expression was: 
    HotReloading.stack

Works fine for simulator. Any help? Thanks very much.

Cannot use HotReloading with Other debug configurations (ex. Dev, Test Configuration)

Hello, I have a question.
When I use the HotReloading package with other configurations, the Injection does not start.
If I use a scheme that has "Test Configuration", I found that BundleInjection is not loaded and Injection doesn't start.
The "Test Configuration" is just a copy of "Debug Configuration" and only the name is different.

You can reproduce this situation even with SwiftUI-Kit after adding a new configuration and a new scheme using the new configuration.

Is there any way to use other configuration other than Debug? (Of course, except Release)
Thank you.



image

Related Issue:
#57 (comment)

lopen() error: dlopen(/private/var/mobile/Containers/Data

The following error was reported, and I did not run it again many times, nor did I clear DeriveData
🔥 Loading .dylib ...
🔥 ⚠️ dlopen() error: dlopen(/private/var/mobile/Containers/Data/Application/1E8E5159-E037-4069-B520-2DE8ACBFE59F/tmp/eval104.dylib, 2): Symbol not found: _OBJC_PROTOCOL$_TalosPopUpFrameBusinessProtocol
Referenced from: /private/var/mobile/Containers/Data/Application/1E8E5159-E037-4069-B520-2DE8ACBFE59F/tmp/eval104.dylib
Expected in: flat namespace
in /private/var/mobile/Containers/Data/Application/1E8E5159-E037-4069-B520-2DE8ACBFE59F/tmp/eval104.dylib
🔥 ⚠️ 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.
🔥 ⚠️ Injection error: Error Domain=SwiftEval Code=-1 "dlopen() error: dlopen(/private/var/mobile/Containers/Data/Application/1E8E5159-E037-4069-B520-2DE8ACBFE59F/tmp/eval104.dylib, 2): Symbol not found: _OBJC_PROTOCOL$_TalosPopUpFrameBusinessProtocol
Referenced from: /private/var/mobile/Containers/Data/Application/1E8E5159-E037-4069-B520-2DE8ACBFE59F/tmp/eval104.dylib
Expected in: flat namespace
in /private/var/mobile/Containers/Data/Application/1E8E5159-E037-4069-B520-2DE8ACBFE59F/tmp/eval104.dylib

Visual Studio Code support?

Hey @johnno1962, firstly thanks for all your work on HotReloading!

I stupidly made the issue on wrong repo here: jordansinger/SwiftUI-Kit#46

Cheers for responding.

I wonder if you might offer some help as to how I can get HotReloading to work when debugging using vscode.

I've created a demo repo here: https://github.com/markst/hotreloading-vscode-ios
Hot reloading works great when running the generated Xcode project from Xcode.
However when launching the project from vscode, hot reloading doesn't work.

iOS device injection not working when running as a Mac app

I'm trying to use injection when running an iOS app as a Mac app, but I don't see the changes on screen. Is running an iOS app as Mac supported? I assumed it is because I saw that code in HotReloading that use isiOSAppOnMac.

Attached is a simple app that shows the problem. Whether I'm changing the textView's text in ViewController or ViewController's background color I don't see the change on screen.
ExampleApp.zip

UI not refreshing

Changing autolayout constraints in custom tableviewcell class, then command + s, code compliled, but the ui no refreshing, any good solutions for this scenario?

Xcode 15 beta link SwiftTrace failed

Hi, I use the HotReloading as a package in my project. When I try it with the Xcode 15 beta, found the SwiftTrace link failed.

clang: error: unable to execute command: Segmentation fault: 11
clang: error: linker command failed due to signal (use -v to see invocation)

I see the project has adapted with Xcode 15 beta. So, did I need make some extra build setting on the project ? Thanks~

I test it with 4.11.16 on an empty demo project, and the command is as below.

    /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Xlinker -reproducible -target arm64-apple-ios12.0 -dynamiclib -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.0.sdk -O0 -L/Users/camel/Library/Developer/Xcode/DerivedData/BetaXcodeApp-euxtxbekqbyurifpuhqfctmliuqi/Build/Intermediates.noindex/EagerLinkingTBDs/Debug-iphoneos -L/Users/camel/Library/Developer/Xcode/DerivedData/BetaXcodeApp-euxtxbekqbyurifpuhqfctmliuqi/Build/Products/Debug-iphoneos/PackageFrameworks -L/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/lib -F/Users/camel/Library/Developer/Xcode/DerivedData/BetaXcodeApp-euxtxbekqbyurifpuhqfctmliuqi/Build/Intermediates.noindex/EagerLinkingTBDs/Debug-iphoneos -F/Users/camel/Library/Developer/Xcode/DerivedData/BetaXcodeApp-euxtxbekqbyurifpuhqfctmliuqi/Build/Products/Debug-iphoneos/PackageFrameworks/PackageFrameworks -F/Users/camel/Library/Developer/Xcode/DerivedData/BetaXcodeApp-euxtxbekqbyurifpuhqfctmliuqi/Build/Products/Debug-iphoneos/PackageFrameworks/PackageFrameworks -F/Users/camel/Library/Developer/Xcode/DerivedData/BetaXcodeApp-euxtxbekqbyurifpuhqfctmliuqi/Build/Products/Debug-iphoneos/PackageFrameworks -F/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Frameworks -iframework /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Frameworks -iframework /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.0.sdk/Developer/Library/Frameworks -filelist /Users/camel/Library/Developer/Xcode/DerivedData/BetaXcodeApp-euxtxbekqbyurifpuhqfctmliuqi/Build/Intermediates.noindex/SwiftTrace.build/Debug-iphoneos/SwiftTrace\ product.build/Objects-normal/arm64/SwiftTrace.LinkFileList -install_name @rpath/SwiftTrace.framework/SwiftTrace -Xlinker -rpath -Xlinker /usr/lib/swift -dead_strip -Xlinker -object_path_lto -Xlinker /Users/camel/Library/Developer/Xcode/DerivedData/BetaXcodeApp-euxtxbekqbyurifpuhqfctmliuqi/Build/Intermediates.noindex/SwiftTrace.build/Debug-iphoneos/SwiftTrace\ product.build/Objects-normal/arm64/SwiftTrace_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -fobjc-link-runtime -L/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos -L/usr/lib/swift -Xlinker -rpath -Xlinker /Users/camel/Library/Developer/Xcode/DerivedData/BetaXcodeApp-euxtxbekqbyurifpuhqfctmliuqi/Build/Products/Debug-iphoneos/PackageFrameworks/PackageFrameworks -lc++ -Xlinker -rpath -Xlinker /Users/camel/Library/Developer/Xcode/DerivedData/BetaXcodeApp-euxtxbekqbyurifpuhqfctmliuqi/Build/Products/Debug-iphoneos/PackageFrameworks/PackageFrameworks -Xlinker -dependency_info -Xlinker /Users/camel/Library/Developer/Xcode/DerivedData/BetaXcodeApp-euxtxbekqbyurifpuhqfctmliuqi/Build/Intermediates.noindex/SwiftTrace.build/Debug-iphoneos/SwiftTrace\ product.build/Objects-normal/arm64/SwiftTrace_dependency_info.dat -o /Users/camel/Library/Developer/Xcode/DerivedData/BetaXcodeApp-euxtxbekqbyurifpuhqfctmliuqi/Build/Products/Debug-iphoneos/PackageFrameworks/SwiftTrace.framework/SwiftTrace -Xlinker -add_ast_path -Xlinker /Users/camel/Library/Developer/Xcode/DerivedData/BetaXcodeApp-euxtxbekqbyurifpuhqfctmliuqi/Build/Intermediates.noindex/SwiftTrace.build/Debug-iphoneos/SwiftTrace.build/Objects-normal/arm64/SwiftTrace.swiftmodule

Could not work for ObjC: Number of class refs 1 does not equal []

Hi, I tried SwiftUI-Kit on device, it works fine.
But when I tested on my Objective C project, it was failed.

Here is the output:

🔥 Compiling Demo/HotReloadingDemo/HotReloadingDemo/ViewController.m
🔥 ⚠️ Number of class refs 1 does not equal []
🔥 ⚠️ Could not locate descriptors section

The demo project is very simple, only one core file ViewController.m, and here is the source:

// ViewController.m

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
}

- (IBAction)onTestButtonClicked:(id)sender {
    self.view.backgroundColor = [UIColor greenColor]; // Change the color type then `Command + S`
}

@end

Thanks for your time.

Unable to create socket for device injection

As the title says, the package is unable to create the socket to port 8899.
Injection app is running in the background as well. I tried pinging that port on mac, but was unable to.
The defaults key is also written.
Any help is appreciated.

image

image

Undefined symbol _FSEventStream* in FileWatcher

I imported the HotReloading target in my project and it complains about these symbols' missing for both simulator and real device.

Undefined symbols for architecture x86_64:
  "_FSEventStreamScheduleWithRunLoop", referenced from:
      HotReloading.FileWatcher.init(root: Swift.String, callback: (__C.NSArray, Swift.String) -> ()) -> HotReloading.FileWatcher in HotReloading.o
  "_FSEventStreamCreate", referenced from:
      HotReloading.FileWatcher.init(root: Swift.String, callback: (__C.NSArray, Swift.String) -> ()) -> HotReloading.FileWatcher in HotReloading.o
  "_FSEventStreamStart", referenced from:
      HotReloading.FileWatcher.init(root: Swift.String, callback: (__C.NSArray, Swift.String) -> ()) -> HotReloading.FileWatcher in HotReloading.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Updates overlap in UI

I have created a sample project to test this package out - the only custom code is pictured below. Whenever I make a change to the text both the previous and new text overlap each other - the old view is not being cleaned up properly

I am using the following to force a reload:

extension UIViewController {
    @objc func injected() {
        viewDidLoad()
    }
}

image

Version 4.9.6
MacOS Ventura 13.1 (22C65)
Xcode 14.2.0

Cannot reload on M1: Mac os Sonoma prevents InjectionIII from accessing data

Hi there, and thanks again for fixing my previous issue
#88

The previous fix implemented in 4.7.5 solved the “eval101.dylib” message issue, however recently I've upgraded to MacOS Sonoma, and now, again I cannot use InjectionIII on Apple Silicon.

Seems like a new sandbox mechanism prevents injection from accessing files, and whenever I change a source file, I am getting this message:
image

Pressing Allow doesn't help, the pop-up just appear again and again.

I've seen a thread about a similar issue in the Zoom app forums, see https://community.zoom.com/t5/Meetings/Zoom-would-like-to-access-data-from-other-apps-macOS-14-Sonoma/m-p/140967.
It seems like the correct solution will be to allow full disk access to InjectionIII. However, setting this in the security preferences of the Mac does not help. (I suspect that the InjectionIII executable that causes the OS to show this message is not the same one as the one the OS grants the permissions, but I am not sure about it.)

[Help / Question] - Get initial injection working

Heya! Happy to say I'm finally able to give this a shot on a new project.

Hopefully this is just a quick question or setup detail, but it seems like I just can't get the injection bundle to come up, or the original .app service to find the running app to inject to. Essentially, in following the examples in this doc (and even using the prepare project feature in the .app), nothing seems to log to the console. I haven't done much beyond a few retries, a few manual bundle loads outside of the preparation tool, but no dice there.

This is usually a case where some small setup detail is missed just misconfigured. For instance, I've got the special linker/interposable flags included, but that doesn't mean some other flags aren't messing with it at compile or runtime.

Any chance you might have some low-hanging-fruit things to check that you've run into before? Specifically, what might be causing the bundle to not get to the point of logging to the console? Happy to share some more details if it helps, as I didn't want to drop a bunch of logs to ask you to get deep into a debugging session, lol.

Thanks again for this and your other tools, and many times in advance for your time!

INJECTION_III_APP not defined

when I tried add HotReload as a swift package in my own demo I found INJECTION_III_APP is not defined, thus device injection with InjectionIII app does not work

Will the DDHotKey affect the file watch ?

I use the DDHotKey with command + s in HotReloading as a package, but found it will affect the File Watcher, it cannt get the callback when command + s triggered. I didnt figure out how it happed.

Hot reloading not changing my views

Hello, thank you a lot for your work, it is amazing!
Help me please to setup your built with HotReloading, because it is not working for me

So my steps is below:

  1. Installed last version of https://github.com/johnno1962/InjectionIII in /Applications directory
  2. launch the InjectionIII app and select "Open project" with the root of my project
  3. Add flags "-Xlinker -interposable" to all targets
  4. Add swift package with "https://github.com/johnno1962/HotReloading" (only first)

5) Run project

But after launch Mac status bar Injection app do not change color from blue to orange.
In terminal I see only "HotReloading available for sources under ["projectPath"]"
But when I modify and save some file I see error
1

What is wrong? My Xcode is 14.3. Project is a Swift UIKit
Also I tried to move project from /Documents directory, but it is not fixing
Whole Module Optimisation is disabled by default (I building debug for simulator)
2

Also I tried to make with another ways

  1. instead of steps 4,5 I add
    Bundle(path: "/Applications/InjectionIII.app/Contents/Resources/iOSInjection.bundle")?.load()
    and after this it is texts in console about injections without errors. But there is no any changes in View
    As I understand injection is success, but view is not reloaded and I need to do it with my code (it is not convenient)

  2. instead steps 4,5 I used this add-on library https://github.com/krzysztofzablocki/Inject
    And it is works. As I understand his code clearly - he just reloading views after success injections

Am I right, that your "HotReloading" also made for updates view in simulator without any code updates?
Because if true, the it is better for me to use your implementation as a main developer of this great technology. You will change how I will write my code
Also in krzysztofzablocki/Inject i also need to change some code for UI become changing in simulator, but in your [HotReloading] guide I do not need change any code

EXC_BAD_ACCESS in SwiftSweeper

Hi,

recently I started often getting this crash in line 224 of SwiftSweeper pretty randomly, don't know what triggers it.

if let obj = $0.pointee { SwiftSweeper.current?.sweepInstance(obj) }

It was happening with Xcode 13.3 and 13.3.1 now, using HotReloading Swift package v4.3.15.

Do you have any suggetions what to try and how to investigate?

Connection refused

InjectionClient/Could not connect: Connection refused
🔥 ⚠️ HotReloading loaded but could not connect to 172.22.155.24. Is injectiond running?

Support for custom Xcode app path

Hello @johnno1962,

I'd like to make Support for custom Xcode app path.
I've found the solution with symlink but unfortunately this solution is doesn't work for me.
That's why I've already prepared a branch with changes but it seems I don't have enough permissions to push it and propose a pull request (receiving 403).
BTW in order this feature to be done, I'll need to prepose one pull request to this repository and one more to InjectionIII (I've prepared changes to both repos)

Could you please advise me on this question? 🙏
Looking forward to your help!

Best regards,
Leonid

HotReloading as a Carthage dependency

Hi @johnno1962
I wanted to use hot reloading in my app but since we are using SPM is there any way to make it available in debug mode only and avoid it being shipped in release.

If we have hotreloading as a carthage dependency, we can include it as a debug only framework. Just a suggestion

device injection build error in Xcode14

Hi~
John, thanks for your work! HotReloading is amazing, specially after supporting device injection.

but, I am trying use SPM to integrate HotReloading to my project,, but the project built failed,
the error message like this:
.../SourcePackages/checkouts/HotReloading/Sources/injectiondGuts/SignerService.m:31:9: error build: 'system' is unavailable: not available on iOS
.../SourcePackages/checkouts/HotReloading/Sources/injectiondGuts/SignerService.m:31:9: error build: 'system' is unavailable: not available on iOS

Am I missing something in the setup?

Xcode version: 14.0
Device info: iPhone8P, iOS 16.0.2

my project && HotReloading
图片

error info:
图片

What to do if I don't see any message in the console?

You should see a message that the app has connected and which directories it is watching for source file changes.

I'm pretty sure I've followed the steps correctly. I might be wrong tho. The main difference I found from my project and the demo project is that I don't use SwiftUI.

Any help is greatly appreciated 🙏🏽

There is an error in using xcode 13 according to the operation in the video

video link: https://twitter.com/sir_kif/status/1368644206789615617
xcode: Version 13.0 (13A233)

Multiple commands produce '/Users/admin/Library/Developer/Xcode/DerivedData/HotSwiftUI-bphptxjidulartdyzngcqjbfxuid/Build/Intermediates.noindex/HotSwiftUI.build/Debug-iphonesimulator/HotSwiftUI.build/Objects-normal/arm64/HotSwiftUI.swiftmodule':

  1. Target 'HotSwiftUI' (project 'HotSwiftUI') has compile command for Swift source files
  2. Target 'HotSwiftUI' (project 'HotSwiftUI') has compile command for Swift source files
    image

build fail

Some questions about the implementation.

The project HotReloading 's Contents should be modify from InjectionIII ?
image
I tried build the InjectionsIII, copy the nib files in the InjectionsIII app, but it didn't work.
I am curious how it works. Thanks.

Custom script fails on build

On the Swift-UI example I get the following error from the custom script.

/Users/mobiledev/Library/Developer/Xcode/DerivedData/SwiftUI_Kit-amdktjtsrlmmqvegotnwvbfufrky/SourcePackages/checkouts/HotReloading/Sources/HotReloadingGuts/ClientBoot.mm:14:9: fatal error: 'XCTest/XCTest.h' file not found
#import <XCTest/XCTest.h>

image

I am also getting the following warnings when building hotreload:
image

and the following error for IOS:
image

Can't run directly when running on a real machine

It works well on the iOS simulator,
but it can't run on the real machine.
It reported the following error:
dyld: Library not loaded: @rpath/SwiftTrace.framework/SwiftTrace Referenced from: /private/var/containers/Bundle/Application/99A71CEB-0F14-480C-9672-A7308B02F412/HotReloadTest.app/Frameworks/HotReloading.framework/HotReloading Reason: image not found dyld: launch, loading dependent libraries DYLD_LIBRARY_PATH=/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/usr/lib/libMainThreadChecker.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib
The framework is Already embed , I don't know how can run it successfully.
image

Hot reloading failing on real iOS device

Seems like I can't get hot reloading to work on my iOS device.

Setup:

  • iPhone 14 Pro running iOS 16.5 (20F66)
  • macOS 13.4.1 (22F82) (M1 Pro)
  • XCode 14.3 (14E222b)

What I've done:

  • Downloaded and installed InjectionIII (latest version: 4.7.0).
  • Added this library to my new Swift project
image
  • Added the linker flags
image
  • Ran defaults write com.johnholdsworth.InjectionIII deviceUnlock any

  • Added an environment variable to my scheme with my computer local IP

image
  • Added the Run Script/Build Phase
image

I can see it being set when reading from the terminal:

➜  ~ defaults read com.johnholdsworth.InjectionIII
{
    "/Users/adrien.baron/perso/volumizer-new/Volumizer/Volumizer.xcodeproj" = 55B1F64367A6DB4244C5D555C6062DAC71AF1B7F;
    deviceInform = Informed;
    deviceUnlock = any;
    lastProject = "/Users/adrien.baron/perso/volumizer-new/Volumizer/Volumizer.xcodeproj";
    lastWatched = "/Users/adrien.baron/perso/volumizer-new/Volumizer";
}

What I'm seeing:
App starts on the phone, and connect successfully to the InjectionIII app:

🔥 HotReloading connected /Users/adrien.baron/perso/volumizer-new/Volumizer/Volumizer.xcodeproj
🔥 Watching files under the directory /Users/adrien.baron/perso/volumizer-new/Volumizer
🔥 Compiling /Users/adrien.baron/perso/volumizer-new/Volumizer/Volumizer/ContentView.swift
2023-06-25 11:14:07.631726+0100 Volumizer[7136:673478] 🔥 ***** Tests bundle wasn't found - did you run the tests target before running the application?

It does warn about test bundles, but I don't have test for this app yet (so assuming this is unrelated).

What fails:
When I do some change to the code, the app rebuilds but complains about .dylib having invalid code signing:

🔥 Loading .dylib ...
🔥 ⚠️ dlopen() error: dlopen(/private/var/mobile/Containers/Data/Application/2688C0CC-2A9A-4173-A62D-F7A418E59BE7/tmp/eval101.dylib, 0x0002): tried: '/usr/lib/system/introspection/eval101.dylib' (no such file, not in dyld cache), '/private/var/mobile/Containers/Data/Application/2688C0CC-2A9A-4173-A62D-F7A418E59BE7/tmp/eval101.dylib' (code signature invalid in <A283E7DA-CBDA-3FC0-9668-CB1F5168D485> '/private/var/mobile/Containers/Data/Application/2688C0CC-2A9A-4173-A62D-F7A418E59BE7/tmp/eval101.dylib' (errno=1) sliceOffset=0x00000000, codeBlobOffset=0x0001B8B0, codeBlobSize=0x00004E30), '/private/preboot/Cryptexes/OS/private/var/mobile/Containers/Data/Application/2688C0CC-2A9A-4173-A62D-F7A418E59BE7/tmp/eval101.dylib' (no such file), '/private/var/mobile/Containers/Data/Application/2688C0CC-2A9A-4173-A62D-F7A418E59BE7/tmp/eval101.dylib' (code signature invalid in <A283E7DA-CBDA-3FC0-9668-CB1F5168D485> '/private/var/mobile/Containers/Data/Application/2688C0CC-2A9A-4173-A62D-F7A418E59BE7/tmp/eval101.dylib' (errno=1) sliceOffset=0x00000000, codeBlobOffset=0x0001B8B0, codeBlobSize=0x00004E30)
🔥 ⚠️ Loading .dylib has failed due to invalid code signing.
🔥 Add the following as a Run Script/Build Phase:
defaults write com.johnholdsworth.InjectionIII "$PROJECT_FILE_PATH" "$EXPANDED_CODE_SIGN_IDENTITY"

Nothing I've tried so far seemed to have made any difference, but I also can't find anyone online having this issue, am I holding it wrong 😅?

Note
I sadly can't use the simulator while working as I'm using RoomPlan and it doesn't run in a simulator

cold start on device encounter watch dog

My project is a little complicated. And When I use HotReloading as a package on device, it encounter watch dog when the app cold launch, and after the first watch dog, cold launch the app again immediately can just work as normal. The key information of the crash log is as below. But the premain time is just 3-4 seconds. So I just cannot figure out what happened, is there anything I missed with the SwiftTrace ?

Exception Type:  EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Termination Reason: Namespace SPRINGBOARD, Code 0x8badf00d
Termination Description: SPRINGBOARD, <RBSTerminateContext| domain:10 code:0x8BADF00D explanation:process-launch watchdog transgression: application:416 exhausted real (wall clock) time allowance of 20.00 seconds | ProcessVisibility: Foreground | ProcessState: Running | WatchdogEvent: process-launch | WatchdogVisibility: Foreground | WatchdogCPUStatistics: ( | "Elapsed total CPU time (seconds): 24.170 (user 24.170, system 0.000), 20% CPU", | "Elapsed application CPU time (seconds): 19.736, 16% CPU" | ) reportType:CrashLog maxTerminationResistance:Interactive>
Triggered by Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libobjc.A.dylib               	0x00000001a4cbdaf0 0x1a4caa000 + 80624
1   libobjc.A.dylib               	0x00000001a4cbdbf8 0x1a4caa000 + 80888
2   libobjc.A.dylib               	0x00000001a4cbd7a4 0x1a4caa000 + 79780
3   libobjc.A.dylib               	0x00000001a4cbd0a0 0x1a4caa000 + 77984
4   libdyld.dylib                 	0x00000001910f4124 0x1910e4000 + 65828
5   libdyld.dylib                 	0x00000001910e6e7c 0x1910e4000 + 11900
6   libdyld.dylib                 	0x00000001910f3bf8 0x1910e4000 + 64504
7   libdyld.dylib                 	0x0000000191110d5c 0x1910e4000 + 183644
8   dyld                          	0x0000000143afd248 0x143af4000 + 37448
9   dyld                          	0x0000000143afb16c 0x143af4000 + 29036
10  dyld                          	0x0000000143af5208 0x143af4000 + 4616
11  dyld                          	0x0000000143af5038 0x143af4000 + 4152

Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x0000000000000080   x1: 0x000000016d2d3ef8   x2: 0x00000001e6f644d0   x3: 0x000000019fd86ef4
    x4: 0x0000000000000000   x5: 0x00000001a4cde79e   x6: 0x00000001cb54d240   x7: 0x00000001cb54ca69
    x8: 0x0000000000000006   x9: 0x000000000000000c  x10: 0x0000000000000180  x11: 0x00000001e6f644d0
   x12: 0x000000000000007f  x13: 0x000000000000007f  x14: 0x0000000000000018  x15: 0x0000000000000000
   x16: 0xffffffffffffffff  x17: 0x0000000000000005  x18: 0x0000000000000000  x19: 0x00000001e5a44a80
   x20: 0x000000016d2d3fa0  x21: 0x00000001a4cdec3b  x22: 0x00000001e5a48718  x23: 0x00000001dbb18698
   x24: 0x00000001e6f644a8  x25: 0x0000000000000007  x26: 0x00000001e7c98000  x27: 0x00000001910f4048
   x28: 0x00000001deeeeb80   fp: 0x000000016d2d3f90   lr: 0x00000001a4cbdbf8
    sp: 0x000000016d2d3f30   pc: 0x00000001a4cbdaf0 cpsr: 0x20000000
   esr: 0x92000007 (Data Abort) byte read Translation fault

Binary Images:
0x102b28000 - 0x11264ffff my_project arm64  <b4abc4da851033c99ef14fbe4a654447> /var/containers/Bundle/Application/B244B3B1-783C-4BC5-A424-0173BD741923/my_project.app/my_project
0x14390c000 - 0x14399bfff SwiftTrace arm64  <9e31da64c2253258b26a948d55da7313> /var/containers/Bundle/Application/B244B3B1-783C-4BC5-A424-0173BD741923/my_project.app/Frameworks/SwiftTrace.framework/SwiftTrace

Crashing on injecting to device

App crashes immediately after hitting save. Its a swift project based on UIKit running on a iOS device.

🔥 HotReloading connected /Users/denilct/Documents/Sharechat/HotReload/HotReload.xcodeproj
🔥 Watching files under the directory /Users/denilct/Documents/Sharechat/HotReload
🔥 💉 ⚠️ Your project file seems to be in the Desktop or Documents folder and may prevent InjectionIII working as it has special permissions.
🔥 Compiling /Users/denilct/Documents/Sharechat/HotReload/HotReload/ViewController.swift
🔥 Loaded .dylib - Ignore any duplicate class warning ⬆️
🔥 Interposed 2 function references.
🔥 ⚠️ Number of class refs 2 does not equal []
🔥 Injected type #1 'HotReload.ViewController'
objc[1025]: Attempt to use unknown class 0x109db0340.
import UIKit

class ViewController: UIViewController {
    let label = UILabel(frame: CGRect(x: 30, y: 200, width: 200, height: 150))

    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = .red
        view.addSubview(label)
        label.text = "hello"
        // Do any additional setup after loading the view.
    }
    
    
    @objc func injected() {
        view.backgroundColor = UIColor.yellow
        label.text = "anyoooo"
        label.backgroundColor = .red
        view.layoutIfNeeded()
    }
}

Same code works fine for simulator, but crashes on device on hitting save.

image

Cannot reload on M1, getting an “eval101.dylib” can’t be opened because Apple cannot check it for malicious software error.

I've been trying to use HotReloading for an iOS app when running on an Apple Silicon target ("My Mac (Designed for iPhone)").

Whenever I change the a file and the reloading is initiated, I get a security error from my mac saying
“eval101.dylib” can’t be opened because Apple cannot check it for malicious software."

What should I do? is there something I can change in the Package.swift to make my mac recognize this dylib as trusted?

Could not locate compile command for storyboard

Hi,

I've been struggling for last few days with storyboard hot reloading. I have an older test project where it works just fine, but now with a newly created one with Xcode 13.3 and only HotReloading added by SPM I can't make it work, always getting that error "Could not locate compile command for storyboard"

That generated command.sh doesn't give any output (you should also give that file +x permission when automatically created).

I thought that Xcode project format could be the reason so I've tried setting it to an older 9.3 compatible, but that didn't help also. I can see that no optimization is turned on (completely new test project, just HotReloading added, linker flags too, tried with and without that run script that starts daemon, injecting from code works ok) and the path should not be a problem, I guess. Do you have any suggestions how to investigate what could be the issue?

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.

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.

use HotReloading SPM in .xcworkspace cocopods project

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.