Changed Info.plist lookup#1542
Conversation
|
Hi @TheoGermain, would you mind helping out and doing a review on this PR? Since you added the initial code I feel your input on this could be very valuable. |
|
Hey, thanks for digging into this and providing a reproduction with the example project. The root cause you identified is correct. With global SPM enabled in Flutter 3.44+, the Adding A few things I would want to look at before merging though. The recursive subdirectory scan in What I would suggest instead is keeping the walk-up approach but using Something along these lines: func findInfoPlist() -> [String: Any] {
let fm = FileManager.default
let searchRoots: [URL] = [
URL(fileURLWithPath: #file).deletingLastPathComponent(),
URL(fileURLWithPath: fm.currentDirectoryPath),
]
var visited = Set<String>()
for root in searchRoots {
var dir = root
for _ in 0..<12 {
let key = dir.resolvingSymlinksInPath().path
guard visited.insert(key).inserted else { break }
let plistURL = dir.appendingPathComponent("ios/Runner/Info.plist")
if fm.fileExists(atPath: dir.appendingPathComponent("pubspec.yaml").path),
let plist = NSDictionary(contentsOf: plistURL) as? [String: Any] {
return plist
}
dir = dir.deletingLastPathComponent()
}
}
return [:]
}This covers both the standard SPM case and global SPM, deduplicates paths so the two roots do not overlap, and avoids any recursive directory scanning. The Finally, the example migration from CocoaPods to SPM is a great validation step, but it is a fairly significant change on its own. It might be cleaner to split it into a separate PR so the core plist lookup fix can be reviewed and merged independently. Would you be open to a narrower version of the patch focused on the |
|
@TheoGermain , thank you for detailed response.
this is new requirement from Flutter 3.41. - https://docs.flutter.dev/packages-and-plugins/swift-package-manager/for-plugin-authors#:~:text=New%20in%20Flutter%203.41!%20Add%20the%20FlutterFramework |
|
Good to know about FlutterFramework, I missed that change in 3.41. Thanks for the pointer. Looking forward to the updated patch. |
I have flutter 3.44 with global SPM enabled. I noticed on my project that all permissions pernamentlyDenied. I've read similar issues and understood that it's related to lookup of Info.plist permissions.
I tried to use permissions_handler_apple/example ios project, migrated it to SPM and permissions were pernamentlyDenided as well, only if I used launchctl "launchctl setenv PERMISSION_CAMERA 1" it worked.
So I did code changes to improve Info.plist lookup and it helped on both permissions_handler_apple/example and as dependency overwrite in my monorepo project.
Pre-launch Checklist
pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or this PR is does not need version changes.CHANGELOG.mdto add a description of the change.///).main.dart format .and committed any changes.flutter analyzeand fixed any errors.