Comments (21)
No, you have been most helpful, John. I might have been unclear; I've gotten it to work β here's a demo; hopefully it'll been useful to others https://github.com/hboon/MacOSWithInjectionIII/
from injectioniii.
Hi, Can you try turning off the sandbox?
from injectioniii.
Hi John! I read in the docs to turn off ENABLE_APP_SANDBOX
(it's already off for me) and I also turned off ENABLED_USER_SCRIPT_SANDBOXING
, but I forgot where I read about it.
Both are off for the console out above.
from injectioniii.
You're not running the app? Do you have a WORKSPACE file somewhere? You seemed to have turned on the Bazel support.
from injectioniii.
The output is for when the app is not running. It would say connected if it is, but still shows the same Bazel related errors. The directory (that I would choose in InjectionIII if it's running) looks like this:
I renamed the project.yml
just in case. Oh, could it be buildServer.json
?
from injectioniii.
Nope, remaining buildServer.json
still triggers the same error.
from injectioniii.
Is there an example where it works with macOS? I found a couple for iOS which worked for me and I used to use it with iOS.
from injectioniii.
Not that I'm aware of. The best thing you could do at this stage is to create a new macOS app without sandbox and get things running and then work your way back to your app.
from injectioniii.
Thanks. I started a fresh project with Xcode's macOS wizard and did it step by step and got a different error below:
-
Add to OTHER_LDFLAGS:
OTHER_LDFLAGS = ( "-Xlinker", "-interposable", );
-
Add Injection package:
https://github.com/krzysztofzablocki/Inject.git
- Run InjectionIII and choose the project directory
Run project and still nothing in the console
- Add import Inject, @ObserveInjection var, .enableInjection()
Run project and still nothing in the console. But it complains about team and platform ID and signature
-
ENABLE_USER_SCRIPT_SANDBOXING = NO
-
Add Run Script build phase
RESOURCES=/Applications/InjectionIII.app/Contents/Resources
if [ -f "$RESOURCES/copy_bundle.sh" ]; then
"$RESOURCES/copy_bundle.sh"
fi
Complains falling back to standalone mode but wouldn't because we are using Injection
- Add INJECTION_STANDALONE as scheme's env var
Getting:
InjectionClient/Could not connect: Operation not permitted
π Unable to connect to InjectionIII app, falling back to standalone HotReloading.
π Standalone InjectionIII available for sources under ["/Users/hboon"]
π Using logs: /Users/hboon/Library/Developer/Xcode/DerivedData/Foo-cjazpklsqoadreakjxbqxfoaivdf/Logs/Build/1A16774D-8E6B-4A21-8EB7-C6FA219A8E98.xcactivitylog.
ls: *.xcactivitylog: No such file or directory
π β οΈ Could not locate compile command for "/Users/hboon/Desktop/Foo/Foo/ContentView.swift" in /Users/hboon/Library/Developer/Xcode/DerivedData/Foo-cjazpklsqoadreakjxbqxfoaivdf/Logs/Build/.
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/hboon/Library/Containers/com.motionobj.Foo/Data/tmp/command.sh".
I've verified this file exists and is non-empty: /Users/hboon/Library/Developer/Xcode/DerivedData/Foo-cjazpklsqoadreakjxbqxfoaivdf/Logs/Build/1A16774D-8E6B-4A21-8EB7-C6FA219A8E98.xcactivitylog
This path is the source file I have modified: /Users/hboon/Desktop/Foo/Foo/ContentView.swift
- Injection does not work with Whole Module Optimization.
It's disabled
- There are restrictions on characters allowed in paths.
Is this the source path "/Users/hboon/Desktop/Foo/Foo/ContentView.swift"? Seems OK
- File paths in the simulator are case sensitive.
macOS, but looks OK?
- The modified source file is not in the current project.
It is
- The source file is an XCTest that has not been run yet.
Nope.
- Xcode has removed the build logs. Edit a file and re-run.
Try a build clean then rebuild to make logs available or
Tried while observing the Build/
mentioned above.
Any idea what to look for or troubleshoot? If you don't mind looking, I've pushed the repo to https://github.com/hboon/Foo (unfortunately I wasn't planning to publish this when I created it, so please excuse the dirty commits and repo name)
from injectioniii.
Can you try moving your project out of the Desktop folder. The has special permissions which sometimes cause problems.
from injectioniii.
You may be better off running the app rather than using "standalone" injection.
from injectioniii.
I tried again, this time with a fresh project that is somewhere in my ~/Documents/
directory. Didn't use the Injection
package. But it complains that it's falling back to HotReloading and I get the bazel related error again.
InjectionClient/Could not connect: Operation not permitted
π Unable to connect to InjectionIII app, falling back to standalone HotReloading.
π Standalone InjectionIII available for sources under ["/Users/hboon"]
π Using logs: /Users/hboon/Library/Developer/Xcode/DerivedData/InjectionIIIOnly-cfoanmnxxryrsvcoeekictbqsety/Logs/Build/8B392C78-F37A-41D3-A5DF-5A901AFC4CAA.xcactivitylog.
π β οΈ Locating response file failed (see: /Users/hboon/Library/Containers/com.motionobj.InjectionIIIOnly/Data/tmp/command.sh)
/Users/hboon/Library/Containers/com.motionobj.InjectionIIIOnly/Data/tmp/command.sh: line 2: cd: /Users/hboon/Documents/bazel-out/../external/build_bazel_rules_swift: No such file or directory
Checking patch tools/worker/swift_runner.cc...
error: tools/worker/swift_runner.cc: No such file or directory
Checking patch tools/worker/swift_runner.h...
error: tools/worker/swift_runner.h: No such file or directory
Here's what I tried:
- Load bundle in app:
#if DEBUG
Bundle(path: "/Applications/InjectionIII.app/Contents/Resources/macOSInjection.bundle")?.load()
#endif
- Add to OTHER_LDFLAGS:
OTHER_LDFLAGS = (
"-Xlinker",
"-interposable",
);
-
ENABLE_USER_SCRIPT_SANDBOXING = NO
-
Add Run Script build phase
RESOURCES=/Applications/InjectionIII.app/Contents/Resources
if [ -f "$RESOURCES/copy_bundle.sh" ]; then
"$RESOURCES/copy_bundle.sh"
fi
- Modified code in step 1 to:
if let path = Bundle.main.path(forResource: "iOSInjection", ofType: "bundle") ??
Bundle.main.path(forResource: "macOSInjection", ofType: "bundle") {
Bundle(path: path)!.load()
}
What does this mean:
InjectionClient/Could not connect: Operation not permitted
from injectioniii.
Can you try running the app please. That give you control over the project directory and does "fall back". Do you have an environment variable INJECTION_BASEL or a user default "bazelLight set?
from injectioniii.
InjectionClient/Could not connect: Operation not permitted
This means you still have the sandbox turned on.
from injectioniii.
Can you try running the app please.
The app is running. I also chose the project directory with Open Project
.
InjectionClient/Could not connect: Operation not permitted
This means you still have the sandbox turned on.
I verified that ENABLE_USER_SCRIPT_SANDBOXING and ENABLE_APP_SANDBOX are off for the target, is there another option I might have missed?
Do you have an environment variable INJECTION_BASEL or a user default "bazelLight set?
I did:
$ defaults read > foo
and these returned 0 hits:
$ ag injection_ba foo
$ ag bazel foo
Not for these too:
$ echo $INJECTION_BASEL
$ echo $INJECTION_BAZEL
Not set in the scheme's env var too.
The first part of these file /Users/hboon/Library/Containers/com.motionobj.InjectionIIIOnly/Data/tmp/command.sh
is puzzling perhaps? β
# search through bazel args, most recent first
cd "/Users/hboon/Documents/bazel-out/../external/build_bazel_rules_swift" 2>"/Users/hboon/Library/Containers/com.motionobj.InjectionIIIOnly/Data/tmp/eval101.err" &&
grep module_name_ tools/worker/swift_runner.h >/dev/null 2>>"/Users/hboon/Library/Containers/com.motionobj.InjectionIIIOnly/Data/tmp/eval101.err" ||
(git apply -v <<'BAZEL_PATCH' 2>>"/Users/hboon/Library/Containers/com.motionobj.InjectionIIIOnly/Data/tmp/eval101.err" && echo "β οΈ bazel patched, restart app" >>"/Users/hboon/Library/Containers/com.motionobj.InjectionIIIOnly/Data/tmp/eval101.err" && exit 1) &&
diff --git a/tools/worker/swift_runner.cc b/tools/worker/swift_runner.cc
index 535dad0..19e1a6d 100644
--- a/tools/worker/swift_runner.cc
+++ b/tools/worker/swift_runner.cc
from injectioniii.
If you are still seeing "Operation not permitted" instead of "Connection refused", the sandbox is still on.
from injectioniii.
Heads-up in case you think about it. This from #177 (comment) helped:
<key>com.apple.security.network.client</key>
<true/>
I'm not sure if clearing ENABLE_HARDENED_RUNTIME
was also needed, but I'll do a fresh one and see if we can get a template goingβ¦
from injectioniii.
If you needed that option you still have the sandbox switched on. Injection without using the app (standalone) won't work with the sandbox switched on. Are you running the app now?
from injectioniii.
Not exactly sure what you mean, but this is the combo that works for me:
InjectionIII running + ENABLE_HARDENED_RUNTIME=off + the entitlement
I can't get standalone to work.
from injectioniii.
(I looked for all options that has "harden" or "sandbox" and made sure they were off)
from injectioniii.
My friend, I can't spend any more time on this. If injection works for iOS then stick to that. macOS is much more difficult to get running particularly standalone and we don't seem to be making any progress. My last piece of advice is you should try to get it working with a GitHub download of the app and make sure the sandbox is off in your app.
from injectioniii.
Related Issues (20)
- Error loading, when using mac target HOT 3
- Crash on reload every time HOT 6
- Loading .dylib has failed HOT 15
- EOF received from server.. HOT 2
- Is there a way to make injected macOS app not become active when it's reloaded? HOT 2
- Re-compilation failed HOT 5
- InjectionClient/Could not connect: Connection refused π₯ HOT 18
- Hello, I reported the error when I used the real machine to debug, looking forward to your answer, thank you HOT 6
- Meaning of colors HOT 2
- It doesn't work on Xcode 15.3 iOS 17.4 HOT 14
- It doesn't work on xcode 15.3 (15E204a) HOT 7
- Loading .dylib has failed HOT 1
- TCA ObservableState crash HOT 3
- Unknown argument: -interposable HOT 2
- Could not bind service socket: Address already in use HOT 5
- Is support arm mac??? HOT 19
- ld: building for 'iOS', but linking in object file built for 'visionOS-simulator' HOT 5
- dlopen() error: Library not loaded: @rpath/libswift_Concurrency.dylib HOT 15
- SwiftUI `onChange` is not called after injection HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from injectioniii.