Skip to content

Commit de1ed2a

Browse files
committed
Using bundle path to resolve extension in iOS.
Using a NativeReference to include the xcframework. Forcing iOS simulator architecture.
1 parent c3be943 commit de1ed2a

File tree

6 files changed

+37
-35
lines changed

6 files changed

+37
-35
lines changed
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# PowerSync.Maui Changelog
22

3-
## 0.0.2-dev.8
3+
## 0.0.2-dev.9
44
- Fixing build issues related to MAUI targets not resolving on install.
55

66
## 0.0.1-alpha.1
@@ -9,4 +9,6 @@
99

1010
### Platform Runtime Support Added
1111
* MAUI iOS
12-
* MAUI Android
12+
* MAUI Android
13+
14+
```Discarded 'powersync-sqlite-core.xcframework/ios-arm64/dSYMs/powersync-sqlite-core.framework.dSYM/Contents/Resources/DWARF/powersync-sqlite-core' with logical name '../../../../../../../../../Users/christiaanlandman/code/dotnet/powersync-dotnet/PowerSync/PowerSync.Maui/powersync-sqlite-core.xcframework/ios-arm64/dSYMs/powersync-sqlite-core.framework.dSYM/Contents/Resources/DWARF/powersync-sqlite-core' because the logical name does not match 'Info.plist'`

PowerSync/PowerSync.Maui/PowerSync.Maui.csproj

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@
1919
<PackageIcon>icon.png</PackageIcon>
2020
<NoWarn>NU5100</NoWarn>
2121
<PackageReadmeFile>README.md</PackageReadmeFile>
22+
<IsBindingProject>true</IsBindingProject>
23+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
24+
<IncludeBuildOutput>true</IncludeBuildOutput>
2225
</PropertyGroup>
2326

2427
<ItemGroup>
2528
<ProjectReference Include="..\PowerSync.Common\PowerSync.Common.csproj" />
26-
2729
</ItemGroup>
2830

2931
<ItemGroup>
@@ -33,17 +35,14 @@
3335
<SubType>Designer</SubType>
3436
</None>
3537
</ItemGroup>
36-
37-
<!-- For monorepo-->
38-
<ItemGroup Condition="$(TargetFramework.Contains('-android'))">
39-
<Content Include="Platforms\Android\**\*.*">
40-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
41-
</Content>
42-
</ItemGroup>
4338

44-
<ItemGroup Condition="$(TargetFramework.Contains('-ios'))">
45-
<Content Include="Platforms\iOS\NativeLibs\powersync-sqlite-core.xcframework\**\*.*">
46-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
47-
</Content>
48-
</ItemGroup>
39+
40+
<ItemGroup Condition="$(TargetFramework.Contains('-ios'))">
41+
<ObjcBindingApiDefinition Include="build\ApiDefinition.cs" />
42+
43+
<NativeReference Include="platforms\iOS\NativeLibs\powersync-sqlite-core.xcframework">
44+
<Kind>Framework</Kind>
45+
<SmartLink>False</SmartLink>
46+
</NativeReference>
47+
</ItemGroup>
4948
</Project>

PowerSync/PowerSync.Maui/SQLite/MAUISQLiteAdapter.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ protected override void LoadExtension(SqliteConnection db)
1919
db.EnableExtensions(true);
2020

2121
#if IOS
22-
LoadExtensionIOS(db);
22+
LoadExtensionIOS(db);
2323
#elif ANDROID
2424
db.LoadExtension("libpowersync");
2525
#else
@@ -29,16 +29,21 @@ protected override void LoadExtension(SqliteConnection db)
2929

3030
private void LoadExtensionIOS(SqliteConnection db)
3131
{
32-
#if IOS
33-
var bundlePath = Foundation.NSBundle.MainBundle.BundlePath;
32+
#if IOS
33+
var bundlePath = Foundation.NSBundle.FromIdentifier("co.powersync.sqlitecore")?.BundlePath;
34+
if (bundlePath == null)
35+
{
36+
throw new Exception("Could not find PowerSync SQLite extension bundle path");
37+
}
38+
3439
var filePath =
35-
Path.Combine(bundlePath, "Frameworks", "powersync-sqlite-core.framework", "powersync-sqlite-core");
36-
40+
Path.Combine(bundlePath, "powersync-sqlite-core");
41+
3742
using var loadExtension = db.CreateCommand();
3843
loadExtension.CommandText = "SELECT load_extension(@path, @entryPoint)";
3944
loadExtension.Parameters.AddWithValue("@path", filePath);
4045
loadExtension.Parameters.AddWithValue("@entryPoint", "sqlite3_powersync_init");
4146
loadExtension.ExecuteNonQuery();
42-
#endif
47+
#endif
4348
}
4449
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
namespace YourNamespace
2+
{
3+
// Empty API definition - allows xcframework to be included without managed bindings
4+
}

PowerSync/PowerSync.Maui/build/PowerSync.Maui.targets

Lines changed: 0 additions & 13 deletions
This file was deleted.

demos/MAUITodo/MAUITodo.csproj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
<PropertyGroup>
44
<ApplicationId>com.companyname.todo</ApplicationId>
55

6-
<TargetFrameworks>net8.0-android;net8.0-ios</TargetFrameworks>
6+
<TargetFrameworks>net8.0-android</TargetFrameworks>
77
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>
8+
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('osx'))">$(TargetFrameworks);net8.0-ios</TargetFrameworks>
89

910

1011
<OutputType>Exe</OutputType>
@@ -34,6 +35,10 @@
3435
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.19041.0</SupportedOSPlatformVersion>
3536
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.19041.0</TargetPlatformMinVersion>
3637
</PropertyGroup>
38+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-ios|AnyCPU'">
39+
<RuntimeIdentifier>iossimulator-x64</RuntimeIdentifier>
40+
<ForceSimulatorX64ArchitectureInIDE>true</ForceSimulatorX64ArchitectureInIDE>
41+
</PropertyGroup>
3742
<ItemGroup>
3843
<!-- App Icon -->
3944
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />

0 commit comments

Comments
 (0)