diff --git a/.metadata b/.metadata new file mode 100644 index 00000000..9796a7e5 --- /dev/null +++ b/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: f53b32eb2317ba09137969999d130c24a6314997 + channel: master + +project_type: plugin diff --git a/android/build.gradle b/android/build.gradle index 6c5609ec..d7d65fdd 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -11,18 +11,17 @@ gradle.buildFinished { buildResult -> } } -group 'com.pauldemarco.flutterblue' +group 'com.pauldemarco.flutter_blue' version '1.0-SNAPSHOT' buildscript { repositories { google() jcenter() - mavenLocal() } dependencies { - classpath 'com.android.tools.build:gradle:3.3.0' + classpath 'com.android.tools.build:gradle:3.5.0' classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.10' } } @@ -31,7 +30,6 @@ rootProject.allprojects { repositories { google() jcenter() - mavenLocal() } } @@ -48,11 +46,6 @@ android { lintOptions { disable 'InvalidPackage' } - dependencies { - // Required for local unit tests (JUnit 4 framework) - testImplementation 'junit:junit:4.12' - implementation 'androidx.core:core:1.0.2' - } sourceSets { main { proto { diff --git a/android/gradle.properties b/android/gradle.properties index 8bd86f68..38c8d454 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1 +1,4 @@ org.gradle.jvmargs=-Xmx1536M +android.enableR8=true +android.useAndroidX=true +android.enableJetifier=true diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..019065d1 --- /dev/null +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index 9edd329e..7a2ef35f 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.pauldemarco.flutter_blue"> diff --git a/android/src/main/java/com/pauldemarco/flutterblue/AdvertisementParser.java b/android/src/main/java/com/pauldemarco/flutter_blue/AdvertisementParser.java similarity index 98% rename from android/src/main/java/com/pauldemarco/flutterblue/AdvertisementParser.java rename to android/src/main/java/com/pauldemarco/flutter_blue/AdvertisementParser.java index 315ffe44..c12c4803 100644 --- a/android/src/main/java/com/pauldemarco/flutterblue/AdvertisementParser.java +++ b/android/src/main/java/com/pauldemarco/flutter_blue/AdvertisementParser.java @@ -25,10 +25,10 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -package com.pauldemarco.flutterblue; +package com.pauldemarco.flutter_blue; import com.google.protobuf.ByteString; -import com.pauldemarco.flutterblue.Protos.AdvertisementData; +import com.pauldemarco.flutter_blue.Protos.AdvertisementData; import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; diff --git a/android/src/main/java/com/pauldemarco/flutterblue/FlutterBluePlugin.java b/android/src/main/java/com/pauldemarco/flutter_blue/FlutterBluePlugin.java similarity index 99% rename from android/src/main/java/com/pauldemarco/flutterblue/FlutterBluePlugin.java rename to android/src/main/java/com/pauldemarco/flutter_blue/FlutterBluePlugin.java index 5dd56a2e..32b23454 100644 --- a/android/src/main/java/com/pauldemarco/flutterblue/FlutterBluePlugin.java +++ b/android/src/main/java/com/pauldemarco/flutter_blue/FlutterBluePlugin.java @@ -2,7 +2,7 @@ // All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -package com.pauldemarco.flutterblue; +package com.pauldemarco.flutter_blue; import android.app.Activity; import android.Manifest; @@ -53,9 +53,7 @@ import io.flutter.plugin.common.PluginRegistry.RequestPermissionsResultListener; -/** - * FlutterBluePlugin - */ +/** FlutterBluePlugin */ public class FlutterBluePlugin implements MethodCallHandler, RequestPermissionsResultListener { private static final String TAG = "FlutterBluePlugin"; private static final String NAMESPACE = "plugins.pauldemarco.com/flutter_blue"; @@ -74,9 +72,7 @@ public class FlutterBluePlugin implements MethodCallHandler, RequestPermissionsR private MethodCall pendingCall; private Result pendingResult; - /** - * Plugin registration. - */ + /** Plugin registration. */ public static void registerWith(Registrar registrar) { final FlutterBluePlugin instance = new FlutterBluePlugin(registrar); registrar.addRequestPermissionsResultListener(instance); diff --git a/android/src/main/java/com/pauldemarco/flutterblue/ProtoMaker.java b/android/src/main/java/com/pauldemarco/flutter_blue/ProtoMaker.java similarity index 99% rename from android/src/main/java/com/pauldemarco/flutterblue/ProtoMaker.java rename to android/src/main/java/com/pauldemarco/flutter_blue/ProtoMaker.java index 0740b1e0..31e758a8 100644 --- a/android/src/main/java/com/pauldemarco/flutterblue/ProtoMaker.java +++ b/android/src/main/java/com/pauldemarco/flutter_blue/ProtoMaker.java @@ -2,7 +2,7 @@ // All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -package com.pauldemarco.flutterblue; +package com.pauldemarco.flutter_blue; import android.annotation.TargetApi; import android.bluetooth.BluetoothDevice; diff --git a/example/.gitignore b/example/.gitignore index 47e0b4d6..437cb458 100644 --- a/example/.gitignore +++ b/example/.gitignore @@ -1,6 +1,5 @@ # Miscellaneous *.class -*.lock *.log *.pyc *.swp @@ -16,8 +15,10 @@ *.iws .idea/ -# Visual Studio Code related -.vscode/ +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ # Flutter/Dart/Pub related **/doc/api/ @@ -26,46 +27,10 @@ .packages .pub-cache/ .pub/ -build/ +/build/ -# Android related -**/android/**/gradle-wrapper.jar -**/android/.gradle -**/android/captures/ -**/android/gradlew -**/android/gradlew.bat -**/android/local.properties -**/android/**/GeneratedPluginRegistrant.java - -# iOS/XCode related -**/ios/**/*.mode1v3 -**/ios/**/*.mode2v3 -**/ios/**/*.moved-aside -**/ios/**/*.pbxuser -**/ios/**/*.perspectivev3 -**/ios/**/*sync/ -**/ios/**/.sconsign.dblite -**/ios/**/.tags* -**/ios/**/.vagrant/ -**/ios/**/DerivedData/ -**/ios/**/Icon? -**/ios/**/Pods/ -**/ios/**/.symlinks/ -**/ios/**/profile -**/ios/**/xcuserdata -**/ios/.generated/ -**/ios/Flutter/App.framework -**/ios/Flutter/Flutter.framework -**/ios/Flutter/Generated.xcconfig -**/ios/Flutter/app.flx -**/ios/Flutter/app.zip -**/ios/Flutter/flutter_assets/ -**/ios/ServiceDefinitions.json -**/ios/Runner/GeneratedPluginRegistrant.* +# Web related +lib/generated_plugin_registrant.dart # Exceptions to above rules. -!**/ios/**/default.mode1v3 -!**/ios/**/default.mode2v3 -!**/ios/**/default.pbxuser -!**/ios/**/default.perspectivev3 !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages diff --git a/example/.metadata b/example/.metadata new file mode 100644 index 00000000..2b288502 --- /dev/null +++ b/example/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: f53b32eb2317ba09137969999d130c24a6314997 + channel: master + +project_type: app diff --git a/example/README.md b/example/README.md index 9f0cd815..e19fbb22 100644 --- a/example/README.md +++ b/example/README.md @@ -4,5 +4,13 @@ Demonstrates how to use the flutter_blue plugin. ## Getting Started -For help getting started with Flutter, view our online -[documentation](http://flutter.io/). +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) + +For help getting started with Flutter, view our +[online documentation](https://flutter.dev/docs), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/example/android.iml b/example/android.iml deleted file mode 100644 index 462b903e..00000000 --- a/example/android.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/example/android/.gitignore b/example/android/.gitignore new file mode 100644 index 00000000..bc2100d8 --- /dev/null +++ b/example/android/.gitignore @@ -0,0 +1,7 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 8b09d65c..758061cf 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -32,7 +32,7 @@ android { } defaultConfig { - applicationId "com.pauldemarco.flutterblueexample" + applicationId "com.pauldemarco.flutter_blue_example" minSdkVersion 19 targetSdkVersion 28 versionCode flutterVersionCode.toInteger() diff --git a/example/android/app/src/debug/AndroidManifest.xml b/example/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 00000000..925f1de2 --- /dev/null +++ b/example/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index 1113a9dd..c05ef495 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -1,12 +1,5 @@ - - - - + package="com.pauldemarco.flutter_blue_example"> + + diff --git a/example/android/build.gradle b/example/android/build.gradle index 541636cc..e0d7ae2c 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -5,7 +5,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.3.0' + classpath 'com.android.tools.build:gradle:3.5.0' } } diff --git a/example/android/gradle.properties b/example/android/gradle.properties index 53ae0ae4..38c8d454 100644 --- a/example/android/gradle.properties +++ b/example/android/gradle.properties @@ -1,3 +1,4 @@ -android.enableJetifier=true -android.useAndroidX=true org.gradle.jvmargs=-Xmx1536M +android.enableR8=true +android.useAndroidX=true +android.enableJetifier=true diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index 2819f022..296b146b 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip diff --git a/example/ios/.gitignore b/example/ios/.gitignore new file mode 100644 index 00000000..e96ef602 --- /dev/null +++ b/example/ios/.gitignore @@ -0,0 +1,32 @@ +*.mode1v3 +*.mode2v3 +*.moved-aside +*.pbxuser +*.perspectivev3 +**/*sync/ +.sconsign.dblite +.tags* +**/.vagrant/ +**/DerivedData/ +Icon? +**/Pods/ +**/.symlinks/ +profile +xcuserdata +**/.generated/ +Flutter/App.framework +Flutter/Flutter.framework +Flutter/Flutter.podspec +Flutter/Generated.xcconfig +Flutter/app.flx +Flutter/app.zip +Flutter/flutter_assets/ +Flutter/flutter_export_environment.sh +ServiceDefinitions.json +Runner/GeneratedPluginRegistrant.* + +# Exceptions to above rules. +!default.mode1v3 +!default.mode2v3 +!default.pbxuser +!default.perspectivev3 diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index 9367d483..6b4c0f78 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -3,7 +3,7 @@ CFBundleDevelopmentRegion - en + $(DEVELOPMENT_LANGUAGE) CFBundleExecutable App CFBundleIdentifier diff --git a/example/ios/Podfile b/example/ios/Podfile new file mode 100644 index 00000000..98a90b8a --- /dev/null +++ b/example/ios/Podfile @@ -0,0 +1,87 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '9.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def parse_KV_file(file, separator='=') + file_abs_path = File.expand_path(file) + if !File.exists? file_abs_path + return []; + end + generated_key_values = {} + skip_line_start_symbols = ["#", "/"] + File.foreach(file_abs_path) do |line| + next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ } + plugin = line.split(pattern=separator) + if plugin.length == 2 + podname = plugin[0].strip() + path = plugin[1].strip() + podpath = File.expand_path("#{path}", file_abs_path) + generated_key_values[podname] = podpath + else + puts "Invalid plugin specification: #{line}" + end + end + generated_key_values +end + +target 'Runner' do + # Flutter Pod + + copied_flutter_dir = File.join(__dir__, 'Flutter') + copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework') + copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec') + unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path) + # Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet. + # That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration. + # CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist. + + generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig') + unless File.exist?(generated_xcode_build_settings_path) + raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path) + cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR']; + + unless File.exist?(copied_framework_path) + FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir) + end + unless File.exist?(copied_podspec_path) + FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir) + end + end + + # Keep pod path relative so it can be checked into Podfile.lock. + pod 'Flutter', :path => 'Flutter' + + # Plugin Pods + + # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock + # referring to absolute paths on developers' machines. + system('rm -rf .symlinks') + system('mkdir -p .symlinks/plugins') + plugin_pods = parse_KV_file('../.flutter-plugins') + plugin_pods.each do |name, path| + symlink = File.join('.symlinks', 'plugins', name) + File.symlink(path, symlink) + pod name, :path => File.join(symlink, 'ios') + end +end + +# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system. +install! 'cocoapods', :disable_input_output_paths => true + +post_install do |installer| + installer.pods_project.targets.each do |target| + target.build_configurations.each do |config| + config.build_settings['ENABLE_BITCODE'] = 'NO' + end + end +end diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock new file mode 100644 index 00000000..71e5fcfe --- /dev/null +++ b/example/ios/Podfile.lock @@ -0,0 +1,32 @@ +PODS: + - Flutter (1.0.0) + - flutter_blue (0.0.1): + - Flutter + - flutter_blue/Protos (= 0.0.1) + - flutter_blue/Protos (0.0.1): + - Flutter + - Protobuf + - Protobuf (3.10.0) + +DEPENDENCIES: + - Flutter (from `Flutter`) + - flutter_blue (from `.symlinks/plugins/flutter_blue/ios`) + +SPEC REPOS: + trunk: + - Protobuf + +EXTERNAL SOURCES: + Flutter: + :path: Flutter + flutter_blue: + :path: ".symlinks/plugins/flutter_blue/ios" + +SPEC CHECKSUMS: + Flutter: 0e3d915762c693b495b44d77113d4970485de6ec + flutter_blue: 763739beea88e81195eb6cb8693d530057430feb + Protobuf: a4dc852ad69c027ca2166ed287b856697814375b + +PODFILE CHECKSUM: 3dbe063e9c90a5d7c9e4e76e70a821b9e2c1d271 + +COCOAPODS: 1.8.4 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index cfaa4c95..8fc5bbc7 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -8,7 +8,6 @@ /* Begin PBXBuildFile section */ 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; - 23175688AA110A51F809F778 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 60D991E9C9B0195ABB61DAFF /* libPods-Runner.a */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; }; 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; @@ -19,6 +18,7 @@ 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; + BC840DD82826110B54BA6046 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 037D6201B3317D19077DBE1C /* libPods-Runner.a */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -37,17 +37,17 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 037D6201B3317D19077DBE1C /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 03F90B064E5989CDFA6AE40B /* 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 = ""; }; 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; - 1972BFE8FFDC21C33AA378B2 /* 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 = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; }; - 496C03649F7E3036B107E8CF /* 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 = ""; }; - 60D991E9C9B0195ABB61DAFF /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - 654AF8D0FB3F7BFE3766A2D2 /* 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 = ""; }; + 5FD1D91DB4DD22B46C0A30FB /* 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 = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 90D362CFC65AB38900749923 /* 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 = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; }; @@ -66,23 +66,13 @@ files = ( 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */, 3B80C3941E831B6300D905FE /* App.framework in Frameworks */, - 23175688AA110A51F809F778 /* libPods-Runner.a in Frameworks */, + BC840DD82826110B54BA6046 /* libPods-Runner.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 30F11C343C5FF369427FEE15 /* Pods */ = { - isa = PBXGroup; - children = ( - 496C03649F7E3036B107E8CF /* Pods-Runner.debug.xcconfig */, - 654AF8D0FB3F7BFE3766A2D2 /* Pods-Runner.release.xcconfig */, - 1972BFE8FFDC21C33AA378B2 /* Pods-Runner.profile.xcconfig */, - ); - path = Pods; - sourceTree = ""; - }; 9740EEB11CF90186004384FC /* Flutter */ = { isa = PBXGroup; children = ( @@ -102,8 +92,8 @@ 9740EEB11CF90186004384FC /* Flutter */, 97C146F01CF9000F007C117D /* Runner */, 97C146EF1CF9000F007C117D /* Products */, - 30F11C343C5FF369427FEE15 /* Pods */, - FF555442636EC2F707A35FC6 /* Frameworks */, + 9FA2C22F3442E6B32D987688 /* Pods */, + FE7C0B0D97F9B20AF18716C5 /* Frameworks */, ); sourceTree = ""; }; @@ -139,10 +129,21 @@ name = "Supporting Files"; sourceTree = ""; }; - FF555442636EC2F707A35FC6 /* Frameworks */ = { + 9FA2C22F3442E6B32D987688 /* Pods */ = { + isa = PBXGroup; + children = ( + 03F90B064E5989CDFA6AE40B /* Pods-Runner.debug.xcconfig */, + 90D362CFC65AB38900749923 /* Pods-Runner.release.xcconfig */, + 5FD1D91DB4DD22B46C0A30FB /* Pods-Runner.profile.xcconfig */, + ); + name = Pods; + path = Pods; + sourceTree = ""; + }; + FE7C0B0D97F9B20AF18716C5 /* Frameworks */ = { isa = PBXGroup; children = ( - 60D991E9C9B0195ABB61DAFF /* libPods-Runner.a */, + 037D6201B3317D19077DBE1C /* libPods-Runner.a */, ); name = Frameworks; sourceTree = ""; @@ -154,14 +155,14 @@ isa = PBXNativeTarget; buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( - 725D073084925181E8D21DCC /* [CP] Check Pods Manifest.lock */, + F70296DE928E36AB7322BF47 /* [CP] Check Pods Manifest.lock */, 9740EEB61CF901F6004384FC /* Run Script */, 97C146EA1CF9000F007C117D /* Sources */, 97C146EB1CF9000F007C117D /* Frameworks */, 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, - 696B38C9567D8F47DB5731B6 /* [CP] Embed Pods Frameworks */, + 25F30DD022E5D3EED9183A8A /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -178,7 +179,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1030; + LastUpgradeCheck = 1020; ORGANIZATIONNAME = "The Chromium Authors"; TargetAttributes = { 97C146ED1CF9000F007C117D = { @@ -188,10 +189,9 @@ }; buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( - English, en, Base, ); @@ -220,6 +220,21 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ + 25F30DD022E5D3EED9183A8A /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + ); + 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; buildActionMask = 2147483647; @@ -234,22 +249,21 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin"; }; - 696B38C9567D8F47DB5731B6 /* [CP] Embed Pods Frameworks */ = { + 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "[CP] Embed Pods Frameworks"; + name = "Run Script"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; - showEnvVarsInLog = 0; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; }; - 725D073084925181E8D21DCC /* [CP] Check Pods Manifest.lock */ = { + F70296DE928E36AB7322BF47 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -271,20 +285,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; }; - 9740EEB61CF901F6004384FC /* Run Script */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Run Script"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; - }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -325,7 +325,6 @@ baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -366,6 +365,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; @@ -377,7 +377,6 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = ""; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -389,7 +388,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterBlueExample; + PRODUCT_BUNDLE_IDENTIFIER = com.pauldemarco.flutterBlueExample; PRODUCT_NAME = "$(TARGET_NAME)"; VERSIONING_SYSTEM = "apple-generic"; }; @@ -400,7 +399,6 @@ baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -457,7 +455,6 @@ baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -498,6 +495,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; @@ -509,7 +507,6 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = ""; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -521,7 +518,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterBlueExample; + PRODUCT_BUNDLE_IDENTIFIER = com.pauldemarco.flutterBlueExample; PRODUCT_NAME = "$(TARGET_NAME)"; VERSIONING_SYSTEM = "apple-generic"; }; @@ -533,7 +530,6 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = ""; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -545,7 +541,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = com.example.flutterBlueExample; + PRODUCT_BUNDLE_IDENTIFIER = com.pauldemarco.flutterBlueExample; PRODUCT_NAME = "$(TARGET_NAME)"; VERSIONING_SYSTEM = "apple-generic"; }; diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 12f056a5..a28140cf 100644 --- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ CFBundleDevelopmentRegion - en + $(DEVELOPMENT_LANGUAGE) CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier diff --git a/ios/.gitignore b/ios/.gitignore index 710ec6cf..aa479fd3 100644 --- a/ios/.gitignore +++ b/ios/.gitignore @@ -34,3 +34,4 @@ Icon? .tags* /Flutter/Generated.xcconfig +/Flutter/flutter_export_environment.sh \ No newline at end of file diff --git a/ios/flutter_blue.podspec b/ios/flutter_blue.podspec index c2c42f69..8774abfc 100644 --- a/ios/flutter_blue.podspec +++ b/ios/flutter_blue.podspec @@ -1,46 +1,32 @@ # -# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html +# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. +# Run `pod lib lint flutter_blue.podspec' to validate before publishing. # Pod::Spec.new do |s| s.name = 'flutter_blue' s.version = '0.0.1' - s.summary = 'A new flutter plugin project.' + s.summary = 'Bluetooth Low Energy plugin for Flutter.' s.description = <<-DESC -A new flutter plugin project. +Bluetooth Low Energy plugin for Flutter. DESC - s.homepage = 'http://example.com' + s.homepage = 'https://github.com/pauldemarco/flutter_blue' s.license = { :file => '../LICENSE' } - s.author = { 'Your Company' => 'email@example.com' } + s.author = { 'Paul DeMarco' => 'paulmdemarco@gmail.com' } s.source = { :path => '.' } s.source_files = 'Classes/**/*' s.public_header_files = 'Classes/**/*.h' s.dependency 'Flutter' - s.dependency '!ProtoCompiler' + s.platform = :ios, '8.0' s.framework = 'CoreBluetooth' - protoc = ENV['PWD'] + '/Pods/!ProtoCompiler/protoc' - objc_out = 'gen' - proto_in = '../protos' - s.prepare_command = <<-CMD - mkdir -p #{objc_out} - #{protoc} \ - --objc_out=#{objc_out} \ - --proto_path=#{proto_in} \ - #{proto_in}/*.proto - CMD - s.subspec 'Protos' do |ss| ss.source_files = 'gen/**/*.pbobjc.{h,m}' - ss.header_mappings_dir = 'gen' + ss.header_mappings_dir = '.' ss.requires_arc = false ss.dependency 'Protobuf' end - s.pod_target_xcconfig = { - # This is needed by all pods that depend on Protobuf: - 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1', - } - - s.ios.deployment_target = '8.0' -end + # 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', } +end \ No newline at end of file diff --git a/protos/flutterblue.proto b/protos/flutterblue.proto index 0d2830ef..d6bd191a 100644 --- a/protos/flutterblue.proto +++ b/protos/flutterblue.proto @@ -4,7 +4,7 @@ syntax = "proto3"; -option java_package = "com.pauldemarco.flutterblue"; +option java_package = "com.pauldemarco.flutter_blue"; option java_outer_classname = "Protos"; option objc_class_prefix = "Protos"; diff --git a/pubspec.yaml b/pubspec.yaml index 4ab3ee70..240fbe13 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,11 +16,11 @@ dependencies: protobuf: "^0.14.1" rxdart: "^0.22.0" -flutter: - plugin: - androidPackage: com.pauldemarco.flutterblue - pluginClass: FlutterBluePlugin - dev_dependencies: flutter_test: sdk: flutter + +flutter: + plugin: + androidPackage: com.pauldemarco.flutter_blue + pluginClass: FlutterBluePlugin diff --git a/test/flutter_blue_test.dart b/test/flutter_blue_test.dart new file mode 100644 index 00000000..67f69906 --- /dev/null +++ b/test/flutter_blue_test.dart @@ -0,0 +1,23 @@ +import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:flutter_blue/flutter_blue.dart'; + +void main() { + const MethodChannel channel = MethodChannel('flutter_blue'); + + TestWidgetsFlutterBinding.ensureInitialized(); + + setUp(() { + channel.setMockMethodCallHandler((MethodCall methodCall) async { + return '42'; + }); + }); + + tearDown(() { + channel.setMockMethodCallHandler(null); + }); + + test('getPlatformVersion', () async { + expect(await FlutterBlue.platformVersion, '42'); + }); +}