Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
856a90e6
Unverified
Commit
856a90e6
authored
Nov 09, 2019
by
Jenn Magder
Committed by
GitHub
Nov 09, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add swift_versions to plugin template podspec, include default CocoaPod version (#44324)
parent
076bea38
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
169 additions
and
4 deletions
+169
-4
plugin_lint_mac.dart
dev/devicelab/bin/tasks/plugin_lint_mac.dart
+138
-4
projectName.podspec.tmpl
...s/templates/plugin/ios-objc.tmpl/projectName.podspec.tmpl
+0
-0
pluginClass.m.tmpl
...emplates/plugin/ios-swift.tmpl/Classes/pluginClass.m.tmpl
+7
-0
projectName.podspec.tmpl
.../templates/plugin/ios-swift.tmpl/projectName.podspec.tmpl
+23
-0
projectName.podspec.tmpl
...ools/templates/plugin/macos.tmpl/projectName.podspec.tmpl
+1
-0
No files found.
dev/devicelab/bin/tasks/plugin_lint_mac.dart
View file @
856a90e6
...
@@ -13,10 +13,11 @@ import 'package:path/path.dart' as path;
...
@@ -13,10 +13,11 @@ import 'package:path/path.dart' as path;
/// to confirm the plugin module can be imported into an app.
/// to confirm the plugin module can be imported into an app.
Future
<
void
>
main
()
async
{
Future
<
void
>
main
()
async
{
await
task
(()
async
{
await
task
(()
async
{
section
(
'Create Objective-C iOS plugin'
);
final
Directory
tempDir
=
Directory
.
systemTemp
.
createTempSync
(
'flutter_plugin_test.'
);
final
Directory
tempDir
=
Directory
.
systemTemp
.
createTempSync
(
'flutter_plugin_test.'
);
try
{
try
{
section
(
'Create Objective-C plugin'
);
const
String
objcPluginName
=
'test_plugin_objc'
;
const
String
objcPluginName
=
'test_plugin_objc'
;
await
inDirectory
(
tempDir
,
()
async
{
await
inDirectory
(
tempDir
,
()
async
{
await
flutter
(
await
flutter
(
...
@@ -31,8 +32,10 @@ Future<void> main() async {
...
@@ -31,8 +32,10 @@ Future<void> main() async {
);
);
});
});
final
String
objcPodspecPath
=
path
.
join
(
tempDir
.
path
,
objcPluginName
,
'ios'
,
'
$objcPluginName
.podspec'
);
section
(
'Lint Objective-C iOS podspec plugin as framework'
);
section
(
'Lint Objective-C iOS plugin as framework'
);
final
String
objcPluginPath
=
path
.
join
(
tempDir
.
path
,
objcPluginName
);
final
String
objcPodspecPath
=
path
.
join
(
objcPluginPath
,
'ios'
,
'
$objcPluginName
.podspec'
);
await
inDirectory
(
tempDir
,
()
async
{
await
inDirectory
(
tempDir
,
()
async
{
await
exec
(
await
exec
(
'pod'
,
'pod'
,
...
@@ -45,7 +48,8 @@ Future<void> main() async {
...
@@ -45,7 +48,8 @@ Future<void> main() async {
);
);
});
});
section
(
'Lint Objective-C iOS plugin as library'
);
section
(
'Lint Objective-C iOS podspec plugin as library'
);
await
inDirectory
(
tempDir
,
()
async
{
await
inDirectory
(
tempDir
,
()
async
{
await
exec
(
await
exec
(
'pod'
,
'pod'
,
...
@@ -59,6 +63,136 @@ Future<void> main() async {
...
@@ -59,6 +63,136 @@ Future<void> main() async {
);
);
});
});
section
(
'Create Swift plugin'
);
const
String
swiftPluginName
=
'test_plugin_swift'
;
await
inDirectory
(
tempDir
,
()
async
{
await
flutter
(
'create'
,
options:
<
String
>[
'--org'
,
'io.flutter.devicelab'
,
'--template=plugin'
,
'--ios-language=swift'
,
swiftPluginName
,
],
);
});
section
(
'Create Objective-C application'
);
const
String
objcAppName
=
'test_app_objc'
;
await
inDirectory
(
tempDir
,
()
async
{
await
flutter
(
'create'
,
options:
<
String
>[
'--org'
,
'io.flutter.devicelab'
,
'--ios-language=objc'
,
objcAppName
,
],
);
});
section
(
'Build Objective-C application with Swift and Objective-C plugins as libraries'
);
final
String
objcAppPath
=
path
.
join
(
tempDir
.
path
,
objcAppName
);
final
String
swiftPluginPath
=
path
.
join
(
tempDir
.
path
,
swiftPluginName
);
final
File
objcPubspec
=
File
(
path
.
join
(
objcAppPath
,
'pubspec.yaml'
));
String
podspecContent
=
objcPubspec
.
readAsStringSync
();
podspecContent
=
podspecContent
.
replaceFirst
(
'
\n
dependencies:
\n
'
,
'
\n
dependencies:
\n
$objcPluginName
:
\n
path:
$objcPluginPath
\n
$swiftPluginName
:
\n
path:
$swiftPluginPath
\n
'
,
);
objcPubspec
.
writeAsStringSync
(
podspecContent
,
flush:
true
);
await
inDirectory
(
objcAppPath
,
()
async
{
await
flutter
(
'build'
,
options:
<
String
>[
'ios'
,
'--no-codesign'
],
// TODO(jmagman): Make Objective-C applications handle Swift libraries https://github.com/flutter/flutter/issues/16049
canFail:
true
);
});
final
File
objcPodfile
=
File
(
path
.
join
(
objcAppPath
,
'ios'
,
'Podfile'
));
String
objcPodfileContent
=
objcPodfile
.
readAsStringSync
();
if
(
objcPodfileContent
.
contains
(
'use_frameworks!'
))
{
return
TaskResult
.
failure
(
'Expected default Objective-C Podfile to not contain use_frameworks'
);
}
section
(
'Build Objective-C application with Swift and Objective-C plugins as frameworks'
);
objcPodfileContent
=
'use_frameworks!
\n
'
+
objcPodfileContent
;
objcPodfile
.
writeAsStringSync
(
objcPodfileContent
,
flush:
true
);
await
inDirectory
(
objcAppPath
,
()
async
{
await
flutter
(
'build'
,
options:
<
String
>[
'ios'
,
'--no-codesign'
],
);
});
section
(
'Create Swift application'
);
const
String
swiftAppName
=
'test_app_swift'
;
await
inDirectory
(
tempDir
,
()
async
{
await
flutter
(
'create'
,
options:
<
String
>[
'--org'
,
'io.flutter.devicelab'
,
'--ios-language=swift'
,
swiftAppName
,
],
);
});
section
(
'Build Swift application with Swift and Objective-C plugins as frameworks'
);
final
String
swiftAppPath
=
path
.
join
(
tempDir
.
path
,
swiftAppName
);
final
File
swiftPubspec
=
File
(
path
.
join
(
swiftAppPath
,
'pubspec.yaml'
));
swiftPubspec
.
writeAsStringSync
(
podspecContent
,
flush:
true
);
await
inDirectory
(
swiftAppPath
,
()
async
{
await
flutter
(
'build'
,
options:
<
String
>[
'ios'
,
'--no-codesign'
],
);
});
final
File
swiftPodfile
=
File
(
path
.
join
(
swiftAppPath
,
'ios'
,
'Podfile'
));
String
swiftPodfileContent
=
swiftPodfile
.
readAsStringSync
();
if
(!
swiftPodfileContent
.
contains
(
'use_frameworks!'
))
{
return
TaskResult
.
failure
(
'Expected default Swift Podfile to contain use_frameworks'
);
}
section
(
'Build Swift application with Swift and Objective-C plugins as libraries'
);
swiftPodfileContent
=
swiftPodfileContent
.
replaceAll
(
'use_frameworks!'
,
''
);
swiftPodfile
.
writeAsStringSync
(
swiftPodfileContent
,
flush:
true
);
await
inDirectory
(
swiftAppPath
,
()
async
{
await
flutter
(
'build'
,
options:
<
String
>[
'ios'
,
'--no-codesign'
],
);
});
return
TaskResult
.
success
(
null
);
return
TaskResult
.
success
(
null
);
}
catch
(
e
)
{
}
catch
(
e
)
{
return
TaskResult
.
failure
(
e
.
toString
());
return
TaskResult
.
failure
(
e
.
toString
());
...
...
packages/flutter_tools/templates/plugin/ios.tmpl/projectName.podspec.tmpl
→
packages/flutter_tools/templates/plugin/ios
-objc
.tmpl/projectName.podspec.tmpl
View file @
856a90e6
File moved
packages/flutter_tools/templates/plugin/ios-swift.tmpl/Classes/pluginClass.m.tmpl
View file @
856a90e6
#import "{{pluginClass}}.h"
#import "{{pluginClass}}.h"
#if __has_include(<{{projectName}}/{{projectName}}-Swift.h>)
#import <{{projectName}}/{{projectName}}-Swift.h>
#import <{{projectName}}/{{projectName}}-Swift.h>
#else
// Support project import fallback if the generated compatibility header
// is not copied when this plugin is created as a library.
// https://forums.swift.org/t/swift-static-libraries-dont-copy-generated-objective-c-header/19816
#import "{{projectName}}-Swift.h"
#endif
@implementation {{pluginClass}}
@implementation {{pluginClass}}
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
...
...
packages/flutter_tools/templates/plugin/ios-swift.tmpl/projectName.podspec.tmpl
0 → 100644
View file @
856a90e6
#
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
# Run `pod lib lint {{projectName}}.podspec' to validate before publishing.
#
Pod::Spec.new do |s|
s.name = '{{projectName}}'
s.version = '0.0.1'
s.summary = '{{description}}'
s.description = <<-DESC
{{description}}
DESC
s.homepage = 'http://example.com'
s.license = { :file => '../LICENSE' }
s.author = { 'Your Company' => 'email@example.com' }
s.source = { :path => '.' }
s.source_files = 'Classes/**/*'
s.dependency 'Flutter'
s.platform = :ios, '8.0'
# Flutter.framework does not contain a i386 slice. Only x86_64 simulators are supported.
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS[sdk=iphonesimulator*]' => 'x86_64' }
s.swift_version = '5.0'
end
packages/flutter_tools/templates/plugin/macos.tmpl/projectName.podspec.tmpl
View file @
856a90e6
...
@@ -18,4 +18,5 @@ Pod::Spec.new do |s|
...
@@ -18,4 +18,5 @@ Pod::Spec.new do |s|
s.platform = :osx, '10.11'
s.platform = :osx, '10.11'
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
s.swift_version = '5.0'
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment