Skip to content

Commit

Permalink
Swift utils improved to target extensions
Browse files Browse the repository at this point in the history
Swift utils improved to work with features inside target extensions
  • Loading branch information
rafaelsetragni committed Mar 15, 2023
1 parent 2566999 commit 1d50591
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions IosAwnCore/Classes/utils/SwiftUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,21 @@ public class SwiftUtils{
}
return _isExtension!
}

public static func getMainBundle() -> Bundle {
var components = Bundle.main.bundleURL.path.split(separator: "/")
var bundle: Bundle?

if let index = components.lastIndex(where: { $0.hasSuffix(".app") }) {
components.removeLast((components.count - 1) - index)
bundle = Bundle(path: components.joined(separator: "/"))
}

return bundle ?? Bundle.main
}

public static func getFlutterAssetPath(forAsset assetPath:String) -> String? {
var realPath = getMainBundle().bundlePath + "/Frameworks/App.framework/flutter_assets/" + assetPath
return realPath
}
}

0 comments on commit 1d50591

Please sign in to comment.