├── .gitignore
├── LICENSE
├── README.md
├── dynamicload
├── README.md
├── dynamicload.sln
├── dynloadios
│ ├── AppDelegate.cs
│ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ └── Contents.json
│ ├── Entitlements.plist
│ ├── Info.plist
│ ├── LaunchScreen.storyboard
│ ├── Main.cs
│ ├── Main.storyboard
│ ├── ViewController.cs
│ ├── ViewController.designer.cs
│ ├── dynloadios.csproj
│ └── packages.config
├── fail
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── fail.cs
│ └── fail.csproj
└── pass
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── pass.cs
│ └── pass.csproj
└── subclass
├── README.md
├── customcode
├── CustomProtocol.cs
├── CustomView.cs
├── Properties
│ └── AssemblyInfo.cs
└── customcode.csproj
├── subclass.sln
└── subclass
├── AppDelegate.cs
├── Assets.xcassets
└── AppIcon.appiconset
│ ├── Contents.json
│ ├── Icon1024.png
│ ├── Icon120.png
│ ├── Icon152.png
│ ├── Icon167.png
│ ├── Icon180.png
│ ├── Icon20.png
│ ├── Icon29.png
│ ├── Icon40.png
│ ├── Icon58.png
│ ├── Icon60.png
│ ├── Icon76.png
│ ├── Icon80.png
│ └── Icon87.png
├── Entitlements.plist
├── Info.plist
├── LaunchScreen.storyboard
├── Main.cs
├── Main.storyboard
├── Properties
└── AssemblyInfo.cs
├── Resources
└── LaunchScreen.xib
├── ViewController.cs
├── ViewController.designer.cs
└── subclass.csproj
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .vs
3 | *.userprefs
4 | *.user
5 | *.suo
6 | *.exe
7 | *.dll
8 | *.mdb
9 | *.pdb
10 | bin
11 | obj
12 | packages
13 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Sebastien Pouliot
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # interpreter
2 |
3 | Quick and dirty experiments with Xamarin.iOS and the IL interpreter
4 |
5 | * **dynamicload**: a quick sample that does `Assembly.Load`, `dynamic`, code downloading and `System.Reflection.Emit` - all the things you can't normally do on iOS
6 |
7 | * **subclass**: a specialized sample to validate special optimizations (mostly done by the managed linker) are not interfering, by default, with the interpreter.
8 |
9 |
10 | ## Requirements
11 |
12 | * Xamarin.iOS 12.7.1.x build
13 |
14 | This is a special build that includes
15 | * a `mscorlib.dll` with extra types, so compiling code using `System.Reflection.Emit` is possible;
16 | * a `libmono` runtime including the `System.Reflection.Emit` native code (icalls) for devices;
17 | * a `System.Core.dll` build for the _normal_ dynamic support (not the SLE interpreter);
18 |
19 | The other (experimental) features are already included in Xamarin.iOS 12.6+
20 |
21 |
22 | ## How-to roll your own interpreted application
23 |
24 | 1. Create a new iOS project (or use an existing one);
25 | 2. In the project's options, **iOS Build**, add `--interpreter` to the **Additional mtouch arguments**
26 | 3. Build and deploy to device
27 |
28 |
29 |
30 | ## FAQ
31 |
32 | 1. What happens if I don't provide the `--interpreter` argument ?
33 |
34 | The application will be AOT'ed just like normal Xamarin.iOS applications always have been.
35 |
36 |
37 | 2. What happens if I don't use Xamarin.iOS 12.7.1.x ?
38 |
39 | Some extra features, like `System.Reflection.Emit`, won't be supported.
40 |
41 |
42 | 3. What happens if I use a newer Xamarin.iOS, like 12.8.x+ ?
43 |
44 | Some extra features, like `System.Reflection.Emit`, won't be supported. Xamarin.iOS 12.7.1 is a special build to preview features that will become available in a future stable release.
45 |
46 |
47 | 4. How can I control what's AOT'ed and what's interpreted ?
48 |
49 | ```
50 | --interpreter[=VALUE] Enable the *experimental* interpreter. Optionally
51 | takes a comma-separated list of assemblies to
52 | interpret (if prefixed with a minus sign, the
53 | assembly will be AOT-compiled instead). 'all'
54 | can be used to specify all assemblies. This
55 | argument can be specified multiple times.
56 | ```
57 |
58 |
59 | ## Feedback
60 |
61 | If you are experimenting with this build then come talk to us on our [gitter channel](https://gitter.im/xamarin/xamarin-macios).
62 |
63 | Please report issues on [github issues](https://github.com/xamarin/xamarin-macios/issues/new) and include all the requested information.
64 |
--------------------------------------------------------------------------------
/dynamicload/README.md:
--------------------------------------------------------------------------------
1 | # DynamicLoad
2 |
3 | This sample shows
4 |
5 | * the use of C# `dynamic`, both a
6 | - working case, `pass.dll`; and
7 | - an incomplete assembly `fail.dll` which throws [1]
8 | * the use of `Assembly.Load` on non-AOT'ed assemblies [2]
9 | - two assemblies are included, as **BundleResource**, inside the .app
10 | - an assembly can be downloaded from the network
11 | * the use of `System.Reflection.Emit` to
12 | - generate and save an assembly on device; and then
13 | - load and execute it
14 |
15 | [1] the stack trace confirms the SLE interpreter (using for AOT builds) is not being used
16 |
17 | [2] edit the URL to a web server that you control
18 |
19 | This sample does **not** show
20 |
21 | * Good UI taste :-)
22 |
23 | ## Building Notes
24 |
25 | * By design this sample uses assemblies (e.g. `pass.dll` and `fail.dll`) that are not known to the iOS project (`dynloadios.exe`). This requires building `pass.csproj` and `fail.csproj` before the main `dynloadios` project. This ensure that `mtouch` is unaware of the assemblies and can't prepare (or change anything) to make them run (e.g. no AOT'ing, no linking...)
26 |
27 | * Downloading an assembly requires you to start a local web server and update the URL inside `ViewController.cs`. Otherwise you'll get an exception.
28 |
29 | ```csharp
30 | var url = "http://192.168.2.35:8000/download.dll";
31 | ```
32 |
33 | ## FAQ
34 |
35 | 1. What happens if I don't provide the `--interpreter` argument ?
36 |
37 | When touching any of the labels the sample will crash with something like:
38 | ```
39 | error: Failed to load AOT module '.../dynloadios.app/pass.dll.so' in aot-only mode.
40 | ```
41 |
42 | 2. What happens if I don't use Xamarin.iOS 12.7.1.x ?
43 |
44 | The sample won't build since it uses `System.Reflection.Emit` types that Xamarin.iOS does not provide.
45 | However you can comment this part to try the rest of the sample.
46 |
--------------------------------------------------------------------------------
/dynamicload/dynamicload.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "pass", "pass\pass.csproj", "{F1470A27-AAE2-4AC7-B844-623EC98BF04A}"
5 | EndProject
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "fail", "fail\fail.csproj", "{F9ACD423-8188-451F-BB47-9B79E2CF9C3D}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dynloadios", "dynloadios\dynloadios.csproj", "{E2C82117-41D6-4B53-9869-0B15879EE19E}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|x86 = Debug|x86
13 | Release|x86 = Release|x86
14 | Debug|iPhoneSimulator = Debug|iPhoneSimulator
15 | Release|iPhone = Release|iPhone
16 | Release|iPhoneSimulator = Release|iPhoneSimulator
17 | Debug|iPhone = Debug|iPhone
18 | EndGlobalSection
19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
20 | {F1470A27-AAE2-4AC7-B844-623EC98BF04A}.Debug|x86.ActiveCfg = Debug|Any CPU
21 | {F1470A27-AAE2-4AC7-B844-623EC98BF04A}.Debug|x86.Build.0 = Debug|Any CPU
22 | {F1470A27-AAE2-4AC7-B844-623EC98BF04A}.Release|x86.ActiveCfg = Debug|Any CPU
23 | {F1470A27-AAE2-4AC7-B844-623EC98BF04A}.Release|x86.Build.0 = Debug|Any CPU
24 | {F1470A27-AAE2-4AC7-B844-623EC98BF04A}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
25 | {F1470A27-AAE2-4AC7-B844-623EC98BF04A}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
26 | {F1470A27-AAE2-4AC7-B844-623EC98BF04A}.Release|iPhone.ActiveCfg = Release|Any CPU
27 | {F1470A27-AAE2-4AC7-B844-623EC98BF04A}.Release|iPhone.Build.0 = Release|Any CPU
28 | {F1470A27-AAE2-4AC7-B844-623EC98BF04A}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
29 | {F1470A27-AAE2-4AC7-B844-623EC98BF04A}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
30 | {F1470A27-AAE2-4AC7-B844-623EC98BF04A}.Debug|iPhone.ActiveCfg = Debug|Any CPU
31 | {F1470A27-AAE2-4AC7-B844-623EC98BF04A}.Debug|iPhone.Build.0 = Debug|Any CPU
32 | {F9ACD423-8188-451F-BB47-9B79E2CF9C3D}.Debug|x86.ActiveCfg = Debug|Any CPU
33 | {F9ACD423-8188-451F-BB47-9B79E2CF9C3D}.Debug|x86.Build.0 = Debug|Any CPU
34 | {F9ACD423-8188-451F-BB47-9B79E2CF9C3D}.Release|x86.ActiveCfg = Debug|Any CPU
35 | {F9ACD423-8188-451F-BB47-9B79E2CF9C3D}.Release|x86.Build.0 = Debug|Any CPU
36 | {F9ACD423-8188-451F-BB47-9B79E2CF9C3D}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
37 | {F9ACD423-8188-451F-BB47-9B79E2CF9C3D}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
38 | {F9ACD423-8188-451F-BB47-9B79E2CF9C3D}.Release|iPhone.ActiveCfg = Release|Any CPU
39 | {F9ACD423-8188-451F-BB47-9B79E2CF9C3D}.Release|iPhone.Build.0 = Release|Any CPU
40 | {F9ACD423-8188-451F-BB47-9B79E2CF9C3D}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
41 | {F9ACD423-8188-451F-BB47-9B79E2CF9C3D}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
42 | {F9ACD423-8188-451F-BB47-9B79E2CF9C3D}.Debug|iPhone.ActiveCfg = Debug|Any CPU
43 | {F9ACD423-8188-451F-BB47-9B79E2CF9C3D}.Debug|iPhone.Build.0 = Debug|Any CPU
44 | {E2C82117-41D6-4B53-9869-0B15879EE19E}.Debug|x86.ActiveCfg = Debug|iPhoneSimulator
45 | {E2C82117-41D6-4B53-9869-0B15879EE19E}.Debug|x86.Build.0 = Debug|iPhoneSimulator
46 | {E2C82117-41D6-4B53-9869-0B15879EE19E}.Release|x86.ActiveCfg = Release|iPhone
47 | {E2C82117-41D6-4B53-9869-0B15879EE19E}.Release|x86.Build.0 = Release|iPhone
48 | {E2C82117-41D6-4B53-9869-0B15879EE19E}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
49 | {E2C82117-41D6-4B53-9869-0B15879EE19E}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
50 | {E2C82117-41D6-4B53-9869-0B15879EE19E}.Release|iPhone.ActiveCfg = Release|iPhone
51 | {E2C82117-41D6-4B53-9869-0B15879EE19E}.Release|iPhone.Build.0 = Release|iPhone
52 | {E2C82117-41D6-4B53-9869-0B15879EE19E}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
53 | {E2C82117-41D6-4B53-9869-0B15879EE19E}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
54 | {E2C82117-41D6-4B53-9869-0B15879EE19E}.Debug|iPhone.ActiveCfg = Debug|iPhone
55 | {E2C82117-41D6-4B53-9869-0B15879EE19E}.Debug|iPhone.Build.0 = Debug|iPhone
56 | EndGlobalSection
57 | GlobalSection(MonoDevelopProperties) = preSolution
58 | Policies = $0
59 | $0.DotNetNamingPolicy = $1
60 | $1.DirectoryNamespaceAssociation = PrefixedHierarchical
61 | $0.StandardHeader = $2
62 | $0.VersionControlPolicy = $3
63 | EndGlobalSection
64 | EndGlobal
65 |
--------------------------------------------------------------------------------
/dynamicload/dynloadios/AppDelegate.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using Microsoft.CSharp.RuntimeBinder;
4 |
5 | using Foundation;
6 | using UIKit;
7 |
8 | namespace dynloadios
9 | {
10 | // The UIApplicationDelegate for the application. This class is responsible for launching the
11 | // User Interface of the application, as well as listening (and optionally responding) to application events from iOS.
12 | [Register ("AppDelegate")]
13 | public class AppDelegate : UIApplicationDelegate
14 | {
15 | // class-level declarations
16 |
17 | public override UIWindow Window {
18 | get;
19 | set;
20 | }
21 |
22 | public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
23 | {
24 | return true;
25 | }
26 |
27 | public override void OnResignActivation (UIApplication application)
28 | {
29 | // Invoked when the application is about to move from active to inactive state.
30 | // This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message)
31 | // or when the user quits the application and it begins the transition to the background state.
32 | // Games should use this method to pause the game.
33 | }
34 |
35 | public override void DidEnterBackground (UIApplication application)
36 | {
37 | // Use this method to release shared resources, save user data, invalidate timers and store the application state.
38 | // If your application supports background exection this method is called instead of WillTerminate when the user quits.
39 | }
40 |
41 | public override void WillEnterForeground (UIApplication application)
42 | {
43 | // Called as part of the transiton from background to active state.
44 | // Here you can undo many of the changes made on entering the background.
45 | }
46 |
47 | public override void OnActivated (UIApplication application)
48 | {
49 | // Restart any tasks that were paused (or not yet started) while the application was inactive.
50 | // If the application was previously in the background, optionally refresh the user interface.
51 | }
52 |
53 | public override void WillTerminate (UIApplication application)
54 | {
55 | // Called when the application is about to terminate. Save data, if needed. See also DidEnterBackground.
56 | }
57 | }
58 | }
59 |
60 | // same-assembly version
61 | public class DynamicClass {
62 |
63 | public int Add (int i, int j)
64 | {
65 | return i + j;
66 | }
67 |
68 | public void Print2 (string str)
69 | {
70 | Console.WriteLine (str.ToUpper ());
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/dynamicload/dynloadios/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "20x20",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "20x20",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "29x29",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "29x29",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "40x40",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "40x40",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "size" : "60x60",
36 | "scale" : "2x"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "size" : "60x60",
41 | "scale" : "3x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "20x20",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "20x20",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "29x29",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "29x29",
61 | "scale" : "2x"
62 | },
63 | {
64 | "idiom" : "ipad",
65 | "size" : "40x40",
66 | "scale" : "1x"
67 | },
68 | {
69 | "idiom" : "ipad",
70 | "size" : "40x40",
71 | "scale" : "2x"
72 | },
73 | {
74 | "idiom" : "ipad",
75 | "size" : "76x76",
76 | "scale" : "1x"
77 | },
78 | {
79 | "idiom" : "ipad",
80 | "size" : "76x76",
81 | "scale" : "2x"
82 | },
83 | {
84 | "idiom" : "ipad",
85 | "size" : "83.5x83.5",
86 | "scale" : "2x"
87 | },
88 | {
89 | "idiom" : "ios-marketing",
90 | "size" : "1024x1024",
91 | "scale" : "1x"
92 | },
93 | {
94 | "size" : "24x24",
95 | "idiom" : "watch",
96 | "scale" : "2x",
97 | "role" : "notificationCenter",
98 | "subtype" : "38mm"
99 | },
100 | {
101 | "size" : "27.5x27.5",
102 | "idiom" : "watch",
103 | "scale" : "2x",
104 | "role" : "notificationCenter",
105 | "subtype" : "42mm"
106 | },
107 | {
108 | "size" : "29x29",
109 | "idiom" : "watch",
110 | "role" : "companionSettings",
111 | "scale" : "2x"
112 | },
113 | {
114 | "size" : "29x29",
115 | "idiom" : "watch",
116 | "role" : "companionSettings",
117 | "scale" : "3x"
118 | },
119 | {
120 | "size" : "40x40",
121 | "idiom" : "watch",
122 | "scale" : "2x",
123 | "role" : "appLauncher",
124 | "subtype" : "38mm"
125 | },
126 | {
127 | "size" : "44x44",
128 | "idiom" : "watch",
129 | "scale" : "2x",
130 | "role" : "longLook",
131 | "subtype" : "42mm"
132 | },
133 | {
134 | "size" : "86x86",
135 | "idiom" : "watch",
136 | "scale" : "2x",
137 | "role" : "quickLook",
138 | "subtype" : "38mm"
139 | },
140 | {
141 | "size" : "98x98",
142 | "idiom" : "watch",
143 | "scale" : "2x",
144 | "role" : "quickLook",
145 | "subtype" : "42mm"
146 | },
147 | {
148 | "idiom" : "mac",
149 | "size" : "16x16",
150 | "scale" : "1x"
151 | },
152 | {
153 | "idiom" : "mac",
154 | "size" : "16x16",
155 | "scale" : "2x"
156 | },
157 | {
158 | "idiom" : "mac",
159 | "size" : "32x32",
160 | "scale" : "1x"
161 | },
162 | {
163 | "idiom" : "mac",
164 | "size" : "32x32",
165 | "scale" : "2x"
166 | },
167 | {
168 | "idiom" : "mac",
169 | "size" : "128x128",
170 | "scale" : "1x"
171 | },
172 | {
173 | "idiom" : "mac",
174 | "size" : "128x128",
175 | "scale" : "2x"
176 | },
177 | {
178 | "idiom" : "mac",
179 | "size" : "256x256",
180 | "scale" : "1x"
181 | },
182 | {
183 | "idiom" : "mac",
184 | "size" : "256x256",
185 | "scale" : "2x"
186 | },
187 | {
188 | "idiom" : "mac",
189 | "size" : "512x512",
190 | "scale" : "1x"
191 | },
192 | {
193 | "idiom" : "mac",
194 | "size" : "512x512",
195 | "scale" : "2x"
196 | }
197 | ],
198 | "info" : {
199 | "version" : 1,
200 | "author" : "xcode"
201 | }
202 | }
203 |
--------------------------------------------------------------------------------
/dynamicload/dynloadios/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/dynamicload/dynloadios/Entitlements.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/dynamicload/dynloadios/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleName
6 | dynloadios
7 | CFBundleIdentifier
8 | com.companyname.dynloadios
9 | CFBundleShortVersionString
10 | 1.0
11 | CFBundleVersion
12 | 1.0
13 | LSRequiresIPhoneOS
14 |
15 | MinimumOSVersion
16 | 8.0
17 | UIDeviceFamily
18 |
19 | 1
20 | 2
21 |
22 | UILaunchStoryboardName
23 | LaunchScreen
24 | UIMainStoryboardFile
25 | Main
26 | UIRequiredDeviceCapabilities
27 |
28 | armv7
29 |
30 | UISupportedInterfaceOrientations
31 |
32 | UIInterfaceOrientationPortrait
33 | UIInterfaceOrientationPortraitUpsideDown
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 | XSAppIconAssets
38 | Assets.xcassets/AppIcon.appiconset
39 |
40 |
41 |
--------------------------------------------------------------------------------
/dynamicload/dynloadios/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/dynamicload/dynloadios/Main.cs:
--------------------------------------------------------------------------------
1 | using UIKit;
2 |
3 | namespace dynloadios
4 | {
5 | public class Application
6 | {
7 | // This is the main entry point of the application.
8 | static void Main (string [] args)
9 | {
10 | // if you want to use a different Application Delegate class from "AppDelegate"
11 | // you can specify it here.
12 | UIApplication.Main (args, null, "AppDelegate");
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/dynamicload/dynloadios/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
29 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
53 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/dynamicload/dynloadios/ViewController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Reflection;
4 | using System.Reflection.Emit;
5 | using System.Net;
6 | using System.Text;
7 | using Microsoft.CSharp.RuntimeBinder;
8 |
9 | using UIKit;
10 |
11 | namespace dynloadios
12 | {
13 | public partial class ViewController : UIViewController
14 | {
15 | protected ViewController (IntPtr handle) : base (handle)
16 | {
17 | // Note: this .ctor should not contain any initialization logic.
18 | }
19 |
20 | int a = 1, b = 2;
21 | StringBuilder output = new StringBuilder ();
22 |
23 | void Dynamic (string option, string path)
24 | {
25 | output.Clear ();
26 | output.Append ("Clicked '").Append (option).AppendLine ("'...");
27 |
28 | if (File.Exists (path)) {
29 | output.Append ("Loading '").Append (Path.GetFileName (path)).AppendLine ("'...");
30 | try {
31 | var assembly = Assembly.LoadFile (path);
32 | var t = assembly.GetType ("DynamicClass");
33 | if (t != null) {
34 | dynamic dynamic_ec = Activator.CreateInstance (t);
35 | try {
36 | // on console only
37 | dynamic_ec.Print (assembly.ToString ());
38 | } catch (Exception e) {
39 | output.Append ("FAIL ").AppendLine (e.ToString ());
40 | }
41 |
42 | var addition = String.Empty;
43 | try {
44 | output.Append ("Adding ").Append (a).Append (" to ").Append (b).Append (" gives ");
45 | a = dynamic_ec.Add (a, b++);
46 | output.AppendLine (a.ToString ());
47 | } catch (RuntimeBinderException rbe) {
48 | output.Append ("Does not add up ").AppendLine (rbe.ToString ());
49 | } catch (Exception e) {
50 | output.Append ("FAIL ").AppendLine (e.ToString ());
51 | }
52 | } else {
53 | output.Append ("Type 'DynamicClass' was not found inside the assembly!");
54 | }
55 | } catch (Exception e) {
56 | output.Append ("FAIL ").AppendLine (e.ToString ());
57 | }
58 | } else {
59 | output.Append ("Assembly '").Append (path).AppendLine ("' not found!");
60 | }
61 | textBox.Text = output.ToString ();
62 | }
63 |
64 | partial void EmitDown (UIButton sender)
65 | {
66 | var temp = Path.GetTempFileName () + ".dll";
67 | var name = Path.GetFileName (temp);
68 | AssemblyName aname = new AssemblyName ("Emit");
69 | AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly (aname, AssemblyBuilderAccess.Save, Path.GetDirectoryName (temp));
70 | ModuleBuilder mod = ab.DefineDynamicModule ("main", name);
71 | TypeBuilder tb = mod.DefineType ("DynamicClass", TypeAttributes.Public);
72 |
73 | MethodBuilder mb = tb.DefineMethod ("Print", MethodAttributes.Public, null, new [] { typeof (string) });
74 | ILGenerator il = mb.GetILGenerator ();
75 | il.EmitWriteLine ("Hello Code Generation!");
76 | il.Emit (OpCodes.Ret);
77 |
78 | MethodBuilder mb2 = tb.DefineMethod ("Add", MethodAttributes.Public, typeof (int), new [] { typeof (int), typeof (int) });
79 | ILGenerator il2 = mb2.GetILGenerator ();
80 | il2.Emit (OpCodes.Ldarg_1);
81 | il2.Emit (OpCodes.Ldarg_2);
82 | il2.Emit (OpCodes.Add);
83 | il2.Emit (OpCodes.Ret);
84 |
85 | tb.CreateType ();
86 | ab.Save (name);
87 | Dynamic ("Emit", temp);
88 | }
89 |
90 | // e.g. `python -m SimpleHTTPServer 8000`
91 | partial void DownloadDown (UIButton sender)
92 | {
93 | var url = "http://192.168.2.35:8000/download.dll";
94 | var temp = Path.GetTempFileName ();
95 | try {
96 | new WebClient ().DownloadFile (url, temp);
97 | Dynamic ("Download", temp);
98 | } catch (Exception e) {
99 | textBox.Text = $"Could not download '{url}' to '{temp}'.{Environment.NewLine}{e}";
100 | }
101 | }
102 |
103 | partial void FailDown (UIButton sender)
104 | {
105 | Dynamic ("Fail", Path.GetFullPath ("fail.dll"));
106 | }
107 |
108 | partial void PassDown (UIButton sender)
109 | {
110 | Dynamic ("Pass", Path.GetFullPath ("pass.dll"));
111 | }
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/dynamicload/dynloadios/ViewController.designer.cs:
--------------------------------------------------------------------------------
1 | // WARNING
2 | //
3 | // This file has been generated automatically by Visual Studio from the outlets and
4 | // actions declared in your storyboard file.
5 | // Manual changes to this file will not be maintained.
6 | //
7 | using Foundation;
8 | using System;
9 | using System.CodeDom.Compiler;
10 |
11 | namespace dynloadios
12 | {
13 | [Register ("ViewController")]
14 | partial class ViewController
15 | {
16 | [Outlet]
17 | [GeneratedCode ("iOS Designer", "1.0")]
18 | UIKit.UITextView textBox { get; set; }
19 |
20 | [Action ("DownloadDown:")]
21 | [GeneratedCode ("iOS Designer", "1.0")]
22 | partial void DownloadDown (UIKit.UIButton sender);
23 |
24 | [Action ("EmitDown:")]
25 | [GeneratedCode ("iOS Designer", "1.0")]
26 | partial void EmitDown (UIKit.UIButton sender);
27 |
28 | [Action ("FailDown:")]
29 | [GeneratedCode ("iOS Designer", "1.0")]
30 | partial void FailDown (UIKit.UIButton sender);
31 |
32 | [Action ("PassDown:")]
33 | [GeneratedCode ("iOS Designer", "1.0")]
34 | partial void PassDown (UIKit.UIButton sender);
35 |
36 | void ReleaseDesignerOutlets ()
37 | {
38 | if (textBox != null) {
39 | textBox.Dispose ();
40 | textBox = null;
41 | }
42 | }
43 | }
44 | }
--------------------------------------------------------------------------------
/dynamicload/dynloadios/dynloadios.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | iPhoneSimulator
6 | {E2C82117-41D6-4B53-9869-0B15879EE19E}
7 | {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
8 | Exe
9 | dynloadios
10 | dynloadios
11 | Resources
12 |
13 |
14 | true
15 | full
16 | false
17 | bin\iPhoneSimulator\Debug
18 | DEBUG;ENABLE_TEST_CLOUD;
19 | prompt
20 | 4
21 | iPhone Developer
22 | true
23 | true
24 | true
25 | true
26 | 32059
27 | None
28 | x86_64
29 | NSUrlSessionHandler
30 | x86
31 | false
32 |
33 |
34 |
35 | pdbonly
36 | true
37 | bin\iPhone\Release
38 |
39 | prompt
40 | 4
41 | iPhone Developer
42 | true
43 | true
44 | Entitlements.plist
45 | SdkOnly
46 | ARM64
47 | NSUrlSessionHandler
48 | x86
49 |
50 |
51 |
52 | true
53 | bin\iPhoneSimulator\Release
54 |
55 | prompt
56 | 4
57 | iPhone Developer
58 | true
59 | None
60 | x86_64
61 | NSUrlSessionHandler
62 | x86
63 |
64 |
65 |
66 |
67 | false
68 |
69 |
70 | true
71 | full
72 | false
73 | bin\iPhone\Debug
74 | DEBUG;ENABLE_TEST_CLOUD;
75 | prompt
76 | 4
77 | iPhone Developer
78 | true
79 | true
80 | true
81 | true
82 | true
83 | true
84 | Entitlements.plist
85 | 46815
86 | SdkOnly
87 | ARM64
88 | NSUrlSessionHandler
89 | x86
90 |
91 |
92 |
93 | true
94 | full
95 | false
96 | bin\iPhoneSimulator\Debug on Simulator
97 | __IOS__;__MOBILE__;__UNIFIED__;DEBUG;ENABLE_TEST_CLOUD;
98 | prompt
99 | 4
100 | iPhone Developer
101 | true
102 | true
103 | true
104 | true
105 | 32059
106 | None
107 | x86_64
108 | NSUrlSessionHandler
109 | x86
110 | false
111 |
112 |
113 |
114 | true
115 | full
116 | false
117 | bin\iPhoneSimulator\Debug on SIm 2
118 | __IOS__;__MOBILE__;__UNIFIED__;DEBUG;ENABLE_TEST_CLOUD;
119 | prompt
120 | 4
121 | iPhone Developer
122 | true
123 | true
124 | true
125 | true
126 | 32059
127 | None
128 | x86_64
129 | NSUrlSessionHandler
130 | x86
131 | false
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 | ViewController.cs
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
--------------------------------------------------------------------------------
/dynamicload/dynloadios/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/dynamicload/fail/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 |
4 | // Information about this assembly is defined by the following attributes.
5 | // Change them to the values specific to your project.
6 |
7 | [assembly: AssemblyTitle ("fail")]
8 | [assembly: AssemblyDescription ("")]
9 | [assembly: AssemblyConfiguration ("")]
10 | [assembly: AssemblyCompany ("")]
11 | [assembly: AssemblyProduct ("")]
12 | [assembly: AssemblyCopyright ("${AuthorCopyright}")]
13 | [assembly: AssemblyTrademark ("")]
14 | [assembly: AssemblyCulture ("")]
15 |
16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision,
18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision.
19 |
20 | [assembly: AssemblyVersion ("1.0.*")]
21 |
22 | // The following attributes are used to specify the signing key for the assembly,
23 | // if desired. See the Mono documentation for more information about signing.
24 |
25 | //[assembly: AssemblyDelaySign(false)]
26 | //[assembly: AssemblyKeyFile("")]
27 |
--------------------------------------------------------------------------------
/dynamicload/fail/fail.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | public class DynamicClass {
4 |
5 | public void Print (string str)
6 | {
7 | Console.WriteLine (str);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/dynamicload/fail/fail.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | {F9ACD423-8188-451F-BB47-9B79E2CF9C3D}
7 | Library
8 | fail
9 | fail
10 | v4.7
11 |
12 |
13 | true
14 | full
15 | false
16 | ..\dynloadios
17 | DEBUG;
18 | prompt
19 | 4
20 | false
21 |
22 |
23 | true
24 | ..\dynloadios
25 | prompt
26 | 4
27 | false
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/dynamicload/pass/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 |
4 | // Information about this assembly is defined by the following attributes.
5 | // Change them to the values specific to your project.
6 |
7 | [assembly: AssemblyTitle ("pass")]
8 | [assembly: AssemblyDescription ("")]
9 | [assembly: AssemblyConfiguration ("")]
10 | [assembly: AssemblyCompany ("")]
11 | [assembly: AssemblyProduct ("")]
12 | [assembly: AssemblyCopyright ("${AuthorCopyright}")]
13 | [assembly: AssemblyTrademark ("")]
14 | [assembly: AssemblyCulture ("")]
15 |
16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision,
18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision.
19 |
20 | [assembly: AssemblyVersion ("1.0.*")]
21 |
22 | // The following attributes are used to specify the signing key for the assembly,
23 | // if desired. See the Mono documentation for more information about signing.
24 |
25 | //[assembly: AssemblyDelaySign(false)]
26 | //[assembly: AssemblyKeyFile("")]
27 |
--------------------------------------------------------------------------------
/dynamicload/pass/pass.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | public class DynamicClass {
4 |
5 | public int Add (int i, int j)
6 | {
7 | return i + j;
8 | }
9 |
10 | public void Print (string str)
11 | {
12 | Console.WriteLine (str.ToLowerInvariant ());
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/dynamicload/pass/pass.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | {F1470A27-AAE2-4AC7-B844-623EC98BF04A}
7 | Library
8 | pass
9 | pass
10 | v4.7
11 |
12 |
13 | true
14 | full
15 | false
16 | ..\dynloadios\
17 | DEBUG;
18 | prompt
19 | 4
20 | false
21 |
22 |
23 | true
24 | ..\dynloadios\
25 | prompt
26 | 4
27 | false
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/subclass/README.md:
--------------------------------------------------------------------------------
1 | # Subclass
2 |
3 | This sample shows the use of the interpreter and the linker / optimizations.
4 |
5 | It can be tricky to get both working together. The linker assume it knows all the code inside the application. Anything loaded dynamically cannot be considered at build time. Still, if some care is applied, you can use the interpreter and the linker together.
6 |
7 | To help this scenario some of the default optimizations are turned off when the interpreter is enabled. You can turn them back on if your application does not break the optimization assumptions.
8 |
9 | ## Building Notes
10 |
11 | * By design this sample uses an assembly, `customcode.dll`, that is not known to the iOS project (`subclass.exe`). This requires building `customcode.csproj` abefore the main `subclass` project. This ensure that `mtouch` is unaware of the assembly and can't prepare (or change anything) to make it run (e.g. no AOT'ing, no linking...)
12 |
13 | ## FAQ
14 |
15 | 1. What happens if I don't provide the `--interpreter` argument ?
16 |
17 | When touching any of the labels the sample will crash with something like:
18 | ```
19 | error: Failed to load AOT module '.../subclass.app/customcode.dll.so' in aot-only mode.
20 | ```
21 |
22 | 2. What happens if I don't use Xamarin.iOS 12.7.1.x ?
23 |
24 | The default options for many optimizations won't work with the interpreter when linking is enabled, leading to exceptions/crashes.
25 |
--------------------------------------------------------------------------------
/subclass/customcode/CustomProtocol.cs:
--------------------------------------------------------------------------------
1 | using Foundation;
2 |
3 | namespace BundledCode {
4 |
5 | public class CustomProtocol : NSObject, INSUrlProtocolClient {
6 |
7 | public CustomProtocol (NSUrlRequest request, NSCachedUrlResponse cachedResponse, INSUrlProtocolClient client)
8 | {
9 | }
10 |
11 | public void CachedResponseIsValid (NSUrlProtocol protocol, NSCachedUrlResponse cachedResponse)
12 | {
13 | }
14 |
15 | public void CancelledAuthenticationChallenge (NSUrlProtocol protocol, NSUrlAuthenticationChallenge challenge)
16 | {
17 | }
18 |
19 | public void DataLoaded (NSUrlProtocol protocol, NSData data)
20 | {
21 | }
22 |
23 | public void FailedWithError (NSUrlProtocol protocol, NSError error)
24 | {
25 | }
26 |
27 | public void FinishedLoading (NSUrlProtocol protocol)
28 | {
29 | }
30 |
31 | public void ReceivedAuthenticationChallenge (NSUrlProtocol protocol, NSUrlAuthenticationChallenge challenge)
32 | {
33 | }
34 |
35 | public void ReceivedResponse (NSUrlProtocol protocol, NSUrlResponse response, NSUrlCacheStoragePolicy policy)
36 | {
37 | }
38 |
39 | public void Redirected (NSUrlProtocol protocol, NSUrlRequest redirectedToEequest, NSUrlResponse redirectResponse)
40 | {
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/subclass/customcode/CustomView.cs:
--------------------------------------------------------------------------------
1 | using CoreGraphics;
2 | using UIKit;
3 |
4 | namespace BundledCode
5 | {
6 | public class CustomView : UIView {
7 |
8 | public CustomView (CGRect frame) : base (frame)
9 | {
10 | }
11 |
12 | // all colors are fine - as long as it's red
13 | public override UIColor BackgroundColor {
14 | get => base.BackgroundColor;
15 | set => base.BackgroundColor = UIColor.Red;
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/subclass/customcode/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle ("customview")]
9 | [assembly: AssemblyDescription ("")]
10 | [assembly: AssemblyConfiguration ("")]
11 | [assembly: AssemblyCompany ("")]
12 | [assembly: AssemblyProduct ("customview")]
13 | [assembly: AssemblyCopyright ("Copyright © 2017")]
14 | [assembly: AssemblyTrademark ("")]
15 | [assembly: AssemblyCulture ("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible (false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid ("50c7b8c9-e664-45af-b88e-0c9b8b9c1be1")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion ("1.0.0.0")]
36 | [assembly: AssemblyFileVersion ("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/subclass/customcode/customcode.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 8.0.30703
7 | 2.0
8 | {CB189365-5937-4915-8AD1-DA46C5421F0E}
9 | {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
10 | {a52b8a63-bc84-4b47-910d-692533484892}
11 | Library
12 | BundledCode
13 | Resources
14 | customcode
15 |
16 |
17 | true
18 | full
19 | false
20 | ..\subclass
21 | DEBUG;
22 | prompt
23 | 4
24 | false
25 |
26 |
27 | full
28 | true
29 | ..\subclass
30 | prompt
31 | 4
32 | false
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/subclass/subclass.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "subclass", "subclass\subclass.csproj", "{419FBE29-7B36-4D4D-9B2D-C0DEA58C0148}"
5 | EndProject
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "customcode", "customcode\customcode.csproj", "{CB189365-5937-4915-8AD1-DA46C5421F0E}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|iPhoneSimulator = Debug|iPhoneSimulator
11 | Release|iPhoneSimulator = Release|iPhoneSimulator
12 | Debug|iPhone = Debug|iPhone
13 | Release|iPhone = Release|iPhone
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {419FBE29-7B36-4D4D-9B2D-C0DEA58C0148}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
17 | {419FBE29-7B36-4D4D-9B2D-C0DEA58C0148}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
18 | {419FBE29-7B36-4D4D-9B2D-C0DEA58C0148}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
19 | {419FBE29-7B36-4D4D-9B2D-C0DEA58C0148}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
20 | {419FBE29-7B36-4D4D-9B2D-C0DEA58C0148}.Debug|iPhone.ActiveCfg = Debug|iPhone
21 | {419FBE29-7B36-4D4D-9B2D-C0DEA58C0148}.Debug|iPhone.Build.0 = Debug|iPhone
22 | {419FBE29-7B36-4D4D-9B2D-C0DEA58C0148}.Release|iPhone.ActiveCfg = Release|iPhone
23 | {419FBE29-7B36-4D4D-9B2D-C0DEA58C0148}.Release|iPhone.Build.0 = Release|iPhone
24 | {CB189365-5937-4915-8AD1-DA46C5421F0E}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
25 | {CB189365-5937-4915-8AD1-DA46C5421F0E}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
26 | {CB189365-5937-4915-8AD1-DA46C5421F0E}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
27 | {CB189365-5937-4915-8AD1-DA46C5421F0E}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
28 | {CB189365-5937-4915-8AD1-DA46C5421F0E}.Debug|iPhone.ActiveCfg = Debug|Any CPU
29 | {CB189365-5937-4915-8AD1-DA46C5421F0E}.Debug|iPhone.Build.0 = Debug|Any CPU
30 | {CB189365-5937-4915-8AD1-DA46C5421F0E}.Release|iPhone.ActiveCfg = Release|Any CPU
31 | {CB189365-5937-4915-8AD1-DA46C5421F0E}.Release|iPhone.Build.0 = Release|Any CPU
32 | EndGlobalSection
33 | EndGlobal
34 |
--------------------------------------------------------------------------------
/subclass/subclass/AppDelegate.cs:
--------------------------------------------------------------------------------
1 | using Foundation;
2 | using UIKit;
3 |
4 | namespace subclass
5 | {
6 | // The UIApplicationDelegate for the application. This class is responsible for launching the
7 | // User Interface of the application, as well as listening (and optionally responding) to application events from iOS.
8 | [Register ("AppDelegate")]
9 | public class AppDelegate : UIApplicationDelegate
10 | {
11 | // class-level declarations
12 |
13 | public override UIWindow Window {
14 | get;
15 | set;
16 | }
17 |
18 | public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
19 | {
20 | // Override point for customization after application launch.
21 | // If not required for your application you can safely delete this method
22 |
23 | return true;
24 | }
25 |
26 | public override void OnResignActivation (UIApplication application)
27 | {
28 | // Invoked when the application is about to move from active to inactive state.
29 | // This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message)
30 | // or when the user quits the application and it begins the transition to the background state.
31 | // Games should use this method to pause the game.
32 | }
33 |
34 | public override void DidEnterBackground (UIApplication application)
35 | {
36 | // Use this method to release shared resources, save user data, invalidate timers and store the application state.
37 | // If your application supports background exection this method is called instead of WillTerminate when the user quits.
38 | }
39 |
40 | public override void WillEnterForeground (UIApplication application)
41 | {
42 | // Called as part of the transiton from background to active state.
43 | // Here you can undo many of the changes made on entering the background.
44 | }
45 |
46 | public override void OnActivated (UIApplication application)
47 | {
48 | // Restart any tasks that were paused (or not yet started) while the application was inactive.
49 | // If the application was previously in the background, optionally refresh the user interface.
50 | }
51 |
52 | public override void WillTerminate (UIApplication application)
53 | {
54 | // Called when the application is about to terminate. Save data, if needed. See also DidEnterBackground.
55 | }
56 | }
57 | }
58 |
59 |
--------------------------------------------------------------------------------
/subclass/subclass/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images": [
3 | {
4 | "scale": "2x",
5 | "size": "20x20",
6 | "idiom": "iphone",
7 | "filename": "Icon40.png"
8 | },
9 | {
10 | "scale": "3x",
11 | "size": "20x20",
12 | "idiom": "iphone",
13 | "filename": "Icon60.png"
14 | },
15 | {
16 | "scale": "2x",
17 | "size": "29x29",
18 | "idiom": "iphone",
19 | "filename": "Icon58.png"
20 | },
21 | {
22 | "scale": "3x",
23 | "size": "29x29",
24 | "idiom": "iphone",
25 | "filename": "Icon87.png"
26 | },
27 | {
28 | "scale": "2x",
29 | "size": "40x40",
30 | "idiom": "iphone",
31 | "filename": "Icon80.png"
32 | },
33 | {
34 | "scale": "3x",
35 | "size": "40x40",
36 | "idiom": "iphone",
37 | "filename": "Icon120.png"
38 | },
39 | {
40 | "scale": "2x",
41 | "size": "60x60",
42 | "idiom": "iphone",
43 | "filename": "Icon120.png"
44 | },
45 | {
46 | "scale": "3x",
47 | "size": "60x60",
48 | "idiom": "iphone",
49 | "filename": "Icon180.png"
50 | },
51 | {
52 | "scale": "1x",
53 | "size": "20x20",
54 | "idiom": "ipad",
55 | "filename": "Icon20.png"
56 | },
57 | {
58 | "scale": "2x",
59 | "size": "20x20",
60 | "idiom": "ipad",
61 | "filename": "Icon40.png"
62 | },
63 | {
64 | "scale": "1x",
65 | "size": "29x29",
66 | "idiom": "ipad",
67 | "filename": "Icon29.png"
68 | },
69 | {
70 | "scale": "2x",
71 | "size": "29x29",
72 | "idiom": "ipad",
73 | "filename": "Icon58.png"
74 | },
75 | {
76 | "scale": "1x",
77 | "size": "40x40",
78 | "idiom": "ipad",
79 | "filename": "Icon40.png"
80 | },
81 | {
82 | "scale": "2x",
83 | "size": "40x40",
84 | "idiom": "ipad",
85 | "filename": "Icon80.png"
86 | },
87 | {
88 | "scale": "1x",
89 | "size": "76x76",
90 | "idiom": "ipad",
91 | "filename": "Icon76.png"
92 | },
93 | {
94 | "scale": "2x",
95 | "size": "76x76",
96 | "idiom": "ipad",
97 | "filename": "Icon152.png"
98 | },
99 | {
100 | "scale": "2x",
101 | "size": "83.5x83.5",
102 | "idiom": "ipad",
103 | "filename": "Icon167.png"
104 | },
105 | {
106 | "scale": "1x",
107 | "size": "1024x1024",
108 | "idiom": "ios-marketing",
109 | "filename": "Icon1024.png"
110 | }
111 | ],
112 | "properties": {},
113 | "info": {
114 | "version": 1,
115 | "author": "xcode"
116 | }
117 | }
--------------------------------------------------------------------------------
/subclass/subclass/Assets.xcassets/AppIcon.appiconset/Icon1024.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spouliot/interpreter/fffff9e624baa46a4c517f8a89c233a1306d4c8b/subclass/subclass/Assets.xcassets/AppIcon.appiconset/Icon1024.png
--------------------------------------------------------------------------------
/subclass/subclass/Assets.xcassets/AppIcon.appiconset/Icon120.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spouliot/interpreter/fffff9e624baa46a4c517f8a89c233a1306d4c8b/subclass/subclass/Assets.xcassets/AppIcon.appiconset/Icon120.png
--------------------------------------------------------------------------------
/subclass/subclass/Assets.xcassets/AppIcon.appiconset/Icon152.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spouliot/interpreter/fffff9e624baa46a4c517f8a89c233a1306d4c8b/subclass/subclass/Assets.xcassets/AppIcon.appiconset/Icon152.png
--------------------------------------------------------------------------------
/subclass/subclass/Assets.xcassets/AppIcon.appiconset/Icon167.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spouliot/interpreter/fffff9e624baa46a4c517f8a89c233a1306d4c8b/subclass/subclass/Assets.xcassets/AppIcon.appiconset/Icon167.png
--------------------------------------------------------------------------------
/subclass/subclass/Assets.xcassets/AppIcon.appiconset/Icon180.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spouliot/interpreter/fffff9e624baa46a4c517f8a89c233a1306d4c8b/subclass/subclass/Assets.xcassets/AppIcon.appiconset/Icon180.png
--------------------------------------------------------------------------------
/subclass/subclass/Assets.xcassets/AppIcon.appiconset/Icon20.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spouliot/interpreter/fffff9e624baa46a4c517f8a89c233a1306d4c8b/subclass/subclass/Assets.xcassets/AppIcon.appiconset/Icon20.png
--------------------------------------------------------------------------------
/subclass/subclass/Assets.xcassets/AppIcon.appiconset/Icon29.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spouliot/interpreter/fffff9e624baa46a4c517f8a89c233a1306d4c8b/subclass/subclass/Assets.xcassets/AppIcon.appiconset/Icon29.png
--------------------------------------------------------------------------------
/subclass/subclass/Assets.xcassets/AppIcon.appiconset/Icon40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spouliot/interpreter/fffff9e624baa46a4c517f8a89c233a1306d4c8b/subclass/subclass/Assets.xcassets/AppIcon.appiconset/Icon40.png
--------------------------------------------------------------------------------
/subclass/subclass/Assets.xcassets/AppIcon.appiconset/Icon58.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spouliot/interpreter/fffff9e624baa46a4c517f8a89c233a1306d4c8b/subclass/subclass/Assets.xcassets/AppIcon.appiconset/Icon58.png
--------------------------------------------------------------------------------
/subclass/subclass/Assets.xcassets/AppIcon.appiconset/Icon60.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spouliot/interpreter/fffff9e624baa46a4c517f8a89c233a1306d4c8b/subclass/subclass/Assets.xcassets/AppIcon.appiconset/Icon60.png
--------------------------------------------------------------------------------
/subclass/subclass/Assets.xcassets/AppIcon.appiconset/Icon76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spouliot/interpreter/fffff9e624baa46a4c517f8a89c233a1306d4c8b/subclass/subclass/Assets.xcassets/AppIcon.appiconset/Icon76.png
--------------------------------------------------------------------------------
/subclass/subclass/Assets.xcassets/AppIcon.appiconset/Icon80.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spouliot/interpreter/fffff9e624baa46a4c517f8a89c233a1306d4c8b/subclass/subclass/Assets.xcassets/AppIcon.appiconset/Icon80.png
--------------------------------------------------------------------------------
/subclass/subclass/Assets.xcassets/AppIcon.appiconset/Icon87.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/spouliot/interpreter/fffff9e624baa46a4c517f8a89c233a1306d4c8b/subclass/subclass/Assets.xcassets/AppIcon.appiconset/Icon87.png
--------------------------------------------------------------------------------
/subclass/subclass/Entitlements.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/subclass/subclass/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDisplayName
6 | subclass
7 | CFBundleIdentifier
8 | com.companyname.subclass
9 | CFBundleShortVersionString
10 | 1.0
11 | CFBundleVersion
12 | 1.0
13 | LSRequiresIPhoneOS
14 |
15 | MinimumOSVersion
16 | 10.0
17 | UIDeviceFamily
18 |
19 | 1
20 | 2
21 |
22 | UILaunchStoryboardName
23 | LaunchScreen
24 | UIMainStoryboardFile
25 | Main
26 | UIMainStoryboardFile~ipad
27 | Main
28 | UIRequiredDeviceCapabilities
29 |
30 | armv7
31 |
32 | UISupportedInterfaceOrientations
33 |
34 | UIInterfaceOrientationPortrait
35 | UIInterfaceOrientationLandscapeLeft
36 | UIInterfaceOrientationLandscapeRight
37 |
38 | UISupportedInterfaceOrientations~ipad
39 |
40 | UIInterfaceOrientationPortrait
41 | UIInterfaceOrientationPortraitUpsideDown
42 | UIInterfaceOrientationLandscapeLeft
43 | UIInterfaceOrientationLandscapeRight
44 |
45 | XSAppIconAssets
46 | Assets.xcassets/AppIcon.appiconset
47 |
48 |
--------------------------------------------------------------------------------
/subclass/subclass/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/subclass/subclass/Main.cs:
--------------------------------------------------------------------------------
1 | using UIKit;
2 |
3 | namespace subclass
4 | {
5 | public class Application
6 | {
7 | // This is the main entry point of the application.
8 | static void Main (string [] args)
9 | {
10 | // if you want to use a different Application Delegate class from "AppDelegate"
11 | // you can specify it here.
12 | UIApplication.Main (args, null, "AppDelegate");
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/subclass/subclass/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/subclass/subclass/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("subclass")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("subclass")]
13 | [assembly: AssemblyCopyright("Copyright © 2017")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("50c7b8c9-e664-45af-b88e-0c9b8b9c1be1")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/subclass/subclass/Resources/LaunchScreen.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
21 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/subclass/subclass/ViewController.cs:
--------------------------------------------------------------------------------
1 | using Foundation;
2 | using ObjCRuntime;
3 | using System;
4 | using UIKit;
5 |
6 | // System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.MissingMethodException: Method not found: void UIKit.UIView..ctor(CoreGraphics.CGRect)
7 | [assembly: Preserve (typeof (UIView), AllMembers = true)]
8 | // type won't load (and we'll throw a `ArgumentNullException`) if we won't preserve the protocol
9 | [assembly: Preserve (typeof (INSUrlProtocolClient), AllMembers = true)]
10 |
11 | namespace subclass {
12 |
13 | public partial class ViewController : UIViewController {
14 |
15 | public ViewController (IntPtr handle) : base (handle)
16 | {
17 | }
18 |
19 | public override void ViewDidLoad ()
20 | {
21 | base.ViewDidLoad ();
22 | // use `Type` to load the assembly we bundled into the app, i.e. `mtouch` is *NOT* aware of it
23 | var t = Type.GetType ("BundledCode.CustomView, customcode");
24 | // this would crash if 'remove-dynamic-registrar' was not turned off
25 | // System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> ObjCRuntime.RuntimeException: Can't register the class SubclassDemo.CustomView when the dynamic registrar has been linked away.
26 | var v = (UIView) Activator.CreateInstance (t, UIScreen.MainScreen.Bounds);
27 |
28 | // this would crash (without much informative details) if 'inline-isdirectbinding' was not turned off
29 | v.BackgroundColor = UIColor.Blue;
30 | // that won't crash but it might not do what we expect if 'seal-and-devirtualize' was not turned off
31 | if (v.BackgroundColor != UIColor.Red)
32 | throw new InvalidProgramException ("'seal-and-devirtualize' is likely enabled, causing the AOT code to be sealed and disallowing dynamically loaded code to subclass/override some types/members");
33 | Add (v);
34 |
35 | // dynamically loading protocols conflicts when the 'register-protocols' optimization
36 | var p = Type.GetType ("BundledCode.CustomProtocol, customcode");
37 | var u = (NSObject) Activator.CreateInstance (p, null, null, null);
38 | var x = new Protocol ("NSURLProtocolClient");
39 | if (!u.ConformsToProtocol (x.Handle))
40 | throw new InvalidProgramException ("'register-protocols' is likely enabled, causing the dynamically loaded code to skip protocol registration");
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/subclass/subclass/ViewController.designer.cs:
--------------------------------------------------------------------------------
1 | // WARNING
2 | //
3 | // This file has been generated automatically by Visual Studio from the outlets and
4 | // actions declared in your storyboard file.
5 | // Manual changes to this file will not be maintained.
6 | //
7 | using Foundation;
8 | using System;
9 | using System.CodeDom.Compiler;
10 | using UIKit;
11 |
12 | namespace subclass
13 | {
14 | [Register ("ViewController")]
15 | partial class ViewController
16 | {
17 | }
18 | }
--------------------------------------------------------------------------------
/subclass/subclass/subclass.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | iPhoneSimulator
6 | {419FBE29-7B36-4D4D-9B2D-C0DEA58C0148}
7 | {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
8 | {edc1b0fa-90cd-4038-8fad-98fe74adb368}
9 | Exe
10 | subclass
11 | subclass
12 | Resources
13 | true
14 | NSUrlSessionHandler
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\iPhoneSimulator\Debug
21 | DEBUG
22 | prompt
23 | 4
24 | false
25 | x86_64
26 | None
27 | true
28 |
29 |
30 | none
31 | true
32 | bin\iPhoneSimulator\Release
33 | prompt
34 | 4
35 | None
36 | x86_64
37 | false
38 |
39 |
40 | true
41 | full
42 | false
43 | bin\iPhone\Debug
44 | DEBUG
45 | prompt
46 | 4
47 | false
48 | ARM64
49 | Entitlements.plist
50 | iPhone Developer
51 | true
52 | --interpreter
53 |
54 |
55 | none
56 | true
57 | bin\iPhone\Release
58 | prompt
59 | 4
60 | Entitlements.plist
61 | ARM64
62 | false
63 | iPhone Developer
64 | true
65 | --interpreter
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 | false
74 |
75 |
76 | false
77 |
78 |
79 | false
80 |
81 |
82 | false
83 |
84 |
85 | false
86 |
87 |
88 | false
89 |
90 |
91 | false
92 |
93 |
94 | false
95 |
96 |
97 | false
98 |
99 |
100 | false
101 |
102 |
103 | false
104 |
105 |
106 | false
107 |
108 |
109 | false
110 |
111 |
112 | false
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 | ViewController.cs
132 |
133 |
134 |
135 |
136 |
137 |
138 |
--------------------------------------------------------------------------------