Skip to content

Commit 9f4ddae

Browse files
[jni] Add macOS support for Flutter apps
1 parent 7efefec commit 9f4ddae

File tree

21 files changed

+245
-92
lines changed

21 files changed

+245
-92
lines changed

Diff for: .github/workflows/jnigen.yaml

+19
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,25 @@ jobs:
352352
- run: flutter pub get
353353
- run: flutter build windows
354354

355+
build_jni_example_macos:
356+
runs-on: macos-latest
357+
defaults:
358+
run:
359+
working-directory: ./pkgs/jni/example
360+
steps:
361+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
362+
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1
363+
with:
364+
channel: 'stable'
365+
cache: true
366+
cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:'
367+
- uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9
368+
with:
369+
distribution: 'temurin'
370+
java-version: '11'
371+
- run: flutter pub get
372+
- run: flutter build macos
373+
355374
build_jni_example_android:
356375
runs-on: ubuntu-latest
357376
defaults:

Diff for: pkgs/jni/.metadata

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
# This file tracks properties of this Flutter project.
22
# Used by Flutter tool to assess capabilities and perform upgrades etc.
33
#
4-
# This file should be version controlled.
4+
# This file should be version controlled and should not be manually edited.
55

66
version:
7-
revision: 676cefaaff197f27424942307668886253e1ec35
8-
channel: stable
7+
revision: "a14f74ff3a1cbd521163c5f03d68113d50af93d3"
8+
channel: "stable"
99

1010
project_type: plugin_ffi
1111

1212
# Tracks metadata for the flutter migrate command
1313
migration:
1414
platforms:
1515
- platform: root
16-
create_revision: 676cefaaff197f27424942307668886253e1ec35
17-
base_revision: 676cefaaff197f27424942307668886253e1ec35
16+
create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3
17+
base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3
1818
- platform: android
19-
create_revision: 676cefaaff197f27424942307668886253e1ec35
20-
base_revision: 676cefaaff197f27424942307668886253e1ec35
19+
create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3
20+
base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3
2121
- platform: linux
22-
create_revision: 676cefaaff197f27424942307668886253e1ec35
23-
base_revision: 676cefaaff197f27424942307668886253e1ec35
22+
create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3
23+
base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3
2424
- platform: macos
25-
create_revision: 676cefaaff197f27424942307668886253e1ec35
26-
base_revision: 676cefaaff197f27424942307668886253e1ec35
25+
create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3
26+
base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3
2727
- platform: windows
28-
create_revision: 676cefaaff197f27424942307668886253e1ec35
29-
base_revision: 676cefaaff197f27424942307668886253e1ec35
28+
create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3
29+
base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3
3030

3131
# User provided section
3232

Diff for: pkgs/jni/example/lib/main.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44

55
// ignore_for_file: library_private_types_in_public_api
66

7-
import 'package:flutter/material.dart';
8-
9-
import 'dart:io';
107
import 'dart:ffi';
8+
import 'dart:io';
119

10+
import 'package:flutter/material.dart';
1211
import 'package:jni/jni.dart';
1312

1413
// An example of calling JNI methods using low level primitives.

Diff for: pkgs/jni/example/macos/Podfile.lock

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
PODS:
2+
- FlutterMacOS (1.0.0)
3+
- jni (0.0.1):
4+
- FlutterMacOS
5+
6+
DEPENDENCIES:
7+
- FlutterMacOS (from `Flutter/ephemeral`)
8+
- jni (from `Flutter/ephemeral/.symlinks/plugins/jni/macos`)
9+
10+
EXTERNAL SOURCES:
11+
FlutterMacOS:
12+
:path: Flutter/ephemeral
13+
jni:
14+
:path: Flutter/ephemeral/.symlinks/plugins/jni/macos
15+
16+
SPEC CHECKSUMS:
17+
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
18+
jni: d08848714503eb300e23d543183127c08ac62572
19+
20+
PODFILE CHECKSUM: 353c8bcc5d5b0994e508d035b5431cfe18c1dea7
21+
22+
COCOAPODS: 1.15.2

Diff for: pkgs/jni/example/macos/Runner.xcodeproj/project.pbxproj

