Skip to content
This repository was archived by the owner on Mar 11, 2024. It is now read-only.

Commit ab10eaf

Browse files
committed
Re-instate copyable device bundles.
1 parent 119af19 commit ab10eaf

File tree

4 files changed

+44
-12
lines changed

4 files changed

+44
-12
lines changed

InjectionIII/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<key>CFBundleShortVersionString</key>
2020
<string>$(MARKETING_VERSION)</string>
2121
<key>CFBundleVersion</key>
22-
<string>7995</string>
22+
<string>7997</string>
2323
<key>LSApplicationCategoryType</key>
2424
<string>public.app-category.developer-tools</string>
2525
<key>LSMinimumSystemVersion</key>

InjectionIII/build_bundles.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Created by John Holdsworth on 04/10/2019.
77
# Copyright © 2019 John Holdsworth. All rights reserved.
88
#
9-
# $Id: //depot/ResidentEval/InjectionIII/build_bundles.sh#88 $
9+
# $Id: //depot/ResidentEval/InjectionIII/build_bundles.sh#89 $
1010
#
1111

1212
# Injection has to assume a fixed path for Xcode.app as it uses
@@ -44,6 +44,8 @@ function build_bundle () {
4444
#build_bundle macOS MacOSX macosx &&
4545
if [ "$(hostname)" != "Johns-MacBook-Air.local" ]; then
4646
build_bundle xrOS XRSimulator xrsimulator
47+
build_bundle tvdevOS AppleTVOS appletvos
48+
build_bundle xrdevOS XROS xros
4749
fi
4850
build_bundle iOS iPhoneSimulator iphonesimulator &&
4951
build_bundle tvOS AppleTVSimulator appletvsimulator &&

README.md

+39-9
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,13 @@ or removing methods as the `vtable` used for dispatch is
7474
itself a data structure which must not change over injection.
7575
Injection also can't work out what pieces of code need to
7676
be re-executed to update the display as discussed above.
77-
Finally, Injection doesn't cope well with source files being
78-
added/renamed/deleted during injection. You will need to
77+
Also, don't get carried away with access control. `private`
78+
properties and methods can't be injected directly, particularly
79+
in extensions as they are not a `global` interposable symbol.
80+
They generally inject indirectly as they can only be acessed
81+
inside the file being injected but this can cause confusion.
82+
Finally, Injection doesn't cope well with source files being
83+
added/renamed/deleted during injection. You may need to
7984
build and relaunch your app or even close and reopen
8085
your project to clear out old Xcode build logs.
8186

@@ -134,18 +139,41 @@ of the InjectionIII.app, set a user default to opt-in and restart the app.
134139
```
135140
$ defaults write com.johnholdsworth.InjectionIII deviceUnlock any
136141
```
137-
Then, instead of loading the injection bundles add the following
138-
Swift Package to your project (*only during development*):
139-
[HotReloading project](https://github.com/johnno1962/HotReloading).
140-
This contains details on how to debug having your program connect to the
142+
Then, instead of loading the injection bundles run this script in a "Build Phase":
143+
(You may also need to turn off the project build setting "User Script Sandboxing")
144+
145+
```
146+
RESOURCES=/Applications/InjectionIII.app/Contents/Resources
147+
if [ -f "$RESOURCES/copy_bundle.sh" ]; then
148+
"$RESOURCES/copy_bundle.sh"
149+
fi
150+
```
151+
and, in your application execute the following code on startup:
152+
153+
```
154+
#if DEBUG
155+
if let path = Bundle.main.path(forResource:
156+
"iOSInjection", ofType: "bundle") ??
157+
Bundle.main.path(forResource:
158+
"macOSInjection", ofType: "bundle") {
159+
Bundle(path: path)!.load()
160+
}
161+
#endif
162+
```
163+
Once you have switched to this configuaration it will also
164+
work when using the simulator. Consult the README of the
165+
[HotReloading project](https://github.com/johnno1962/HotReloading)
166+
for details on how to debug having your program connect to the
141167
InjectionIII.app over Wi-Fi. You will also need to select the project
142168
directory for the file watcher manually from the pop-down menu.
143169

144170
### Injection on macOS
145171

146172
It works but you need to temporarily turn off the "app sandbox" and
147173
"library validation" under the "hardened runtime" during development
148-
so it can dynamically load code.
174+
so it can dynamically load code. In order to avoid codesigning problems,
175+
use the new `copy_bundle.sh` script as detailed in the instructions for
176+
injection on an iOS device above.
149177

150178
### How it works
151179

@@ -209,7 +237,9 @@ file system to be a faithful simulation of a real device.
209237
and because you cannot load a bundle off your Mac's filesystem on a real
210238
phone you add the [HotReloading Swift Package](https://github.com/johnno1962/HotReloading)
211239
to your project (during development only!) which contains all the code that
212-
would normally be in the bundle to perform the dynamic loading.
240+
would normally be in the bundle to perform the dynamic loading. This
241+
requires that you use one of the un-sandboxed binary releases. It has
242+
also been replaced by the `copy_bundle.sh` script described above.
213243

214244
"Standalone injection". This was the most recent evolution of the project
215245
where you don't run the app itself anymore but simply load one of the
@@ -268,4 +298,4 @@ for the code to be evaluated using injection under an MIT license.
268298

269299
The fabulous app icon is thanks to Katya of [pixel-mixer.com](http://pixel-mixer.com/).
270300

271-
$Date: 2024/03/06 $
301+
$Date: 2024/03/07 $

0 commit comments

Comments
 (0)