Skip to content
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

Xcode 9: Automatically detect selected provisioning profiles of the Xcode project #9460

Merged
merged 6 commits into from
Jun 30, 2017

Conversation

KrauseFx
Copy link
Member

@KrauseFx KrauseFx commented Jun 13, 2017

This way fastlane will just keep working with Xcode 9 even for setups that don't use match (yet).

Xcode 9 requires a mapping of bundle identifier and what provisioning profile to use. We use xcodeproj to find those values, but in a way that gym doesn't break if we can't detect those things

I also verified that things work fine if you pass non-existent bundle identifier/profiles, Xcode will just ignore them 👍

Fixes #9380 even more

Output when running it:
screen shot 2017-06-13 at 2 46 41 pm

Error message if it's not auto-detected, catching Xcode error, and linking to the new docs :)
screen shot 2017-06-13 at 2 41 55 pm

…code project

This way fastlane will just keep working with Xcode 9 even for setups that don't use _match_ (yet).

Xcode 9 requires a mapping of bundle identifier and what provisioning profile to use. We use `xcodeproj` to find those values, but in a way that _gym_ doesn't break if we can't detect those things

I also verified that things work fine if you pass non-existent bundle identifier/profiles, Xcode will just ignore them 👍
Copy link
Contributor

@ohayon ohayon left a comment

Choose a reason for hiding this comment

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

This looks great! Just a couple of questions, but otherwise 💯

@@ -292,7 +292,7 @@ def build_xcodebuild_showbuildsettings_command
end

# Get the build settings for our project
# this is used to properly get the DerivedData folder
# this is used e.g. to properly get the DerivedData folder
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this line should be reworded to just say e.g. to properly get the DerivedData folder

gym/README.md Outdated
@@ -174,6 +174,20 @@ export_options(
)
```

Optional: To pass a mapping of bundle identifiers to provisioning profiles, use the following
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add another comment here about why someone would want to use this?

@@ -80,6 +80,10 @@ def handle_package_error(output)
print "This means, the specified provisioning profile was not created using"
print "the specified certificate."
print "Run cert and sigh before gym to make sure to have all signing resources ready"
when /requires a provisioning profile/
print "No provisioning profile provided"
print "Make sure to pass a valid provisioning for each rquired target"
Copy link
Contributor

Choose a reason for hiding this comment

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

*required

end

Gym.config[:export_options] ||= {}
Gym.config[:export_options][:provisioningProfiles] = provisioning_profile_mapping
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this overwrite any export options that are already set?

@ohayon
Copy link
Contributor

ohayon commented Jun 14, 2017

Does this PR take care of this change too? #9449

@KrauseFx
Copy link
Member Author

Nice catch @ohayon, seems like it's the same thing, but with a different approach. Let's make sure we use the better one 👍

@igor-makarov
Copy link
Contributor

As I mentioned in #9449, I like combining both approaches as they do not seem contradictive of each other.

I do want to report a small bug I encountered while testing this PR combined with mine:

When using workspace instead of project in gym options, gym fails to find the project file to infer from. The error I get is:

The plist file at path `/Users/*****/*****/*****.xcworkspace/project.pbxproj` doesn't exist.

@andrerfneves
Copy link

@KrauseFx when do you believe I can expect this to be merged in?

@KrauseFx
Copy link
Member Author

Whops, I thought this was already merged, thanks for pinging me. Looking into this now 👍

@KrauseFx
Copy link
Member Author

Thanks for letting me know re workspace, I can reproduce @igor-makarov 👍

@KrauseFx
Copy link
Member Author

@igor-makarov Would you mind giving it another shot for your workspace?

@igor-makarov
Copy link
Contributor

Still not working on my config... Two issues:

  • Iterating on the workspace can produce groups other than a project (in my case, a GPX folder). My suggestion is to add current_match.end_with?(".xcodeproj") to the find_all block.
  • Not related to workspaces, but I have several base .xcconfig files that the project build settings depend on. The provisioning profile is specified there, like so:
PROVISIONING_PROFILE_SPECIFIER = ${PRODUCT_BUNDLE_IDENTIFIER} AppStore

Because of that, in my setup, current["PRODUCT_BUNDLE_IDENTIFIER"] returns nil.

However, attempting to use Xcodeproj method target.resolved_build_setting function doesn't seem to work as it returns the value resolved from the xcconfig, but doesn't resolve the fact the value references another property, in this case "$(XXXXXX_BASE_BUNDLE_PREFIX).Widget".

This seems to be a limitation of Xcodeproj and I don't know how easy it is to address it. Perhaps @dantoml can clarify what can be done about this?

@andrerfneves
Copy link

@KrauseFx any updates on getting this merged?

@KrauseFx
Copy link
Member Author

Yeah, it would be awesome if you could provide a sample project that can reproduce the problem.

@andrerfneves we'll merge as soon as it's ready 😉 it seems like we still have some problems with workspaces.

I'm not gonna be online tomorrow (Monday), so realistically I'll have time to finish this PR on Tuesday 👍

@KrauseFx
Copy link
Member Author

For now, you can always manually pass the provisioning profile mapping as described in the docs @andrerfneves

@andrerfneves
Copy link

andrerfneves commented Jun 19, 2017

@KrauseFx Ah! wasn't aware I could do that. Also initially thought the workspaces issue was separate from this PR. Sorry about that. And thanks for the hard work on such an awesome tool! Cheers.

EDIT: Where would one find export options documentation? I've been scouring Fastlane Docs and I've been unable to find it. Could you point me to it when you get a chance? I appreciate it.

@KrauseFx
Copy link
Member Author

Without a sample project to reproduce the issue, I'm having a hard time fixing the problem 😢

@igor-makarov
Copy link
Contributor

igor-makarov commented Jun 20, 2017

I can provide one. Any reason not to merge the pull request I submitted, by the way? It doesn't conflict with this one.

@igor-makarov
Copy link
Contributor

I've created the demo project. You can find it at https://github.com/igor-makarov/DemoWorkspaceWithXCConfig

Note that the issue I'm running into isn't related to workspaces. It's related to inherited .xccconfig files.

Also, my other issue (Iterating on the workspace can produce groups other than a project) that I've mentioned above, still needs to be addressed.

@KrauseFx
Copy link
Member Author

@igor-makarov Thanks for preparing the sample project, I gave it a try by changing the bundle identifier to my project one, and things are working without any problems.

[18:28:58]: Detected provisioning profile mapping: {"family.wwdc.app"=>"match AppStore family.wwdc.app"}
[18:28:58]: $ xcodebuild -list -workspace ./DemoWorkspaceWithXCConfig.xcworkspace
[18:28:59]: $ xcodebuild -showBuildSettings -workspace ./DemoWorkspaceWithXCConfig.xcworkspace -scheme DemoWorkspaceWithXCConfig

+-----------------------------------------------------+---------------------------------------------------------+
|                                            Summary for gym 2.38.1                                             |
+-----------------------------------------------------+---------------------------------------------------------+
| workspace                                           | ./DemoWorkspaceWithXCConfig.xcworkspace                 |
| export_options.provisioningProfiles.family.wwdc.app | match AppStore family.wwdc.app                          |
| scheme                                              | DemoWorkspaceWithXCConfig                               |
| destination                                         | generic/platform=iOS                                    |
| output_name                                         | DemoWorkspaceWithXCConfig                               |
| build_path                                          | /Users/fkrause/Library/Developer/Xcode/Archives/2017-0  |
|                                                     | 6-29                                                    |
| clean                                               | false                                                   |
| output_directory                                    | .                                                       |
| silent                                              | false                                                   |
| skip_package_ipa                                    | false                                                   |
| use_legacy_build_api                                | false                                                   |
| buildlog_path                                       | ~/Library/Logs/gym                                      |
| xcode_path                                          | /Applications/Xcode-9.app                               |
+-----------------------------------------------------+---------------------------------------------------------+

[18:29:00]: $ set -o pipefail && xcodebuild -workspace ./DemoWorkspaceWithXCConfig.xcworkspace -scheme DemoWorkspaceWithXCConfig -destination 'generic/platform=iOS' -archivePath /Users/fkrause/Library/Developer/Xcode/Archives/2017-06-29/DemoWorkspaceWithXCConfig\ 2017-06-29\ 18.29.00.xcarchive archive | tee /Users/fkrause/Library/Logs/gym/DemoWorkspaceWithXCConfig-DemoWorkspaceWithXCConfig.log | xcpretty
[18:29:01]: ▸ Building DemoWorkspaceWithXCConfig/DemoWorkspaceWithXCConfig [Release]
[18:29:01]: ▸ Check Dependencies
[18:29:01]: ▸ Linking DemoWorkspaceWithXCConfig
[18:29:02]: ▸ Compiling LaunchScreen.storyboard
[18:29:05]: ▸ Compiling Main.storyboard
[18:29:05]: ▸ Processing Info.plist
[18:29:05]: ▸ Generating 'DemoWorkspaceWithXCConfig.app.dSYM'
[18:29:05]: ▸ Touching DemoWorkspaceWithXCConfig.app
[18:29:10]: ▸ Signing /Users/fkrause/Library/Developer/Xcode/DerivedData/DemoWorkspaceWithXCConfig-cfpacxhsmflleecusxxxcgiuiega/Build/Intermediates.noindex/ArchiveIntermediates/DemoWorkspaceWithXCConfig/InstallationBuildProductsLocation/Applications/DemoWorkspaceWithXCConfig.app
[18:29:11]: ▸ Touching DemoWorkspaceWithXCConfig.app.dSYM
[18:29:11]: ▸ Archive Succeeded
[18:29:11]: Generated plist file with the following values:
[18:29:11]: ▸ -----------------------------------------
[18:29:11]: ▸ {
[18:29:11]: ▸   "provisioningProfiles": {
[18:29:11]: ▸     "family.wwdc.app": "match AppStore family.wwdc.app"
[18:29:11]: ▸   },
[18:29:11]: ▸   "method": "app-store"
[18:29:11]: ▸ }
[18:29:11]: ▸ -----------------------------------------
[18:29:11]: $ /usr/bin/xcrun /Users/fkrause/Developer/fastlane/gym/lib/assets/wrap_xcodebuild/xcbuild-safe.sh -exportArchive -exportOptionsPlist '/var/folders/8q/f0rt7xtj4pd8q6vgh_mk2p4c00dw80/T/gym_config20170629-19615-3ens69.plist' -archivePath /Users/fkrause/Library/Developer/Xcode/Archives/2017-06-29/DemoWorkspaceWithXCConfig\ 2017-06-29\ 18.29.00.xcarchive -exportPath '/var/folders/8q/f0rt7xtj4pd8q6vgh_mk2p4c00dw80/T/gym_output20170629-19615-1mhwq53'
[18:29:35]: Compressing 1 dSYM(s)
[18:29:35]: $ cd '/Users/fkrause/Library/Developer/Xcode/Archives/2017-06-29/DemoWorkspaceWithXCConfig 2017-06-29 18.29.00.xcarchive/dSYMs' && zip -r '/Users/fkrause/Developer/hacking/DemoWorkspaceWithXCConfig/DemoWorkspaceWithXCConfig.app.dSYM.zip' *.dSYM
[18:29:35]: ▸   adding: DemoWorkspaceWithXCConfig.app.dSYM/ (stored 0%)
[18:29:35]: ▸   adding: DemoWorkspaceWithXCConfig.app.dSYM/Contents/ (stored 0%)
[18:29:35]: ▸   adding: DemoWorkspaceWithXCConfig.app.dSYM/Contents/Info.plist (deflated 52%)
[18:29:35]: ▸   adding: DemoWorkspaceWithXCConfig.app.dSYM/Contents/Resources/ (stored 0%)
[18:29:35]: ▸   adding: DemoWorkspaceWithXCConfig.app.dSYM/Contents/Resources/DWARF/ (stored 0%)
[18:29:35]: ▸   adding: DemoWorkspaceWithXCConfig.app.dSYM/Contents/Resources/DWARF/DemoWorkspaceWithXCConfig (deflated 68%)

[18:29:35]: Successfully exported and compressed dSYM file
[18:29:35]: Successfully exported and signed the ipa file:
[18:29:35]: /Users/fkrause/Developer/hacking/DemoWorkspaceWithXCConfig/DemoWorkspaceWithXCConfig.ipa

I'll dive in further to figure out what it is.

# Conflicts:
#	gym/lib/gym/detect_values.rb
@KrauseFx KrauseFx merged commit 0aa3138 into master Jun 30, 2017
@KrauseFx KrauseFx deleted the automatic-profile-mapping branch June 30, 2017 01:46
@KrauseFx
Copy link
Member Author

Alright, seems like things work for me, we can do a follow-up patch if things end up not working

@igor-makarov
Copy link
Contributor

It seems that it matched the profiles from the match output, rather than from the project file.

@fastlane-bot
Copy link

Hey @KrauseFx 👋

Thank you for your contribution to fastlane and congrats on getting this pull request merged 🎉
The code change now lives in the master branch, however it wasn't released to RubyGems yet.
We usually ship about once a week, and your PR will be included in the next one.

Please let us know if this change requires an immediate release by adding a comment here 👍
We'll notify you once we shipped a new release with your changes 🚀

@fastlane-bot
Copy link

Congratulations! 🎉 This was released as part of fastlane 2.44.0 🚀

@igor-makarov
Copy link
Contributor

FYI I still think it would fail under my config when not using match or the sigh patch I submitted. However I'm using sigh so my project builds ok.

So I guess I'm commenting just in case someone googles xcconfig in the future.

@mjholgate
Copy link
Contributor

@KrauseFx I've noticed this still fails when either the provisioning profile or the app bundle ID are inherited from the project configuration (rather than being defined in the target) and are constructed using build setting $(VARIABLES) - this causes values to be missing from the in the generated plist.

If I've not explained this well enough, please let me know and am happy to produce an example project tomorrow :). Cheers

@igor-makarov
Copy link
Contributor

@mjholgate This is my setup exactly and I already linked to a demo before.

@KrauseFx
Copy link
Member Author

KrauseFx commented Jul 5, 2017

Yes, I couldn't reproduce, if you let me know how I can reproduce the problem with the sample project, I can work on a fix 👍

@igor-makarov
Copy link
Contributor

@KrauseFx I've provided the sample project earlier.

The reason you haven't encountered the problem when reproducing is because you have match in place.

dvdchr pushed a commit to dvdchr/fastlane that referenced this pull request Sep 5, 2017
…code project (fastlane#9460)

* Xcode 9: Automatically detect selected provisioning profiles of the Xcode project

This way fastlane will just keep working with Xcode 9 even for setups that don't use _match_ (yet).

Xcode 9 requires a mapping of bundle identifier and what provisioning profile to use. We use `xcodeproj` to find those values, but in a way that _gym_ doesn't break if we can't detect those things

I also verified that things work fine if you pass non-existent bundle identifier/profiles, Xcode will just ignore them 👍

* Remove old comment

* Skip setting of empty provisioning profile mapping

* Improve spelling

Adresses feedback @ohayon

* Add support for workspaces
@fastlane fastlane locked and limited conversation to collaborators Sep 26, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants