# https://github.com/CocoaPods/Core/blob/master/lib/cocoapods-core/podfile/dsl.rb#L256

$REGISTERED_DEPENDENCIES = Hash.new
$REGISTER_MODE = true

$g_flutter_path = ''
fbFlutterPath = ''
fbJsonPath = File.join(File.dirname(__FILE__), 'fbconfig.local.json')
if File.exists? fbJsonPath
    fbjson = File.read(fbJsonPath)
    fbConfig = JSON.parse(fbjson)
    if fbConfig['flutterPath']
        fbFlutterPath = fbConfig['flutterPath']
    end
    if fbFlutterPath == nil
    	# @sunxiao5 ， 如果拿不到fbconfig.local.json的值，那么直接退出，报错即可
	    p "fbconfig.local.json's path is nil"
	    exit(-1)
	end

	flutter_application_path = fbFlutterPath
	eval(File.read(File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper_sn.rb')), binding)

	# @sunxiao5， 全局变量g_flutter_path，用来给外面的Podfile提供flutter module的路径
	# btw，这就是所谓ruby-eval原罪了
	$g_flutter_path = flutter_application_path
	install_all_flutter_pods(flutter_application_path)
else
	#@sunxiao5，如果不存在fbconfig.local.json文件，那说明是在native状态下，直接加入pod即可
	pod 'Flutter', :git => 'git@git.staff.sina.com.cn:SinaInnovationIOS/sn-flutter.git'
    pod 'flutter_boost', :git => 'git@git.staff.sina.com.cn:SinaInnovationIOS/sn-flutter-boot.git'
    pod 'FlutterPluginRegistrant', :git => 'git@git.staff.sina.com.cn:SinaInnovationIOS/blog-flutter-plugin-registrant.git'
    pod 'FlutterApp', :git => 'git@git.staff.sina.com.cn:SinaInnovationIOS/blog-flutter-app.git'
end

$REGISTER_MODE = false