+66-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
archiveVersion = 1;
44
classes = {
55
};
6-
objectVersion = 51;
6+
objectVersion = 54;
77
objects = {
88

99
/* Begin PBXAggregateTarget section */
@@ -21,6 +21,7 @@
2121
/* End PBXAggregateTarget section */
2222

2323
/* Begin PBXBuildFile section */
24+
31B9E26D2EB59CABB0AF863B /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C69C493CCDF4A533867FCC8D /* Pods_Runner.framework */; };
2425
335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; };
2526
33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; };
2627
33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; };
@@ -54,7 +55,7 @@
5455
/* Begin PBXFileReference section */
5556
333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = "<group>"; };
5657
335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = "<group>"; };
57-
33CC10ED2044A3C60003C045 /* jni_example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "jni_example.app"; sourceTree = BUILT_PRODUCTS_DIR; };
58+
33CC10ED2044A3C60003C045 /* jni_example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = jni_example.app; sourceTree = BUILT_PRODUCTS_DIR; };
5859
33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
5960
33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = "<group>"; };
6061
33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = "<group>"; };
@@ -67,14 +68,19 @@
6768
33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = "<group>"; };
6869
33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = "<group>"; };
6970
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = "<group>"; };
71+
908AD9024D8CB7D20F75E75C /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
7072
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = "<group>"; };
73+
AE07195FEB458C1E77D7E93E /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
74+
C69C493CCDF4A533867FCC8D /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
75+
D0492A503298F9672919BFDC /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
7176
/* End PBXFileReference section */
7277

