Open ag84ark opened 4 years ago
As an update, I managed to make the app work with the example provided on flutter_blue. Maybe I can get some directions on something that needs to be done for iOS apps. Again, thank!
As an update, I managed to make the app work with the example provided on flutter_blue. Maybe I can get some directions on something that needs to be done for iOS apps. Again, thank!
Hi @ag84ark , could u pls tell me how to solve this problem?
fatal error: could not build module 'protobuf'
import "GPBProtocolBuffers_RuntimeSupport.h"
I am still getting this with a fresh install of 0.6.3. Running macOS 10.15 and iOS 13.1.2. Any ideas on this one?
As an update, I managed to make the app work with the example provided on flutter_blue. Maybe I can get some directions on something that needs to be done for iOS apps. Again, thank!
Hi @ag84ark , could u pls tell me how to solve this problem?
I did not fix the problem, I just wanted to say if I try to create a project from the files in the example folder of flutter_blue, that compiles, but in my project or a new project that just has flutter_blue 0.6.x as a dependency, I can not build for iOS. So I wanted to know what the author @pauldemarco did extra on the example he provided so I can do it in my project as well to make it work. Hope I explained better this time.
Ran into the same issue(Android worked for me as well), i also tried creating a brand new flutter project and included flutter_blue(0.6.3) to see if I could rule out my project, that did not work, I get the exact same errors as @ag84ark did using current stable flutter.
`Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, v1.9.1+hotfix.5, on Mac OS X 10.14.6 18G95, locale en-US) [✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2) [✓] Xcode - develop for iOS and macOS (Xcode 11.1) [✓] Android Studio (version 3.5) [✓] VS Code (version 1.39.0) [✓] Connected device (1 available)
• No issues found!`
Hi guys, again with an update! I have managed to make the build work with something that I don't recommend :). As I said earlier the example project from flutter_blue is working good on iOS. So what I did as an experiment, I copied all the files from the working example iOS folder and paste it into my own iOS folder overwriting all the files, and to my surprise the project compiled for iOS as well. Now I have some errors in the app, but that I think is my fault :) One thing that I noticed that I think could maybe have something to do with my problem is that when I created the project I enabled swift for iOS but after I overwrote my original files from my limited objective C/swift knowledge the project went to ObjC. Maybe that is the problem for others as well. I am now trying to recreate the iOS with ObjC as the default iOS lang to see if I still encounter this problem.
I hope that my solution helps you guys, or maybe helps you find the exact problem of why it isn't working. I am still waiting for a good solution as this is not the best solution for the future of the project. Waiting for some feedback from you @bradd-pktlzyer @thermoChas @NuclearGear
Steps to take to see if it's working for you as well.
flutter create -i objc
. from the root of the project folder
This will change to ObjC from Swift.
After this compiled without any problems.
The problem that I was getting when creating a new project was because now by default flutter enables Swift instead of ObjC.Note to author: @pauldemarco project does not compile on iOS if Swift is enabled over ObjC in flutter.
@ag84ark interesting info, i just created a new flutter app like i did previously this time unchecking swift and it worked. Now I need to figure out what swift flag generates to see if I can remove that or possibly recreate my ios folder like you did, just don't want to have to reconfigure my project.
@ag84ark Finally found a workaround for me, maybe give some others more clues. I was able to get things working with 0.6.3 by commenting out
use_frameworks!
from my Podfile. I noticed that @pauldemarco does not have this in his example Podfile as he probably generated Podfile without swift.
@bradd-pktlzyer , thanks for this workaround, but if my project has other dependencies which require use_frameworks, then it will be failed.
The root cause is the preprocessor [GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS]
I tried to fix it by adding it to podspec, and it's working for my project
'GCC_PREPROCESSOR_DEFINITIONS' => ['$(inherited)', 'GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1']
@bradd-pktlzyer , thanks for this workaround, but if my project has other dependencies which require use_frameworks, then it will be failed.
The root cause is the preprocessor [GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS]
I tried to fix it by adding it to podspec, and it's working for my project
'GCC_PREPROCESSOR_DEFINITIONS' => ['$(inherited)', 'GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1']
hi @vincentsong , could u pls tell me how to solve this problem? which file should be edited? thx!
@NuclearGear you could put it into Podfile or podspec
hi @vincentsong , could u pls tell me how to modify podfile?
Hi all, I've created a dedicated Discord channel so we can debug these problems more efficiently:
Compiling flutter_blue on a Swift enabled Flutter project
Flutter projects using Swift for the iOS platform may have trouble compiling with flutter_blue:
While building module 'flutter_blue' imported from
/Users/paul/my_app/ios/Runner/GeneratedPluginRegistrant.m:10:
In file included from <module-includes>:1:
/Users/paul/my_app/build/ios/Debug-iphoneos/flutter_blue/flutter_blue.framework/Headers/fl
utter_blue-umbrella.h:13:9: fatal error: 'FlutterBluePlugin.h' file not found
#import "FlutterBluePlugin.h"
^~~~~~~~~~~~~~~~~~~~~
1 error generated.
/Users/paul/my_app/ios/Runner/GeneratedPluginRegistrant.m:10:9: fatal error: could not
build module 'flutter_blue'
@import flutter_blue;
~~~~~~~^~~~~~~~~~~~
2 errors generated.
note: Using new build systemnote: Planning buildnote: Constructing build description
From your project's root folder:
Clean everything:
rm -rf ios/Pods
rm ios/Podfile
rm ios/Podfile.lock
rm -rf ~/Library/Developer/Xcode/DerivedData/
flutter clean
flutter packages upgrade
Regenerate the Podfile with:
flutter run
Open ios/Podfile
and comment the following line:
#use_frameworks!
The project should now run successfully with:
flutter run
I can't find that line in my ios podfile?
Hi all, I've created a dedicated Discord channel so we can debug these problems more efficiently:
The invite link is invalid.
Here’s one that doesn’t expire:
On Mon, Oct 28, 2019 at 6:39 PM KevinR notifications@github.com wrote:
Hi all, I've created a dedicated Discord channel so we can debug these problems more efficiently:
Discord Invite Link https://discord.gg/K8qKgX
The invite link is invalid.
— You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/pauldemarco/flutter_blue/issues/406?email_source=notifications&email_token=AD7TN5SXQ72XZHKAYEJZ7B3QQ5SZTA5CNFSM4JCQCDD2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECOT5ZQ#issuecomment-547176166, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD7TN5WSKZBXBEFYSEMGGJDQQ5SZTANCNFSM4JCQCDDQ .
-- Warm Regards,
Paul DeMarco
@pauldemarco the removal of use_frameworks!
is breaking ios build for me due to several other plugins requiring it. Are there other alternatives?
@ekuleshov At the moment, the alternative would be to make sure your flutter project was generated with objective-c for the ios side. You can regenerate by deleting the ios folder (assuming you made no custom changes), and regenerating with:
flutter create -i objc .
I am working on finding an actual solution for using flutter_blue with projects that use swift.
Thank you for letting us know.
Here's another user w/ dependencies that require use_frameworks!.
Does the the PROTOBUF-podspec line work? And compatible with use_frameworks! ? https://github.com/pauldemarco/flutter_blue/issues/406#issuecomment-544762898
I am working on finding an actual solution for using flutter_blue with projects that use swift.
Any progress or update on a fix for this?
The related flutter framework issue https://github.com/flutter/flutter/issues/16049 has someone's notes on manually forcing swift (or objc) headers to be generated, which might be related to this, but I can't follow the steps
Hi, I had a similar error. It couldn't find "Flutterblue.pbobjc.h". After tryin all the solutions above with no luck, I ended up editing ios/Pods/Headers/Public/flutter_blue/flutter_blue-umbrella.h and replacing
#import "Flutterblue.pbobjc.h"
by
#import "gen/Flutterblue.pbobjc.h"
and it seems to work.
just install the right cocoa and it will work.
Steps to take to see if it's working for you as well.
- Delete the iOS folder in your app
- run:
flutter create -i objc
. from the root of the project folder This will change to ObjC from Swift. After this compiled without any problems. The problem that I was getting when creating a new project was because now by default flutter enables Swift instead of ObjC.Note to author: @pauldemarco project does not compile on iOS if Swift is enabled over ObjC in flutter.
This actually works for me after wasting 2 days. Thank you
It works only if your project doesn't have swift code AND not using any swift-based plugins. If project uses swift plugins this solution is at no help. I believe @pauldemarco is aware
open ios/Runner.xcworkspaces
go to Pods > Build Phases > Headers
move flutter_blue-umbralla.h
& FlutterBluePlugin.h
& Flutterblue.pbobjc.h
to Public Group
then edit Flutterblue.pbobjc.h
replacing #import "gen/Flutterblue.pbobjc.h"
by #import "Flutterblue.pbobjc.h"
There you go!
Hi all,
still having the error:
While building module 'flutter_blue' imported from /.../Runner/GeneratedPluginRegistrant.m:10:
In file included from
when using CodeMagic to build the project... I've tried almost every step described above. Locally it builds fine but when using CI/CD like codemagic it still fails with this error.
Does anyone have any insights about WHY this fails?
@JohnGorter I am building on CodeMagic, currently my workaround is I have a post clone script that uninstalls all of cocoapods and installs version 1.7.5 every build, this is working well for me. I am using flutter stable and flutter_blue: 0.6.3+1.
gem uninstall cocoapods --all
gem install cocoapods -v 1.7.5
that worked! Thanks very much
@bradd-pktlzyer Wow thank you so much!
I am able to run a debug mode application, but if try to build a release in XCode got this error:
ld: warning: directory not found for option '-L /Library/Developer/Xcode/DerivedData/Runner-bsbiahtqtxjlsjbcltenmajuttqn/ArchiveIntermediates/Runner/BuildProductsPath/Release-iphoneos/shared_preferences' ld: library not found for -lProtobuf clang: error: linker command failed with exit code 1 (use -v to see invocation)
Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Mac OS X 10.15.2 19C57, locale pt-BR)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2) [✓] Xcode - develop for iOS and macOS (Xcode 11.3.1) [✓] Android Studio (version 3.5) [✓] VS Code (version 1.41.1) [✓] Connected device (1 available)
• No issues found!
What is wrong?
While building module 'flutter_blue' imported from /Users/debasis/works/flutter/projects/ble_wifi/ios/Runner/GeneratedPluginRegistrant.m:10:
In file included from <module-includes>:1:
/Users/debasis/Library/Developer/Xcode/DerivedData/Runner-gfkbodfpfhhsnqepptisvjdnimxi/Build/Products/Debug-iphoneos/flutter_blue/flutter_blue.framework/Headers/flutter_blue-umbrella.h:13:9: fatal error: 'FlutterBluePlugin.h' file not found
#import "FlutterBluePlugin.h"
^~~~~~~~~~~~~~~~~~~~~
1 error generated.
/Users/debasis/works/flutter/projects/ble_wifi/ios/Runner/GeneratedPluginRegistrant.m:10:9: fatal error: could not build module 'flutter_blue'
@import flutter_blue;
~~~~~~~^~~~~~~~~~~~
2 errors generated.
it was a real pain to get it going, i had to collect bits of answers to pass the run stage, but eventually got it to work, here is a complete ordered list of what i did:
(basically i started with a flutter hello world)
1. flutter create blue_test
2. cd blue_test
3. add all your code and dependencies to pubspec.yaml (without flutter_blue)
4. flutter clean (in case it is another run or existing project)
5. flutter packages get
6. flutter create -i objc .
7. flutter run (make sure it runs properly without the flutter_blue dependency)
8. add to pubspec.yaml:
flutter_blue: ^0.6.3+1
9. sudo gem uninstall cocoapods --all
10. sudo gem install cocoapods
11. pod cache clean --all
12. in the Podfile (found under ios) add this at the top of the file:
platform :ios, '10.0'
13. in ios folder open the 'Runner.xcworkspace' file in xCode and:
* make sure - Runner->project->Runner->info->Configurations->
debug,release and profile are set to none, close the xcode
* from xcode, make sure Runner->project->Runner->info->deployment target is 10.0
* make sure project Runner->Targets->Runner->Signing & Capabilities has a team selected
* goto: Runner->Targets->Runner->Build Settings->User-Defined and make sure
there is a key FLUTTER_ROOT and it is set to your flutter SDK folder
14. cd ios
15. pod install
16. cd ..
17. add to info.plist (under ios/Runner after the <dict> tag):
<!-- When in use -->
<key>NSLocationWhenInUseUsageDescription</key>
<string>Reason why app needs location</string>
<!-- Always -->
<!-- for iOS 11 + -->
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Reason why app needs location</string>
<!-- for iOS 9/10 -->
<key>NSLocationAlwaysUsageDescription</key>
<string>Reason why app needs location</string>
<!-- Bluetooth Privacy -->
<!-- for iOS 13 + -->
<key>NSBluetoothAlwaysUsageDescription</key>
<string>Reason why app needs bluetooth</string>
18. flutter run
if for some reason this flow still wont work for you (because you use swift code, or have different dependecies that cross versions...) - these are the steps others did as well (but wasn't required for my case), you can try some of them or all of them, they can't hurt the ios project:
* in the project root folder run:
ln -s ios/Pods Pods
* this solution: https://github.com/pauldemarco/flutter_blue/issues/406#issuecomment-572910336
* note: this tip can break your project, so be carefull and backup
- cd ios
- edit ios/Podfile
- remove the line: use_frameworks!
* make sure flutter SDK root is set in your xcode workspase: [https://github.com/flutter/flutter/issues/17234#issuecomment-409832533](url)
hope this will help someone
@shaybc I just never see a podfile in the IOS folder under you line item 12. The file never gets generated. Any idea?
@shaybc I just never see a podfile in the IOS folder under you line item 12. The file never gets generated. Any idea?
assuming:
sudo gem install cocoapods
pubspec.yaml
file (after the dependencies:
section with 2 spaces indention before each dependency)then when you do flutter build ios
(from the root project directory) you should see the created files in ios folder:
- Podfile
- Podfile.lock
if you still don't see it, then you can do this:
1. manually add a Pod file
2. cd ios
3. pod deintegrate
4. pod setup
5. pod install
Podfile example:
# Uncomment this line to define a global platform for your project
platform :ios, '10.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
use_frameworks!
use_modular_headers!
# 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
read more ideas here: https://stackoverflow.com/a/53492243/530884
@debasiskoley I did read somewhere to add a deepclean script like this:
pod repo update rm ios/Podfile rm ios/Podfile.lock rm -rf ios/Pods/ rm .flutter-plugins rm .packages rm pubspec.lock flutter packages get flutter clean
After that the pod file got created.
@pauldemarco 0.7.0 still does not build on iOS, same error about gen/Flutterblue.pbobjc.h. Any chances for a fix?
@b055man Are you available for a discord chat sometime today so I can investigate the issue? http://discord.gg/Yk5Efra
@pauldemarco joined.
There was a problem with xcode which just got release - make sure you update
@ride4sun any links to the xcode problem?
I just committed a potential fix and was able to build the example project and a swift project successfully, without any workarounds. Please test your projects by targeting the master branch of flutter in your pubspec, like so:
dependencies:
flutter_blue:
git: git://github.com/pauldemarco/flutter_blue.git
Let me know the results.
Thanks!
@ride4sun any links to the xcode problem? https://github.com/flutter/flutter/issues/52868 https://github.com/flutter/flutter/issues/49504#issuecomment-592767041
@pauldemarco build now working on iOS
@pauldemarco yup, I'm able to build as well. Thanks!
@pauldemarco I think that can be closed
I still can't make ios build work when pubspec has mix of ios and swift plugin dependencies
If u take flutter_blue out of the picture can u build than?
I am trying to build for iOS and i can not. I have the latest version of flutter_blue, I have created a new project and just added this plugin and when I try to build I get the error below. I was using 0.6.2 version in my project and was working fine on Android, then tried it on iOS with no success, then I tried to update the version to 0.6.3 with no luck. Then I created a new project just to be sure that was nothing from my project that made the problem, and I got the same problem. I looked through the issues, and could not get the problem resolved. Please help. Thank you very much.
Flutter doctor: ` Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel master, v1.10.15-pre.186, on Mac OS X 10.15 19A602, locale en-FR) [✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3) [✓] Xcode - develop for iOS and macOS (Xcode 11.1) [✓] Android Studio (version 3.5) [✓] IntelliJ IDEA Ultimate Edition (version 2019.2.3) [✓] VS Code (version 1.39.2) [✓] Connected device (1 available)
• No issues found! `
` Running pod install... 1.6s Running Xcode build...
Xcode build done. 10.1s Failed to build iOS app Error output from Xcode build: ↳ 2019-10-19 16:35:17.770 xcodebuild[10186:1800491] [MT] PluginLoading: Required plug-in compatibility UUID 92CB09D8-3B74-4EF7-849C-99816039F0E7 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/MarmaladeGCC.xcplugin' not present in DVTPlugInCompatibilityUUIDs 2019-10-19 16:35:17.770 xcodebuild[10186:1800491] Failed to load plugin at: /Users/cojogeo/Library/Application Support/Developer/Shared/Xcode/Plug-ins/MarmaladeGCC.xcplugin, skipping. Reason for failure: * -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0] BUILD FAILED **
Xcode's output: ↳ While building module 'protobuf' imported from /Users/cojogeo/development/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_blue-0.6.3/ios/gen/Flutterblue.pbobjc.m:13: In file included from:1:
In file included from /Users/cojogeo/flutterApps/bluetoothtest1/ios/Pods/Target Support Files/Protobuf/Protobuf-umbrella.h:28:
In file included from /Users/cojogeo/flutterApps/bluetoothtest1/ios/Pods/Protobuf/objectivec/GPBProtocolBuffers.h:44:
/Users/cojogeo/flutterApps/bluetoothtest1/ios/Pods/Protobuf/objectivec/GPBWellKnownTypes.h:44:10: fatal error: 'google/protobuf/Any.pbobjc.h' file not found
import "google/protobuf/Any.pbobjc.h"
`