I am trying to install alamofire pod file in my flutter project but I
got error like 'framework not found Alamofire'
I run pod install in my iOS folder its give error like 'framework not found Alamofire'
I have add pod file code
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
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!
pod 'Alamofire'#
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')
# 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('.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('.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'
end
end
end
ld: warning: directory not found for option '-F/Users/admin/Library/Developer/Xcode/DerivedData/Runner-cmruivjpakthlvdshvwqbtebetrj/Build/Products/Debug-iphoneos/Alamofire'
ld: framework not found SwiftyJSON
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Its solved I have just add following code https://github.com/mravn-google/flutter/blob/e0c73220a6f69d341ce436244212277d83bc189b/packages/flutter_tools/templates/cocoapods/Podfile-swift#L70-L73
Related
The current error I`m having is:
I build on android studio and no problem so far
Run pod install and everything checks out
I press build on XCode and this is the error I find.
Task :shared_core:linkPodDebugFrameworkIos FAILED
e: Could not find "/Users/xxxx/android/shared_core/build/classes/kotlin/ios/main/klib/shared_core.klib" in [/Users/xxxx/ios/Pods, /Users/mac/.konan/klib, /Users/mac/.konan/kotlin-native-prebuilt-macos-x86_64-1.6.10/klib/common, /Users/mac/.konan/kotlin-native-prebuilt-macos-x86_64-1.6.10/klib/platform/ios_x64]
It happens both with multiplatform 1.5.31 and 1.6.10.
Obs:
The file is there.
Both Xcode, Android Studio and Terminal and Cocoapods have Full Disk access.
Obs2: My Folder structure is
- root folder
- android folder
- ios folder
Obs3: My podspec file:
Pod::Spec.new do |spec|
spec.name = 'shared_core'
spec.version = '1.0'
spec.homepage = 'Link to the Shared Module homepage'
spec.source = { :git => "Not Published", :tag => "Cocoapods/#{spec.name}/#{spec.version}" }
spec.authors = ''
spec.license = ''
spec.summary = 'Some description for the Shared Module'
spec.vendored_frameworks = "build/cocoapods/framework/shared_core.framework"
spec.libraries = "c++"
spec.module_name = "#{spec.name}_umbrella"
spec.ios.deployment_target = '11'
spec.pod_target_xcconfig = {
'KOTLIN_PROJECT_PATH' => ':shared_core',
'PRODUCT_MODULE_NAME' => 'shared_core',
}
spec.script_phases = [
{
:name => 'Build shared_core',
:execution_position => :before_compile,
:shell_path => '/bin/sh',
:script => <<-SCRIPT
if [ "YES" = "$COCOAPODS_SKIP_KOTLIN_BUILD" ]; then
echo "Skipping Gradle build task invocation due to COCOAPODS_SKIP_KOTLIN_BUILD environment variable set to \"YES\""
exit 0
fi
set -ev
REPO_ROOT="$PODS_TARGET_SRCROOT"
"$REPO_ROOT/../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \
-Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \
-Pkotlin.native.cocoapods.archs="$ARCHS" \
-Pkotlin.native.cocoapods.configuration=$CONFIGURATION \
-Pkotlin.native.cocoapods.cflags="$OTHER_CFLAGS" \
-Pkotlin.native.cocoapods.paths.headers="$HEADER_SEARCH_PATHS" \
-Pkotlin.native.cocoapods.paths.frameworks="$FRAMEWORK_SEARCH_PATHS"
SCRIPT
}
]
end
And here's my PodFile:
target 'MyTarget' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
pod 'shared_core', :path => '../android/shared_core'
end
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
end
end
I really have no idea what's going one, this project built before, and nothing changed, and now it's not finishing the build.
I have project MySingleViewApp and framework MyFramework. Both are fresh created xcode projects and just added podfile to MySingleViewApp and podspec file to MyFramework.
this is MySingleVIewApp pod file;
target 'MySingleVIewApp' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks! :linkage => :static
pod 'MyFramework', :path => '../MyFramework'
target 'MySingleVIewAppTests' do
inherit! :search_paths
# Pods for testing
end
target 'MySingleVIewAppUITests' do
# Pods for testing
end
end
And this is MyFramework podspec file
Pod::Spec.new do |s|
s.name = "MyFramework"
s.version = "1.0.0"
s.summary = "bla"
s.description = <<-DESC
some description
DESC
s.homepage = "https://github.com/github_account/my-framework"
# brief license entry:
s.license = "MIT"
# optional - use expanded license entry instead:
# s.license = { :type => "MIT", :file => "LICENSE" }
s.authors = { "Your Name" => "yourname#email.com" }
s.platforms = { :ios => "11.0" }
s.source = { :git => "https://github.com/github_account/my-framework.git", :tag => "#{s.version}" }
s.requires_arc = true
s.swift_version = "5.1.2"
s.vendored_frameworks = 'MyFramework.framework'
s.static_framework = true
s.dependency "UserSDK"
end
When run MySingleVIewApp project i get error
dyld: Library not loaded:
#rpath/GoogleUtilities.framework/GoogleUtilities Referenced from: Frameworks/UserSDK.framework/UserSDK Reason: image not found
If i add UserSDK(which is spec dependency of MyFramework) and remove MyFramework from podfile it works
target 'MySingleVIewApp' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks! :linkage => :static
pod 'UserSDK'
target 'MySingleVIewAppTests' do
inherit! :search_paths
# Pods for testing
end
target 'MySingleVIewAppUITests' do
# Pods for testing
end
end
I am working on flutter project where i need to integrate my flutter code with native objective c framework(local framework).
when i am not using any flutter dependencies then its working fine but when i add any flutter dependencies e.g path_provider or image_cropper etc at that time app is showing error i.e.
1./Users//Desktop///ios/Runner/GeneratedPluginRegistrant.m:6:9: 'image_cropper/ImageCropperPlugin.h' file not found.
What i think is that this issue is because of podfile configuration because:
when i have not used "use_frameworks!" this in pod file then all dependencies which i have used in flutter can be seen in .a format(static library) along with my local framework/sdk but when i used "use_frameworks!" statement in pod all libraries along with my local SDK(framework) is coming in .framework format.
i want flutter libraries/dependencies to come in .a format and my framework to come in .framework format.
podfile that i am using:
# Uncomment this line to define a global platform for your project
platform :ios, '10.0'
use_frameworks!
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def applibs
pod 'ThirdPartySDK-Debug', :configuration => ['Debug'], :path => 'Generated_Key_IOS_SDK/Debug/ThirdPartySDK-Debug.podspec'
pod 'ThirdPartySDK-Release', :configuration => ['Release'], :path => 'Generated_Key_IOS_SDK/Release/ThirdPartySDK-Release.podspec'
end
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
workspace 'Runner.xcworkspace'
project 'Runner.xcodeproj'
applibs
# 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')
# Flutter Pods
generated_xcode_build_settings = parse_KV_file('./Flutter/Runner.xcconfig')
if generated_xcode_build_settings.empty?
puts "Runner.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first."
end
generated_xcode_build_settings.map { |p|
if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
symlink = File.join('.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('.symlinks', 'plugins', p[:name])
File.symlink(p[:path], symlink)
pod p[:name], :path => File.join(symlink, 'ios')
}
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
i want flutter libraries/dependencies to come in .a format and my framework to come in .framework format.
I'm currently trying to create a framework that relies in an external module.
That module can be added via the following script in the Podfile:
flutter_application_path = './flutter_embedding'
eval(File.read(File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')), binding)
(You can read more about this implementation here
This works fine if I run it, however, when running pod spec lint I get the following error:
- ERROR | [iOS] xcodebuild: FlutterIosFramework/flutter_ios_framework/AppDelegate.swift:10:8: error: no such module 'Flutter'
This error does not occur if I run the project normally.
So the question is, what can I do to include in the podspec file this external module that is added by a script?
If it helps, the script that is used in the snippet above is the following:
def parse_KV_file(file, separator='=')
file_abs_path = File.expand_path(file)
if !File.exists? file_abs_path
return [];
end
pods_array = []
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_array.push({:name => podname, :path => podpath});
else
puts "Invalid plugin specification: #{line}"
end
}
return pods_array
end
def flutter_root(f)
generated_xcode_build_settings = parse_KV_file(File.join(f, File.join('.ios', 'Flutter', 'Generated.xcconfig')))
if generated_xcode_build_settings.empty?
puts "Generated.xcconfig must exist. Make sure `flutter packages get` is executed in #{f}."
exit
end
generated_xcode_build_settings.map { |p|
if p[:name] == 'FLUTTER_ROOT'
return p[:path]
end
}
end
# If this wasn't specified, assume it's two levels up from the directory of this script.
flutter_application_path ||= File.join(__dir__, '..', '..')
framework_dir = File.join(flutter_application_path, '.ios', 'Flutter')
engine_dir = File.join(framework_dir, 'engine')
if !File.exist?(engine_dir)
# Copy the debug engine to have something to link against if the xcode backend script has not run yet.
debug_framework_dir = File.join(flutter_root(flutter_application_path), 'bin', 'cache', 'artifacts', 'engine', 'ios')
FileUtils.mkdir_p(engine_dir)
FileUtils.cp_r(File.join(debug_framework_dir, 'Flutter.framework'), engine_dir)
FileUtils.cp(File.join(debug_framework_dir, 'Flutter.podspec'), engine_dir)
end
pod 'Flutter', :path => engine_dir
pod 'FlutterPluginRegistrant', :path => File.join(framework_dir, 'FlutterPluginRegistrant')
symlinks_dir = File.join(framework_dir, '.symlinks')
FileUtils.mkdir_p(symlinks_dir)
plugin_pods = parse_KV_file(File.join(flutter_application_path, '.flutter-plugins'))
plugin_pods.map { |r|
symlink = File.join(symlinks_dir, r[:name])
FileUtils.rm_f(symlink)
File.symlink(r[:path], symlink)
pod r[:name], :path => File.join(symlink, 'ios')
}
# Ensure that ENABLE_BITCODE is set to NO, add a #include to Generated.xcconfig, and
# add a run script to the Build Phases.
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['CLANG_WARN_DIRECT_OBJC_ISA_USAGE'] = 'NO'
next if config.base_configuration_reference == nil
xcconfig_path = config.base_configuration_reference.real_path
File.open(xcconfig_path, 'a+') do |file|
file.puts "#include \"#{File.realpath(File.join(framework_dir, 'Generated.xcconfig'))}\""
end
end
end
end
Upon Further inspection of the file and the directories, I saw that in fact it is adding two new pods, Flutter and FlutterPluginRegistrant, and I could add them do the PodFile without the script.
I am trying to link a series of Pods together to encapsulate project functionality and have arrived at an issue.
I have 3 Pods:
IOS-Intrasonics -> contains Intrasonics.framework
IOS-Core -> contains core API and Intrasonics functionality
IOS-Consumer -> contains the consumer app that makes use of the core
Intrasonics Podspec:
Pod::Spec.new do |spec|
spec.name = 'IOS-Intrasonics'
spec.version = '1.0.7'
spec.license = {
:type => 'Copyright',
:text => <<-LICENSE
Copyright 2014 Intrasonics Limited. All rights reserved.
LICENSE
}
spec.homepage = 'http://www.intrasonics.com'
spec.authors = { 'xxxx' => 'xxxxx' }
spec.summary = 'Intrasonics SDK'
spec.source = { :git => 'git#github.com:xxxxx/IOS-Intrasonics.git', :tag => '1.0.7'}
spec.ios.deployment_target = '7.0'
spec.ios.vendored_frameworks = 'src/IntrasonicsDecoder.framework'
spec.ios.frameworks = 'AVFoundation', 'AudioToolbox'
spec.requires_arc = true
end
IOS-Core Podspec:
Pod::Spec.new do |spec|
spec.name = 'IOS-Core'
spec.version = '1.0.0'
spec.license = {
:type => 'Copyright',
:text => <<-LICENSE
Copyright 2014 xxxxxxx. All rights reserved.
LICENSE
}
spec.authors = { 'xxxx' => 'xxxx' }
spec.homepage = 'xxxx'
spec.summary = 'Core'
spec.source = { :git => 'git#github.com:xxxx/IOS-Core.git', :tag => '1.0.0'}
spec.ios.deployment_target = '7.0'
spec.ios.public_header_files = 'Core/Core/**/*.h'
spec.ios.source_files = 'Core/Core/**/*.{h,m}'
spec.ios.dependency 'AFNetworking'
spec.ios.dependency 'IOS-Intrasonics'
spec.requires_arc = true
end
Both of these Pods are located in a private repository. Now, when I run, pod spec lint on IOS-Core, it returns this:
$ pod spec lint
-> IOS-Core (1.0.0)
- ERROR | [xcodebuild] IOS-Core/Core/Core/Models/Events/FNXCIntrasonicsEvent.m:11:9: fatal error: 'IntrasonicsDecoder/IntrasonicsDecoder.h' file not found
- ERROR | [xcodebuild] IOS-Core/Core/Core/Helpers/Core/FNXCIntrasonicsManager.m:13:9: fatal error: 'IntrasonicsDecoder/IntrasonicsDecoder.h' file not found
Analyzed 1 podspec.
[!] The spec did not pass validation.
Even though the Podspec lists IOS-Intrasonics as a dependency, it isn't linking it. IOS-Intrasonics is included in the Podfile and works in the project just fine but it doesn't work as a dependency. Please help!
This looks like it's caused by you not including any public header files in the spec where you're vendoring your framework. You'd want to do that with something like:
s.public_header_files = 'path/to/headers/*.h'
I ended up bundling in the classes I wanted to add with the framework pod instead of the pod that included the pod with the framework.