-
Notifications
You must be signed in to change notification settings - Fork 28.9k
Create correctly structured framework for macOS #38748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create correctly structured framework for macOS #38748
Conversation
Codecov Report
@@ Coverage Diff @@
## master #38748 +/- ##
==========================================
- Coverage 56.24% 56.13% -0.11%
==========================================
Files 195 195
Lines 18275 18298 +23
==========================================
- Hits 10278 10271 -7
- Misses 7997 8027 +30
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the plist, you'll need a template like https://github.com/flutter/flutter/blob/c40d701e9638e9182a8581ecd3634203228618a5/packages/flutter_tools/templates/app/ios.tmpl/Flutter/AppFrameworkInfo.plist
Looking at that one, I think it's probably just a stock framework plist with the bundle ID changed, so you can create a new macOS framework project in Xcode, take that, and change the ID. Please use the same bundle ID so that the FlutterDartProject change I need to do can share as much logic as possible.
if (!currentResources.existsSync()) { | ||
currentResources.createSync(fs.path.join(currentVersion.path, 'Resources')); | ||
} | ||
// Create symlink to current resources |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/resources/binary/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
} | ||
} on FileSystemException { | ||
throw Exception('Failed to create symlinks for framework. try removing ' | ||
'the "macos/Fluter/ephemeral" directory and rerunning'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flutter
(Or even better, get this from the project instead of hard-coding the string, so it won't get stale.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
I've updated the Info.plist to use one from a cocoa application created by Xcode, minus the copyright key and with the flutter bundle identifier. |
// Copy Info.plist template. | ||
assetDirectory.parent.childFile('Info.plist') | ||
..createSync() | ||
..writeAsStringSync(r''' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why inline rather than a template file like iOS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming that since this is ephemeral we don't want to require the user to manually create it each time. Using the templating is complex, It's not tested as well as I like and it relies on mirrors via a 3rd party templating library.
<string>$(MACOSX_DEPLOYMENT_TARGET)</string> | ||
<key>NSMainStoryboardFile</key> | ||
<string>Main</string> | ||
<key>NSPrincipalClass</key> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like an application Info.plist, not a Framework one. CFBundleIconFile, NSPrincipalClass, NSMainStoryboardFile keys shouldn't be there, and the CFBundlePackageType should be FMWK.
The one I just generated:
$ plutil -p Info.plist
{
"CFBundleDevelopmentRegion" => "$(DEVELOPMENT_LANGUAGE)"
"CFBundleExecutable" => "$(EXECUTABLE_NAME)"
"CFBundleIdentifier" => "$(PRODUCT_BUNDLE_IDENTIFIER)"
"CFBundleInfoDictionaryVersion" => "6.0"
"CFBundleName" => "$(PRODUCT_NAME)"
"CFBundlePackageType" => "$(PRODUCT_BUNDLE_PACKAGE_TYPE)"
"CFBundleShortVersionString" => "1.0"
"CFBundleVersion" => "$(CURRENT_PROJECT_VERSION)"
"NSHumanReadableCopyright" => "Copyright © 2019 <etc> . All rights reserved."
}
And once it was a built product from Xcode:
{
"BuildMachineOSBuild" => "18G87"
"CFBundleDevelopmentRegion" => "en"
"CFBundleExecutable" => "TestFramework"
"CFBundleIdentifier" => "com.google.TestFramework"
"CFBundleInfoDictionaryVersion" => "6.0"
"CFBundleName" => "TestFramework"
"CFBundlePackageType" => "FMWK"
"CFBundleShortVersionString" => "1.0"
"CFBundleSupportedPlatforms" => [
0 => "MacOSX"
]
"CFBundleVersion" => "1"
"DTCompiler" => "com.apple.compilers.llvm.clang.1_0"
"DTPlatformBuild" => "11M382q"
"DTPlatformVersion" => "GM"
"DTSDKBuild" => "19A526e"
"DTSDKName" => "macosx10.15"
"DTXcode" => "1100"
"DTXcodeBuild" => "11M382q"
"NSHumanReadableCopyright" => "Copyright © 2019 <etc> . All rights reserved."
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, thanks! I'll update the template
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to use the Info.plist from a cocoa framework project. I don't think we need/want the copyright key, correct?
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I should have been more clear. Because this isn't getting run through Xcode, those build setting variables probably need to be resolved.
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>App</string>
<key>CFBundleIdentifier</key>
<string>io.flutter.flutter.app</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>App</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1.0</string>
</dict>
// Copy App into framework directory. | ||
environment.buildDir | ||
.childDirectory('App.framework') | ||
.childFile('App') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This binary should also be a symlink from frameworkRootDirectory, not a copy.
Just to look at the anatomy of an embedded Xcode framework (because if they aren't getting it right then no one is) at Xcode.app/Contents/Frameworks/DFRSupportKit.framework:
lrwxr-xr-x 1 primarygroup 30 Jul 29 14:36 ./DFRSupportKit -> Versions/Current/DFRSupportKit
lrwxr-xr-x 1 primarygroup 26 Jul 29 14:36 ./Resources -> Versions/Current/Resources
drwxr-xr-x 4 primarygroup 128 Jul 29 14:51 ./Versions
drwxr-xr-x 5 primarygroup 160 Jul 26 10:01 ./Versions/A
-rwxr-xr-x 1 primarygroup 22704 Jul 26 10:01 ./Versions/A/DFRSupportKit
drwxr-xr-x 4 primarygroup 128 Jul 25 02:18 ./Versions/A/Resources
-rw-r--r-- 1 primarygroup 789 Jul 25 02:18 ./Versions/A/Resources/Info.plist
-rw-r--r-- 1 primarygroup 521 Jul 25 02:18 ./Versions/A/Resources/version.plist
drwxr-xr-x 3 primarygroup 96 Jul 25 02:18 ./Versions/A/_CodeSignature
-rw-r--r-- 1 primarygroup 2674 Jul 26 10:01 ./Versions/A/_CodeSignature/CodeResources
lrwxr-xr-x 1 primarygroup 1 Jul 29 14:36 ./Versions/Current -> A
The only non-symlink -type file
files are in Versions/A/
but the symlinks all link Versions/Current
-rwxr-xr-x 1 primarygroup 22704 Jul 26 10:01 ./Versions/A/DFRSupportKit
-rw-r--r-- 1 primarygroup 789 Jul 25 02:18 ./Versions/A/Resources/Info.plist
-rw-r--r-- 1 primarygroup 521 Jul 25 02:18 ./Versions/A/Resources/version.plist
-rw-r--r-- 1 primarygroup 2674 Jul 26 10:01 ./Versions/A/_CodeSignature/CodeResources
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The binary is located under versions/A. The copy in build_dir is in a build cache under .dart_tool/flutter_build/hashed-values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Description
TBD: which Info.plist should I be using?Template created from xcode, copyright removed and flutter bundle identifier added.
Fixes #38728