@@ -74,8 +74,13 @@ or removing methods as the `vtable` used for dispatch is
74
74
itself a data structure which must not change over injection.
75
75
Injection also can't work out what pieces of code need to
76
76
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
79
84
build and relaunch your app or even close and reopen
80
85
your project to clear out old Xcode build logs.
81
86
@@ -134,18 +139,41 @@ of the InjectionIII.app, set a user default to opt-in and restart the app.
134
139
```
135
140
$ defaults write com.johnholdsworth.InjectionIII deviceUnlock any
136
141
```
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
141
167
InjectionIII.app over Wi-Fi. You will also need to select the project
142
168
directory for the file watcher manually from the pop-down menu.
143
169
144
170
### Injection on macOS
145
171
146
172
It works but you need to temporarily turn off the "app sandbox" and
147
173
"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.
149
177
150
178
### How it works
151
179
@@ -209,7 +237,9 @@ file system to be a faithful simulation of a real device.
209
237
and because you cannot load a bundle off your Mac's filesystem on a real
210
238
phone you add the [ HotReloading Swift Package] ( https://github.com/johnno1962/HotReloading )
211
239
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.
213
243
214
244
"Standalone injection". This was the most recent evolution of the project
215
245
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.
268
298
269
299
The fabulous app icon is thanks to Katya of [ pixel-mixer.com] ( http://pixel-mixer.com/ ) .
270
300
271
- $Date: 2024/03/06 $
301
+ $Date: 2024/03/07 $
0 commit comments