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
Make team id, app id and a group prefix specifiable in an xcconfig #483
Conversation
It appears that the ci is using a different bitrise.yml file (maybe something configured on their website?), so my changes to the bitrise.yml in the repo aren't being used. Give this, I'm not sure if my changes to bitrise.yml in commit 1eb51eb are correct, or necessary. I need your help in getting this auto-tested correctly. |
I think the yml is just a backup as they're not in sync at the moment anyway. How about committing DDG developers at the least should be able to check out, build and run without any additional config. I sometimes have multiple checkouts depending on what I'm doing so it would be painful to have to create this file each time. |
Since the bitrise.yml in the repo isn't actually used, I'll retract commit 1eb51eb. We could commit the xcconfig too, but the disadvantage would be that external developers would still have to deal with making sure they don't push their changes to the xcconfig. That is still an improvement over the current scenario because they'll just have one file to change. To compare:
Option 2 puts both DDG developers and external developers on equal footing, which I think is a nice way of welcoming external contributions. Nevertheless, I think you should make the call on which is more important here. |
Option 1 is preferred for simplicitly, please - it'll still be a lot easier than it has been thus far and with a note in the README hopefully people will see what they need to do. New developers can use a git command to mark that file as unchanged for themselves locally:
We will catch changes to that file during a code review. Thanks! |
Okay. |
Hi @roop - we've been at our team offsite this week so apologies for the radio silence. @bwaresiak and I were discussing it and he had a good idea, though I can't quite remember the details. It's not far off from this though. @bwaresiak do you want to elaborate here so we can discuss, please? |
@brindy sure! @roop I like your idea of creating
What would you think about something like that:
Now, whenever contributor needs to change configuration, he will:
Since that file will be ignored by git, nothing should be committed to the repo. There are alternatives to that (like auto-generated config files that are ignored by git, but could be changed easily by contributors) but I'd prefer simpler approach. What do you think about it? |
@bwaresiak I didn't know we can have optional includes. This looks very good. I'm assuming Both problems are solved cleanly:
I'm not sure I like the name |
Glad you like it! :)
Yes.
To be honest, either is fine with me (tho I feel that shorter = better, maybe just |
@bwaresiak Okay, I'll go with When the external developer copies |
On second thoughts, here's a slight modification of your idea:
This way, we don't have to ask people to remove the |
Good idea, that's even better. 👍 |
Hello @roop Just FYI so you know what's going on: I'll be committing some time to look at & test this next week, as I still have some things I want to finish by the end of this week. Thanks for your patience. :) Also I've noticed that DDG group id is still hardcoded for |
Sure, ok.
I didn't see a reason to change that and make it dependant on the GROUP_ID_PREFIX since the app can be built and run without having to do that. Do you think it should be un-hardcoded? |
I gave it some thought: initially my reasoning was that it would be nice to have it not hardcoded, in case we decide |
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.
Nice job! With this it is easy to run development version along regular installation.
Few notes:
- 'Home screen widget' plist field should also take bundle ID from configuration (otherwise for app with customized bundle id that widget won't appear after long-pressing app icon).
- Tested on Xcode 11.0: One has to remember to clean whole project after adding
ExternalDeveloper.xcconfig
otherwise Xcode won't apply changes properly (it seems to work well when removing that file). Maybe we should add info about this to readme? - Tested on the simulator, so this may be the factor: There is something tricky going on with linking to app from extensions (e.g. bookmarks): when I have two apps installed at the same time (with different bundle ids, say "original" and "external") the "original" DDG app is opened no matter which extension I use. When I remove "original" one, the "external" one is opened as expected. I've checked the plist files/config but did not see anything suspicious.
Ah, yes. That's true.
The PR already derives the bundle IDs of extensions (BookmarksTodayExtension, QuickActionsTodayExtension and ShareExtension) from the APP_ID in the xcconfig (commit 3477410).
I didn't really test this scenario. An external developer will be able to build only after he creates a
The extensions open the DDG app using URL schemes (like |
What I meant is Main project's Info.plist file and The exact line. Try long-pressing app icon on iOS 13 to see the issue. :)
Yes, I'd add 'Clean and rebuild project' as the last step.
Yes, but in plist file where custom URL schemes are specified, there is also Identifier field ( PRODUCT_BUNDLE_IDENTIFIER ) that according to documentation:
First sentence suggest that identifier is used to distinguish apps (and I interpret the last one as: other apps that can "hijack" scheme if using same identifier). Nonetheless I don't see anything wrong in your PR - as One more thing: what about adding |
I understand now. Sorry about missing that. :(
Ok.
I see it as: The identifier is indeed used to distinguish apps (though it's a little weird that it needs a separate field for that instead of just using the bundle id). Nevertheless, when two apps have registered for the same URL scheme, what can iOS do anyway? iOS knows from the identifiers that two different apps have registered, but it's unclear which should be launched, hence the line saying "it does not prevent other apps from registering the same scheme and handling the associated links".
Missed that. Will add that. |
The bundle id shall be based on APP_ID defined in an xcconfig
The group id shall be based on GROUP_ID_PREFIX defined in an xcconfig. This value is made accessible in Swift code using a custom Info.plist entry.
The fields are set in DuckDuckGoDeveloper.xcconfig, which is #include-ed in Configuration.xcconfig
No problem :)
That makes sense. Seems like I was expecting too much: optional matching the identifier of the app invoking the URL call with the identifier of the one that is supposed to handle it. Nothing to do here. :) |
One more thing that came to my mind: can you include license header (same as the one we prepend the source code with) in xcconfig files? |
Just to be clear, are you talking about what Xcode populates a file with when we create a new file in the project? AFAIK we can't specify that in an xcconfig, but we can set up an Xcode template header like this. |
What I mean is that I think it would be good to add Copyright notice (see AppDelegate lines 5-17) to the files you've created Sorry if my previous message was unclear :) |
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.
Everything looks good to me, thank you for contribution 👍 :)
Task/Issue URL: Issue #479
Tech Design URL: -
CC: @brindy @bwaresiak
Description:
To make it easier for external developers to contribute, this PR takes out team id, app id and group prefix out of the project file / entitlements files. Instead, they are specified in an xcconfig file at
Configuration/Developer.xcconfig
which is kept out of version control.For developers who are part of the DuckDuckGo team, the
Configuration/Developer.xcconfig
should have the following content:To enable the group ids need to be accessed from code, the group id prefix is added to the
Info.plist
s as necessary, so that the prefix can be obtained by examining the bundle in code.For this,
Core/global.swift
now defines astruct Global
. Having aGlobal
defined inside aglobal.swift
doesn't look very good. I think we should rename it toGlobal.swift
and bringisDebugBuild
intostruct Global
, but that should probably be done outside of this PR. What do you think?Steps to test this PR:
If you're part of the DuckDuckGo team, create a
Configuration/Developer.xcconfig
as specified aboveBuild and run the project as before
Make sure the app and extensions work normally
There are 3 app groups here:
So we should test these combinations:
Internal references:
Software Engineering Expectations
Technical Design Template