7378
/* Begin PBXFrameworksBuildPhase section */
7479
33CC10EA2044A3C60003C045 /* Frameworks */ = {
7580
isa = PBXFrameworksBuildPhase;
7681
buildActionMask = 2147483647;
7782
files = (
83+
31B9E26D2EB59CABB0AF863B /* Pods_Runner.framework in Frameworks */,
7884
);
7985
runOnlyForDeploymentPostprocessing = 0;
8086
};
@@ -99,6 +105,7 @@
99105
33CEB47122A05771004F2AC0 /* Flutter */,
100106
33CC10EE2044A3C60003C045 /* Products */,
101107
D73912EC22F37F3D000D13A0 /* Frameworks */,
108+
7E661A13EA75E31F6546B680 /* Pods */,
102109
);
103110
sourceTree = "<group>";
104111
};
@@ -145,9 +152,20 @@
145152
path = Runner;
146153
sourceTree = "<group>";
147154
};
155+
7E661A13EA75E31F6546B680 /* Pods */ = {
156+
isa = PBXGroup;
157+
children = (
158+
AE07195FEB458C1E77D7E93E /* Pods-Runner.debug.xcconfig */,
159+
D0492A503298F9672919BFDC /* Pods-Runner.release.xcconfig */,
160+
908AD9024D8CB7D20F75E75C /* Pods-Runner.profile.xcconfig */,
161+
);
162+
path = Pods;
163+
sourceTree = "<group>";
164+
};
148165
D73912EC22F37F3D000D13A0 /* Frameworks */ = {
149166
isa = PBXGroup;
150167
children = (
168+
C69C493CCDF4A533867FCC8D /* Pods_Runner.framework */,
151169
);
152170
name = Frameworks;
153171
sourceTree = "<group>";
@@ -159,11 +177,13 @@
159177
isa = PBXNativeTarget;
160178
buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */;
161179
buildPhases = (
180+
CE1500691A1FFA23834C0C88 /* [CP] Check Pods Manifest.lock */,
162181
33CC10E92044A3C60003C045 /* Sources */,
163182
33CC10EA2044A3C60003C045 /* Frameworks */,
164183
33CC10EB2044A3C60003C045 /* Resources */,
165184
33CC110E2044A8840003C045 /* Bundle Framework */,
166185
3399D490228B24CF009A79C7 /* ShellScript */,
186+
3AA03BDC61C212440CD3E30B /* [CP] Embed Pods Frameworks */,
167187
);
168188
buildRules = (
169189
);
@@ -182,7 +202,7 @@
182202
isa = PBXProject;
183203
attributes = {
184204
LastSwiftUpdateCheck = 0920;
185-
LastUpgradeCheck = 1300;
205+
LastUpgradeCheck = 1510;
186206
ORGANIZATIONNAME = "";
187207
TargetAttributes = {
188208
33CC10EC2044A3C60003C045 = {
@@ -235,6 +255,7 @@
235255
/* Begin PBXShellScriptBuildPhase section */
236256
3399D490228B24CF009A79C7 /* ShellScript */ = {
237257
isa = PBXShellScriptBuildPhase;
258+
alwaysOutOfDate = 1;
238259
buildActionMask = 2147483647;
239260
files = (
240261
);
@@ -270,6 +291,45 @@
270291
shellPath = /bin/sh;
271292
shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire";
272293
};
294+
3AA03BDC61C212440CD3E30B /* [CP] Embed Pods Frameworks */ = {
295+
isa = PBXShellScriptBuildPhase;
296+
buildActionMask = 2147483647;
297+
files = (
298+
);
299+
inputFileListPaths = (
300+
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
301+
);
302+
name = "[CP] Embed Pods Frameworks";
303+
outputFileListPaths = (
304+
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
305+
);
306+
runOnlyForDeploymentPostprocessing = 0;
307+
shellPath = /bin/sh;
308+
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
309+
showEnvVarsInLog = 0;
310+
};
311+
CE1500691A1FFA23834C0C88 /* [CP] Check Pods Manifest.lock */ = {
312+
isa = PBXShellScriptBuildPhase;
313+
buildActionMask = 2147483647;
314+
files = (
315+
);
316+
inputFileListPaths = (
317+
);
318+
inputPaths = (
319+
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
320+
"${PODS_ROOT}/Manifest.lock",
321+
);
322+
name = "[CP] Check Pods Manifest.lock";
323+
outputFileListPaths = (
324+
);
325+
outputPaths = (
326+
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
327+
);
328+
runOnlyForDeploymentPostprocessing = 0;
329+
shellPath = /bin/sh;
330+
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";
331+
showEnvVarsInLog = 0;
332+
};
273333
/* End PBXShellScriptBuildPhase section */
274334

275335
/* Begin PBXSourcesBuildPhase section */
@@ -344,7 +404,7 @@
344404
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
345405
GCC_WARN_UNUSED_FUNCTION = YES;
346406
GCC_WARN_UNUSED_VARIABLE = YES;
347-
MACOSX_DEPLOYMENT_TARGET = 10.11;
407+
MACOSX_DEPLOYMENT_TARGET = 10.14;
348408
MTL_ENABLE_DEBUG_INFO = NO;
349409
SDKROOT = macosx;
350410
SWIFT_COMPILATION_MODE = wholemodule;
@@ -423,7 +483,7 @@
423483
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
424484
GCC_WARN_UNUSED_FUNCTION = YES;
425485
GCC_WARN_UNUSED_VARIABLE = YES;
426-
MACOSX_DEPLOYMENT_TARGET = 10.11;
486+
MACOSX_DEPLOYMENT_TARGET = 10.14;
427487
MTL_ENABLE_DEBUG_INFO = YES;
428488
ONLY_ACTIVE_ARCH = YES;
429489
SDKROOT = macosx;
@@ -470,7 +530,7 @@
470530
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
471531
GCC_WARN_UNUSED_FUNCTION = YES;
472532
GCC_WARN_UNUSED_VARIABLE = YES;
473-
MACOSX_DEPLOYMENT_TARGET = 10.11;
533+
MACOSX_DEPLOYMENT_TARGET = 10.14;
474534
MTL_ENABLE_DEBUG_INFO = NO;
475535
SDKROOT = macosx;
476536
SWIFT_COMPILATION_MODE = wholemodule;

Diff for: pkgs/jni/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1300"
3+
LastUpgradeVersion = "1510"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Diff for: pkgs/jni/example/macos/Runner.xcworkspace/contents.xcworkspacedata

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: pkgs/jni/example/macos/Runner/DebugProfile.entitlements

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<plist version="1.0">
44
<dict>
55
<key>com.apple.security.app-sandbox</key>
6-
<true/>
6+
<false/>
77
<key>com.apple.security.cs.allow-jit</key>
88
<true/>
99
<key>com.apple.security.network.server</key>

Diff for: pkgs/jni/example/macos/Runner/Release.entitlements

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
<plist version="1.0">
44
<dict>
55
<key>com.apple.security.app-sandbox</key>
6-
<true/>
6+
<false/>
77
</dict>
88
</plist>

Diff for: pkgs/jni/example/pubspec.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ packages:
200200
path: ".."
201201
relative: true
202202
source: path
203-
version: "0.9.3"
203+
version: "0.11.0-wip"
204204
js:
205205
dependency: transitive
206206
description:

0 commit comments

Comments
 (0)