Skip to content

Commit

Permalink
Merge pull request #455 from medz/feat/spm
Browse files Browse the repository at this point in the history
feat: Swift Package Manager
  • Loading branch information
medz authored Nov 29, 2024
2 parents 8c5ca69 + 940b361 commit 9de30ea
Show file tree
Hide file tree
Showing 11 changed files with 142 additions and 32 deletions.
58 changes: 40 additions & 18 deletions examples/flutter_with_orm/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */; };
7D84E56EBDA51C775B5208BE /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5865938AA7538E8BB30A100B /* Pods_Runner.framework */; };
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
Expand Down Expand Up @@ -72,6 +73,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */,
7D84E56EBDA51C775B5208BE /* Pods_Runner.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -198,13 +200,16 @@
97C146EC1CF9000F007C117D /* Resources */,
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
950019065A4353394ABA0B51 /* [CP] Embed Pods Frameworks */,
1340079823B69081FB578F21 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
dependencies = (
);
name = Runner;
packageProductDependencies = (
78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */,
);
productName = Runner;
productReference = 97C146EE1CF9000F007C117D /* Runner.app */;
productType = "com.apple.product-type.application";
Expand Down Expand Up @@ -238,6 +243,9 @@
Base,
);
mainGroup = 97C146E51CF9000F007C117D;
packageReferences = (
781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "FlutterGeneratedPluginSwiftPackage" */,
);
productRefGroup = 97C146EF1CF9000F007C117D /* Products */;
projectDirPath = "";
projectRoot = "";
Expand Down Expand Up @@ -270,6 +278,23 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
1340079823B69081FB578F21 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
Expand Down Expand Up @@ -308,23 +333,6 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
950019065A4353394ABA0B51 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
Expand Down Expand Up @@ -726,6 +734,20 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */

