Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
lockieluke opened this issue Jul 8, 2024 · 7 comments

Comments

@lockieluke
Copy link

🔥 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?

@johnno1962
Copy link
Owner

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

@bottotl
Copy link

bottotl commented Nov 24, 2024

I'm using iOS 18.1.1, XCode 16.0(16A242d)
I have the error, this issues looks like #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

@johnno1962
Copy link
Owner

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.

@bottotl
Copy link

bottotl commented Nov 24, 2024

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
Copy link

bottotl commented Nov 24, 2024

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

@johnno1962
Copy link
Owner

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

@bottotl
Copy link

bottotl commented Nov 25, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants