这是indexloc提供的服务,不要输入任何密码
Skip to content

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

Merged
merged 6 commits into from
Aug 20, 2019

Conversation

jonahwilliams
Copy link
Contributor

@jonahwilliams jonahwilliams commented Aug 17, 2019

Description

TBD: which Info.plist should I be using?

Template created from xcode, copyright removed and flutter bundle identifier added.

Fixes #38728

@fluttergithubbot fluttergithubbot added the tool Affects the "flutter" command-line tool. See also t: labels. label Aug 17, 2019
@codecov
Copy link

codecov bot commented Aug 17, 2019

Codecov Report

Merging #38748 into master will decrease coverage by 0.1%.
The diff coverage is 83.87%.

Impacted file tree graph

@@            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
Flag Coverage Δ
#flutter_tool 56.13% <83.87%> (-0.11%) ⬇️
Impacted Files Coverage Δ
...tter_tools/lib/src/build_system/targets/macos.dart 50.41% <83.87%> (+8.57%) ⬆️
...ackages/flutter_tools/lib/src/commands/config.dart 52% <0%> (-34.67%) ⬇️
...ckages/flutter_tools/lib/src/commands/devices.dart 53.84% <0%> (-23.08%) ⬇️
packages/flutter_tools/lib/src/device.dart 54.81% <0%> (-2.41%) ⬇️
...ages/flutter_tools/lib/src/linux/linux_device.dart 41.3% <0%> (-2.18%) ⬇️
.../flutter_tools/lib/src/android/android_device.dart 32% <0%> (-2%) ⬇️
packages/flutter_tools/lib/src/version.dart 90.73% <0%> (-1.96%) ⬇️
packages/flutter_tools/lib/src/cache.dart 43.02% <0%> (-0.73%) ⬇️
.../flutter_tools/lib/src/fuchsia/fuchsia_device.dart 55.01% <0%> (-0.38%) ⬇️
packages/flutter_tools/lib/src/project.dart 82.58% <0%> (+0.32%) ⬆️
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8edc3f7...7487c7a. Read the comment docs.

Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/resources/binary/

Copy link
Contributor Author

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');
Copy link
Contributor

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.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@jonahwilliams
Copy link
Contributor Author

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'''
Copy link
Contributor

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?

Copy link
Contributor Author

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>
Copy link
Member

@jmagman jmagman Aug 20, 2019

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."
}

Copy link
Contributor Author

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

Copy link
Contributor Author

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?

@jonahwilliams jonahwilliams requested a review from jmagman August 20, 2019 00:35
<?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>
Copy link
Member

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')
Copy link
Member

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

Copy link
Contributor Author

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.

@jonahwilliams jonahwilliams requested a review from jmagman August 20, 2019 16:58
Copy link
Member

@jmagman jmagman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jonahwilliams jonahwilliams merged commit 2504a41 into flutter:master Aug 20, 2019
@jonahwilliams jonahwilliams deleted the fix_full_framework branch August 20, 2019 17:49
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

macOS App.framework isn't a valid macOS framework
5 participants