Code Monkey home page Code Monkey logo

Comments (21)

hboon avatar hboon commented on June 11, 2024 1

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.

johnno1962 avatar johnno1962 commented on June 11, 2024

Hi, Can you try turning off the sandbox?

from injectioniii.

hboon avatar hboon commented on June 11, 2024

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.

johnno1962 avatar johnno1962 commented on June 11, 2024

You're not running the app? Do you have a WORKSPACE file somewhere? You seemed to have turned on the Bazel support.

from injectioniii.

hboon avatar hboon commented on June 11, 2024

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:

Screenshot 2024-02-11 at 6 05 19β€―PM

I renamed the project.yml just in case. Oh, could it be buildServer.json?

from injectioniii.

hboon avatar hboon commented on June 11, 2024

Nope, remaining buildServer.json still triggers the same error.

from injectioniii.

hboon avatar hboon commented on June 11, 2024

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.

johnno1962 avatar johnno1962 commented on June 11, 2024

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.

hboon avatar hboon commented on June 11, 2024

Thanks. I started a fresh project with Xcode's macOS wizard and did it step by step and got a different error below:

  1. Add to OTHER_LDFLAGS:

     		OTHER_LDFLAGS = (
     			"-Xlinker",
     			"-interposable",
     		);
    
  2. Add Injection package:

https://github.com/krzysztofzablocki/Inject.git

  1. Run InjectionIII and choose the project directory

Run project and still nothing in the console

  1. Add import Inject, @ObserveInjection var, .enableInjection()

Run project and still nothing in the console. But it complains about team and platform ID and signature

  1. ENABLE_USER_SCRIPT_SANDBOXING = NO

  2. 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

  1. 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

  1. Injection does not work with Whole Module Optimization.

It's disabled

  1. There are restrictions on characters allowed in paths.

Is this the source path "/Users/hboon/Desktop/Foo/Foo/ContentView.swift"? Seems OK

  1. File paths in the simulator are case sensitive.

macOS, but looks OK?

  1. The modified source file is not in the current project.

It is

  1. The source file is an XCTest that has not been run yet.

Nope.

  1. 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.

johnno1962 avatar johnno1962 commented on June 11, 2024

Can you try moving your project out of the Desktop folder. The has special permissions which sometimes cause problems.

from injectioniii.

johnno1962 avatar johnno1962 commented on June 11, 2024

You may be better off running the app rather than using "standalone" injection.

from injectioniii.

hboon avatar hboon commented on June 11, 2024

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:

  1. Load bundle in app:
#if DEBUG
Bundle(path: "/Applications/InjectionIII.app/Contents/Resources/macOSInjection.bundle")?.load()
#endif
  1. Add to OTHER_LDFLAGS:
				OTHER_LDFLAGS = (
					"-Xlinker",
					"-interposable",
				);
  1. ENABLE_USER_SCRIPT_SANDBOXING = NO

  2. Add Run Script build phase

RESOURCES=/Applications/InjectionIII.app/Contents/Resources
if [ -f "$RESOURCES/copy_bundle.sh" ]; then
"$RESOURCES/copy_bundle.sh"
fi

  1. 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.

johnno1962 avatar johnno1962 commented on June 11, 2024

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.

johnno1962 avatar johnno1962 commented on June 11, 2024

InjectionClient/Could not connect: Operation not permitted

This means you still have the sandbox turned on.

from injectioniii.

hboon avatar hboon commented on June 11, 2024

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.

johnno1962 avatar johnno1962 commented on June 11, 2024

If you are still seeing "Operation not permitted" instead of "Connection refused", the sandbox is still on.

from injectioniii.

hboon avatar hboon commented on June 11, 2024

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.

johnno1962 avatar johnno1962 commented on June 11, 2024

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.

hboon avatar hboon commented on June 11, 2024

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.

hboon avatar hboon commented on June 11, 2024

(I looked for all options that has "harden" or "sandbox" and made sure they were off)

from injectioniii.

johnno1962 avatar johnno1962 commented on June 11, 2024

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)

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.