HotReloading icon indicating copy to clipboard operation
HotReloading copied to clipboard

App on a Real iPhone fails to inject generated DYLIBS due to codesign issues

Open lockieluke opened this issue 1 year ago β€’ 1 comments

πŸ”₯ Sending broadcast packet to connect to your development host Sherlocks-Air.
πŸ”₯ If this fails, hardcode your Mac's IP address in HotReloading/Package.swift
   or add an environment variable INJECTION_HOST with this value.
πŸ”₯ You'll need to be running a recent copy of the InjectionIII.app downloaded from https://github.com/johnno1962/InjectionIII/releases
πŸ”₯ And have typed: defaults write com.johnholdsworth.InjectionIII deviceUnlock any
Broadcasting to pdp_ip0.3:100.66.120.234 to locate InjectionIII host...
Broadcasting to ipsec0.10:192.0.0.6 to locate InjectionIII host...
Broadcasting to en0.16:192.168.1.255 to locate InjectionIII host...
Broadcasting to ipsec3.23:192.0.0.6 to locate InjectionIII host...
πŸ”₯ Connecting to Sherlocks-Air (192.168.1.144)...
πŸ”₯ HotReloading connected /Users/sherlockluk/Documents/Proj/Swift/CoverArt/CoverArt.xcodeproj
πŸ”₯ Watching files under the directory /Users/sherlockluk/Documents/Proj/Swift/CoverArt
πŸ”₯ πŸ’‰ ⚠️ Your project file seems to be in the Desktop or Documents folder and may prevent InjectionIII working as it has special permissions.
πŸ”₯ Compiling /Users/sherlockluk/Documents/Proj/Swift/CoverArt/CoverArt/Views/CameraView.swift
πŸ”₯ Loading .dylib ...
πŸ”₯ ⚠️ dlopen() error: dlopen(/private/var/mobile/Containers/Data/Application/CDA99D2C-2406-4733-A312-24E9B44E97C1/tmp/eval101.dylib, 0x0002): tried: '/usr/lib/system/introspection/eval101.dylib' (no such file, not in dyld cache), '/private/var/mobile/Containers/Data/Application/CDA99D2C-2406-4733-A312-24E9B44E97C1/tmp/eval101.dylib' (code signature invalid in <1EF51F23-FFB1-383F-A933-4C3DD40782A2> '/private/var/mobile/Containers/Data/Application/CDA99D2C-2406-4733-A312-24E9B44E97C1/tmp/eval101.dylib' (errno=1) sliceOffset=0x00000000, codeBlobOffset=0x00019AA0, codeBlobSize=0x00004DD0), '/private/preboot/Cryptexes/OS/private/var/mobile/Containers/Data/Application/CDA99D2C-2406-4733-A312-24E9B44E97C1/tmp/eval101.dylib' (no such file), '/private/var/mobile/Containers/Data/Application/CDA99D2C-2406-4733-A312-24E9B44E97C1/tmp/eval101.dylib' (code signature invalid in <1EF51F23-FFB1-383F-A933-4C3DD40782A2> '/private/var/mobile/Containers/Data/Application/CDA99D2C-2406-4733-A312-24E9B44E97C1/tmp/eval101.dylib' (errno=1) sliceOffset=0x00000000, codeBlobOffset=0x00019AA0, codeBlobSize=0x00004DD0)
πŸ”₯ ⚠️ 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"
πŸ”₯ ⚠️ Injection error: Error Domain=SwiftEval Code=-1 "dlopen() error: dlopen(/private/var/mobile/Containers/Data/Application/CDA99D2C-2406-4733-A312-24E9B44E97C1/tmp/eval101.dylib, 0x0002): tried: '/usr/lib/system/introspection/eval101.dylib' (no such file, not in dyld cache), '/private/var/mobile/Containers/Data/Application/CDA99D2C-2406-4733-A312-24E9B44E97C1/tmp/eval101.dylib' (code signature invalid in <1EF51F23-FFB1-383F-A933-4C3DD40782A2> '/private/var/mobile/Containers/Data/Application/CDA99D2C-2406-4733-A312-24E9B44E97C1/tmp/eval101.dylib' (errno=1) sliceOffset=0x00000000, codeBlobOffset=0x00019AA0, codeBlobSize=0x00004DD0), '/private/preboot/Cryptexes/OS/private/var/mobile/Containers/Data/Application/CDA99D2C-2406-4733-A312-24E9B44E97C1/tmp/eval101.dylib' (no such file), '/private/var/mobile/Containers/Data/Application/CDA99D2C-2406-4733-A312-24E9B44E97C1/tmp/eval101.dylib' (code signature invalid in <1EF51F23-FFB1-383F-A933-4C3DD40782A2> '/private/var/mobile/Containers/Data/Application/CDA99D2C-2406-4733-A312-24E9B44E97C1/tmp/eval101.dylib' (errno=1) sliceOffset=0x00000000, codeBlobOffset=0x00019AA0, codeBlobSize=0x00004DD0)
πŸ”₯ ⚠️ 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"" UserInfo={NSLocalizedDescription=dlopen() error: dlopen(/private/var/mobile/Containers/Data/Application/CDA99D2C-2406-4733-A312-24E9B44E97C1/tmp/eval101.dylib, 0x0002): tried: '/usr/lib/system/introspection/eval101.dylib' (no such file, not in dyld cache), '/private/var/mobile/Containers/Data/Application/CDA99D2C-2406-4733-A312-24E9B44E97C1/tmp/eval101.dylib' (code signature invalid in <1EF51F23-FFB1-383F-A933-4C3DD40782A2> '/private/var/mobile/Containers/Data/Application/CDA99D2C-2406-4733-A312-24E9B44E97C1/tmp/eval101.dylib' (errno=1) sliceOffset=0x00000000, codeBlobOffset=0x00019AA0, codeBlobSize=0x00004DD0), '/private/preboot/Cryptexes/OS/private/var/mobile/Containers/Data/Application/CDA99D2C-2406-4733-A312-24E9B44E97C1/tmp/eval101.dylib' (no such file), '/private/var/mobile/Containers/Data/Application/CDA99D2C-2406-4733-A312-24E9B44E97C1/tmp/eval101.dylib' (code signature invalid in <1EF51F23-FFB1-383F-A933-4C3DD40782A2> '/private/var/mobile/Containers/Data/Application/CDA99D2C-2406-4733-A312-24E9B44E97C1/tmp/eval101.dylib' (errno=1) sliceOffset=0x00000000, codeBlobOffset=0x00019AA0, codeBlobSize=0x00004DD0)
πŸ”₯ ⚠️ 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"}
πŸ”₯ Compiling /Users/sherlockluk/Documents/Proj/Swift/CoverArt/CoverArt/Views/CameraView.swift
πŸ”₯ Loading .dylib ...
πŸ”₯ ⚠️ dlopen() error: dlopen(/private/var/mobile/Containers/Data/Application/CDA99D2C-2406-4733-A312-24E9B44E97C1/tmp/eval102.dylib, 0x0002): tried: '/usr/lib/system/introspection/eval102.dylib' (no such file, not in dyld cache), '/private/var/mobile/Containers/Data/Application/CDA99D2C-2406-4733-A312-24E9B44E97C1/tmp/eval102.dylib' (code signature invalid in <06FB8E08-C429-379C-A376-7E40924F224F> '/private/var/mobile/Containers/Data/Application/CDA99D2C-2406-4733-A312-24E9B44E97C1/tmp/eval102.dylib' (errno=1) sliceOffset=0x00000000, codeBlobOffset=0x00019AA0, codeBlobSize=0x00004DD0), '/private/preboot/Cryptexes/OS/private/var/mobile/Containers/Data/Application/CDA99D2C-2406-4733-A312-24E9B44E97C1/tmp/eval102.dylib' (no such file), '/private/var/mobile/Containers/Data/Application/CDA99D2C-2406-4733-A312-24E9B44E97C1/tmp/eval102.dylib' (code signature invalid in <06FB8E08-C429-379C-A376-7E40924F224F> '/private/var/mobile/Containers/Data/Application/CDA99D2C-2406-4733-A312-24E9B44E97C1/tmp/eval102.dylib' (errno=1) sliceOffset=0x00000000, codeBlobOffset=0x00019AA0, codeBlobSize=0x00004DD0)
πŸ”₯ ⚠️ 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"
πŸ”₯ ⚠️ Injection error: Error Domain=SwiftEval Code=-1 "dlopen() error: dlopen(/private/var/mobile/Containers/Data/Application/CDA99D2C-2406-4733-A312-24E9B44E97C1/tmp/eval102.dylib, 0x0002): tried: '/usr/lib/system/introspection/eval102.dylib' (no such file, not in dyld cache), '/private/var/mobile/Containers/Data/Application/CDA99D2C-2406-4733-A312-24E9B44E97C1/tmp/eval102.dylib' (code signature invalid in <06FB8E08-C429-379C-A376-7E40924F224F> '/private/var/mobile/Containers/Data/Application/CDA99D2C-2406-4733-A312-24E9B44E97C1/tmp/eval102.dylib' (errno=1) sliceOffset=0x00000000, codeBlobOffset=0x00019AA0, codeBlobSize=0x00004DD0), '/private/preboot/Cryptexes/OS/private/var/mobile/Containers/Data/Application/CDA99D2C-2406-4733-A312-24E9B44E97C1/tmp/eval102.dylib' (no such file), '/private/var/mobile/Containers/Data/Application/CDA99D2C-2406-4733-A312-24E9B44E97C1/tmp/eval102.dylib' (code signature invalid in <06FB8E08-C429-379C-A376-7E40924F224F> '/private/var/mobile/Containers/Data/Application/CDA99D2C-2406-4733-A312-24E9B44E97C1/tmp/eval102.dylib' (errno=1) sliceOffset=0x00000000, codeBlobOffset=0x00019AA0, codeBlobSize=0x00004DD0)
πŸ”₯ ⚠️ 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"" UserInfo={NSLocalizedDescription=dlopen() error: dlopen(/private/var/mobile/Containers/Data/Application/CDA99D2C-2406-4733-A312-24E9B44E97C1/tmp/eval102.dylib, 0x0002): tried: '/usr/lib/system/introspection/eval102.dylib' (no such file, not in dyld cache), '/private/var/mobile/Containers/Data/Application/CDA99D2C-2406-4733-A312-24E9B44E97C1/tmp/eval102.dylib' (code signature invalid in <06FB8E08-C429-379C-A376-7E40924F224F> '/private/var/mobile/Containers/Data/Application/CDA99D2C-2406-4733-A312-24E9B44E97C1/tmp/eval102.dylib' (errno=1) sliceOffset=0x00000000, codeBlobOffset=0x00019AA0, codeBlobSize=0x00004DD0), '/private/preboot/Cryptexes/OS/private/var/mobile/Containers/Data/Application/CDA99D2C-2406-4733-A312-24E9B44E97C1/tmp/eval102.dylib' (no such file), '/private/var/mobile/Containers/Data/Application/CDA99D2C-2406-4733-A312-24E9B44E97C1/tmp/eval102.dylib' (code signature invalid in <06FB8E08-C429-379C-A376-7E40924F224F> '/private/var/mobile/Containers/Data/Application/CDA99D2C-2406-4733-A312-24E9B44E97C1/tmp/eval102.dylib' (errno=1) sliceOffset=0x00000000, codeBlobOffset=0x00019AA0, codeBlobSize=0x00004DD0)
πŸ”₯ ⚠️ 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"}

I have the following build scripts:

defaults write com.johnholdsworth.InjectionIII $SRCROOT 98E0C49655785E7E247956F9017FD937D4948AE1
RESOURCES=/Applications/InjectionIII.app/Contents/Resources
if [ -f "$RESOURCES/copy_bundle.sh" ]; then
    "$RESOURCES/copy_bundle.sh"
fi

Bundle loaded at launch:

#if DEBUG
        if let path = Bundle.main.path(forResource:
                                        "iOSInjection", ofType: "bundle") ??
            Bundle.main.path(forResource:
                                "macOSInjection", ofType: "bundle") {
            Bundle(path: path)!.load()
        }
#endif

Do I have to self-sign InjectionIII?

lockieluke avatar Jul 08 '24 09:07 lockieluke

Hi, $SRCROOT is wrong where you set the default, it should be "$PROJECT_FILE_PATH"

johnno1962 avatar Jul 11 '24 06:07 johnno1962

I'm using iOS 18.1.1, XCode 16.0(16A242d) I have the error, this issues looks like https://github.com/johnno1962/HotReloading/issues/85 the defaults read com.johnholdsworth.InjectionIII and the codesign of eval103.dylib looks good to me image

And I didn't see any error log on evalxx.err/ evalxx.log image

but I found some error when I run /Applications/InjectionIII.app/Contents/MacOS/InjectionIII on the terminal, does this error matter? image

bottotl avatar Nov 24 '24 12:11 bottotl

Are you adding HotReloading as a Swift Package and are using the copy_bundle.sh script? You do one or the other. But at this stage it's probably better to advise you to move to the newer implementation of injection which is simpler and easier to understand when it comes to injecting a device: https://github.com/johnno1962/InjectionNext.

johnno1962 avatar Nov 24 '24 12:11 johnno1962

Are you adding HotReloading as a Swift Package and are using the copy_bundle.sh script? You do one or the other. But at this stage it's probably better to advise you to move to the newer implementation of injection which is simpler and easier to understand when it comes to injecting a device: https://github.com/johnno1962/InjectionNext.

thx,I will try this project next week, hot reload on real device did helps a lot for me

bottotl avatar Nov 24 '24 12:11 bottotl

my friend say, maybe it's because i'm using a free apple account, I will have a try

bottotl avatar Nov 24 '24 13:11 bottotl

Possibly, not sure you can sign for a real device without a developer account.

johnno1962 avatar Nov 24 '24 14:11 johnno1962

Possibly, not sure you can sign for a real device without a developer account.

I change my apple account to a paid account, it works, no more dlopen error

bottotl avatar Nov 25 '24 05:11 bottotl