/* Begin XCLocalSwiftPackageReference section */
781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "FlutterGeneratedPluginSwiftPackage" */ = {
isa = XCLocalSwiftPackageReference;
relativePath = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage;
};
/* End XCLocalSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */ = {
isa = XCSwiftPackageProductDependency;
productName = FlutterGeneratedPluginSwiftPackage;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 97C146E61CF9000F007C117D /* Project object */;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<PreActions>
<ExecutionAction
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
<ActionContent
title = "Run Prepare Flutter Framework Script"
scriptText = "/bin/sh &quot;$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh&quot; prepare&#10;">
<EnvironmentBuildable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
BuildableName = "Runner.app"
BlueprintName = "Runner"
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</EnvironmentBuildable>
</ActionContent>
</ExecutionAction>
</PreActions>
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
Expand Down
12 changes: 6 additions & 6 deletions examples/flutter_with_orm/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,24 +96,24 @@ class _HomeState extends State<Home> {
enableDrag: true,
showDragHandle: true,
builder: (context) {
String name = '';
final controller = TextEditingController();

return Column(
children: [
Text('Create User', style: Theme.of(context).textTheme.titleLarge),
Padding(
padding: const EdgeInsets.all(12),
child: TextField(
controller: controller,
decoration: const InputDecoration(label: Text('Name')),
onChanged: (value) {
print('On changed: $value');
name = value;
},
),
),
FilledButton(
child: const Text('Create'),
onPressed: () => create(name),
onPressed: () {
create(controller.text);
Navigator.pop(context);
},
),
],
);
Expand Down
22 changes: 21 additions & 1 deletion packages/orm_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
## v0.5.0

To install Prisma Flutter Integration v0.5.0 run this command

```bash
dart pub add orm_flutter:^v0.5.0
```

Or update your `pubspec.yaml` file:

```yaml
dependencies:
orm_flutter: ^0.5.0
```
### What's New
- Upgrade Prisma CABI engine to `v6.0.0`
- Support Swift Package Manager

## v0.4.0

To install Prisma Flutter Integration v0.4.0 run this command
Expand All @@ -10,7 +30,7 @@ Or update your `pubspec.yaml` file:

```yaml
dependencies:
orm_flutter: ^v0.4.0
orm_flutter: ^0.4.0
```

### What's New
Expand Down
4 changes: 2 additions & 2 deletions packages/orm_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ homepage: https://prisma.pub
repository: https://github.com/medz/prisma-dart

resolution: workspace
version: 0.4.0
version: 0.5.0

funding:
- https://github.com/sponsors/medz
Expand All @@ -18,7 +18,7 @@ dependencies:
flutter:
sdk: flutter
orm: ^5.2.1
orm_flutter_ffi: ^0.0.1
orm_flutter_ffi: ^0.0.2

dev_dependencies:
flutter_lints: ^5.0.0
6 changes: 6 additions & 0 deletions packages/orm_flutter_ffi/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v0.0.2

- Upgrade `orm_flutter_android` to 0.0.2 version
- Upgrade `orm_flutter_ios` to 0.0.4 version
- Support SPM build for iOS

## v0.0.1

- FFI implementation of Prisma and Flutter integration query engine, acknowledged by `orm_flutter`
9 changes: 8 additions & 1 deletion packages/orm_flutter_ffi/lib/src/bindings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ import '_generate_bindings.dart';

DynamicLibrary get _dl {
if (Platform.isIOS) {
return DynamicLibrary.open('orm_flutter_ios.framework/orm_flutter_ios');
// Try open SPM generated library.
try {
return DynamicLibrary.open('orm-flutter-ios.framework/orm-flutter-ios');

// Fallback open podspec defined library.
} catch (_) {
return DynamicLibrary.open('orm_flutter_ios.framework/orm_flutter_ios');
}
} else if (Platform.isAndroid) {
return DynamicLibrary.open("liborm_flutter_android.so");
}
Expand Down
6 changes: 3 additions & 3 deletions packages/orm_flutter_ffi/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ homepage: https://prisma.pub
repository: https://github.com/medz/prisma-dart

resolution: workspace
version: 0.0.1
version: 0.0.2

funding:
- https://github.com/sponsors/medz
Expand All @@ -19,8 +19,8 @@ dependencies:
sdk: flutter
ffi: ^2.1.3
orm: ^5.2.1
orm_flutter_android: ^0.0.1
orm_flutter_ios: ^0.0.2
orm_flutter_android: ^0.0.2
orm_flutter_ios: ^0.0.4
path_provider: ^2.1.5
path: ^1.9.0

Expand Down
4 changes: 4 additions & 0 deletions packages/orm_flutter_ios/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v0.0.4

* Support Swift Package Manager

## v0.0.3

* Upgrade Prisma CABI engine to `v6.0.0`.
Expand Down
33 changes: 33 additions & 0 deletions packages/orm_flutter_ios/ios/orm_flutter_ios/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// swift-tools-version: 5.9

import PackageDescription

let package = Package(
name: "orm_flutter_ios",
platforms: [
.iOS(.v12)
],
products: [
.library(
name: "orm-flutter-ios",
type: .dynamic,
targets: ["query_engine_bridge"]
)
],
targets: [
.target(
name: "query_engine_bridge",
dependencies: [
.target(name: "PrismaQueryEngine")
],
linkerSettings: [
.linkedFramework("CoreFoundation"),
.linkedFramework("Security"),
]
),
.binaryTarget(
name: "PrismaQueryEngine",
path: "Frameworks/QueryEngine.xcframework"
),
]
)
2 changes: 1 addition & 1 deletion packages/orm_flutter_ios/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: "Dynamic library implementation library for Prisma Dart and Flutter
homepage: https://prisma.pub

resolution: workspace
version: 0.0.3
version: 0.0.4

funding:
- https://github.com/sponsors/medz
Expand Down

0 comments on commit 9de30ea

Please sign in to comment.