Friction adding swift plugin to objective-c project #16049
Comments
I tried these work arounds and it is still failing to build with the same error. Do I need to make any specific changes to the podfile that is being included or something too? I just did these in my app podfiles...
|
@pinkfish If so, try downgrading to 1.4.0. That's the only way I've been able to get it to work. |
@dlutton @pinkfish We have been unable to make Cocoapods 1.4.0 work all the way through to app store archives, and we'll be supporting only Cocoapods 1.5.0 or later going forward. With Cocoapods 1.5.0 and newest Flutter tooling (on master), all you should have to do is patch your
Then delete Filing issue that changing |
@mravn-google Tried cocoapods 1.5.0 and it's failing with:
|
@dlutton Would you be able to share your |
@mravn-google Podfile: # 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'
def parse_KV_file(file, separator='=')
file_abs_path = File.expand_path(file)
if !File.exists? file_abs_path
return [];
end
pods_ary = []
skip_line_start_symbols = ["#", "/"]
File.foreach(file_abs_path) { |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)
pods_ary.push({:name => podname, :path => podpath});
else
puts "Invalid plugin specification: #{line}"
end
}
return pods_ary
end
target 'Runner' do
use_frameworks!
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
# referring to absolute paths on developers' machines.
system('rm -rf Pods/.symlinks')
system('mkdir -p Pods/.symlinks/plugins')
# Flutter Pods
generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig')
if generated_xcode_build_settings.empty?
puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first."
end
generated_xcode_build_settings.map { |p|
if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
symlink = File.join('Pods', '.symlinks', 'flutter')
File.symlink(File.dirname(p[:path]), symlink)
pod 'Flutter', :path => File.join(symlink, File.basename(p[:path]))
end
}
# Plugin Pods
plugin_pods = parse_KV_file('../.flutter-plugins')
plugin_pods.map { |p|
symlink = File.join('Pods', '.symlinks', 'plugins', p[:name])
File.symlink(p[:path], symlink)
pod p[:name], :path => File.join(symlink, 'ios')
}
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
config.build_settings['SWIFT_VERSION'] = '3.2'
end
end
end pubspec.yaml name: fof
description: A new Flutter project.
dependencies:
flutter:
sdk: flutter
connectivity:
flutter_tts:
share: "^0.3.1"
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.0
dev_dependencies:
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
assets:
- assets/failure.webp
- assets/fortune.webp
- assets/LaunchImage.png
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.io/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.io/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
fonts:
- family: Lato
fonts:
- asset: fonts/Lato-Regular.ttf
weight: 400
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.io/custom-fonts/#from-packages
|
The |
Adding an empty Swift file to your Flutter iOS project in Xcode and accepting to add bridging header also works. |
Okay I’ll try that out thank you |
@mravn-google I confirmed it's working with cocoapods 1.5.0. Thank you sir |
@mravn-google can you explain how to
Where am I creating this file and what is a bridging header? |
@goodis0 Did you find an answer to this? Trying to add a pub package to a project I created with |
Can confirm that @mravn-google provided a simple and effective fix #16049 (comment) |
Hmmm, something happened... Just tried on
All good then. Thanks again! |
On my hand, I must share my experience with the plugin open_appstore, which has the same issue apparently. When trying to
#11000 (comment) fixed my first issue, pretty easily. Then, second issue: I've faced this terrible error message, very complicated to get it fixed, after hours of effort :
I've added the following changes to
Apparently, not enough - I was still facing the issue after I know the correct fix would be the one suggested by @jmagman #16049 (comment) I guess I'm using an Objective-C project. I know I need to add I ended up using the workaround as suggested by @mravn-google : #16049 (comment)
After this, I was able to build iOS archive ( Perhaps it's also important to mention that I'm using version 1.8.4 of cocoapods, Xcode version 10.2.1 and flutter version 1.9.1+hotfix4 I hope my experience can save a headache to any other iOS novice developers like me :) Thank you all for your solutions! |
In case you follow all the steps in #16049 (comment) and running
Using XCode 11.3.1 I wasn't able to find
I Hope it helps. |
Thanks a lot @nerder for this addition, it definitely helps! I was also struggling with my own instructions a few days ago, I wasn't able to find Swift Language Version with the new Xcode update, but you gave the correct fix! Thanks again! |
Hi, I am getting below error while building and archiving iOS app. " /Users//.pub-cache/hosted/pub.dartlang.org/device_calendar-3.1.0/ios/Classes/DeviceCalendarPlugin.m:2:9: fatal error: and Sometimes Any idea? |
@ssivagnanam If your app is Objective-C, you can add
If your app is Swift, you can add post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
...
config.build_settings['SWIFT_VERSION'] = '5.0' // Or whatever Swift version your app is using that works with your plugins
end
end
end The real answer is that the maintainers of device-calendar update their podspec to support Swift, see #44324 and #16049 (comment) s.swift_version = '5.0' |
flutter create
a non-swift projectIn
pubspec.yaml
, add a swift plugin such asflutter_iap
.flutter run
warns aboutuse_frameworks!
frompod install
. Easy to resolve so far.The “Swift Language Version” (SWIFT_VERSION) build setting must be set to a supported value for targets which use Swift. This setting can be set in the build settings editor.
error.Seems like swift pod developers need to specify
s.pod_target_xcconfig = { 'SWIFT_VERSION' => <a version above 2.3 for it to work with Xcode 9> }
in their podspec. Added temporary hack in Podfile with
and re-
pod install
3.
Add
and
to make it work.
Wonder if we can add some automatic handling of swift plugins in the default objective-c project's Podfile
The text was updated successfully, but these errors were encountered: