Skip to content

Commit ceb9ef6

Browse files
authored
Relax iOS assembly weaver restrictions (#1535)
* Relax iOS assembly weaver restrictions * Add changelog
1 parent f18ecbb commit ceb9ef6

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ per-application keychain service. ([#1522](https://github.com/realm/realm-dotnet
1010

1111
### Bug fixes
1212
- `Realm.GetInstance` will now advance the Realm to the latest version, so you no longer have to call `Refresh` manually after that. ([#1523](https://github.com/realm/realm-dotnet/pull/1523))
13+
- Fixed an issue that would prevent iOS Share Extension projects from working. ([#1535](https://github.com/realm/realm-dotnet/pull/1535))
1314

1415
### Breaking Changes
1516

NuGet/Realm.Database/Realm.Database.targets

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<Target
77
Name="WeaveRealmAssemblyTarget"
88
BeforeTargets="_CompileToNative"
9-
Condition="'$(TargetFrameworkIdentifier)' == 'Xamarin.iOS' AND '$(OutputType)' == 'Exe'">
9+
Condition="'$(TargetFrameworkIdentifier)' == 'Xamarin.iOS'">
1010
<ItemGroup>
1111
<FilteredReferences Include="@(ReferencePath)" Condition="('%(Filename)%(Extension)' == 'Realm.dll') Or ('%(Filename)%(Extension)' == 'Realm.Sync.dll')" />
1212
<ReferencePath Include="$(OutputPath)Realm.dll" Condition="Exists('$(OutputPath)Realm.dll')"/>

Weaver/Realm.BuildTasks/WeaveRealmAssembly.cs

+14-2
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,19 @@ private static void WeaveDllImport(AssemblyDefinition assemblyToWeave, string dl
176176

177177
private string GetAssemblyPath(string name, bool isRealmAssembly = true)
178178
{
179-
return Path.Combine(isRealmAssembly ? OutputDirectory : IntermediateDirectory, $"{name}.{(isRealmAssembly ? "dll" : "exe")}");
179+
if (isRealmAssembly)
180+
{
181+
return Path.Combine(OutputDirectory, $"{name}.dll");
182+
}
183+
184+
var targetPath = Path.Combine(IntermediateDirectory, $"{name}.exe");
185+
if (File.Exists(targetPath))
186+
{
187+
return targetPath;
188+
}
189+
190+
// Likely an iOS share extension
191+
return Path.Combine(IntermediateDirectory, $"{name}.dll");
180192
}
181193

182194
// Invoked when looking for Cecil
@@ -189,7 +201,7 @@ private Assembly OnCurrentDomainAssemblyResolve(object sender, ResolveEventArgs
189201

190202
try
191203
{
192-
return Assembly.LoadFile(Path.Combine(folder, args.Name + ".dll"));
204+
return Assembly.LoadFile(Path.Combine(folder, $"{args.Name}.dll"));
193205
}
194206
catch
195207
{

0 commit comments

Comments
 (0)