Disregard my advice for #2; this will break if you try to archive your project. Use $(CONTENTS_FOLDER_PATH)/Helpers instead.
On Jan 9, 2017, at 6:23 PM, Saagar Jha < email@hidden> wrote:
I’ve finally got it working, and I’d like to thank both of you for helping out. For posterity, here’s a couple of things that tripped me up, which may or may not seem obvious to others but might be useful to someone:
- If your products have the same name except for one being lowercase or whatever, be careful; HFS+ is case preserving but not case sensitive. One of the binaries will overwrite the other if you attempt to copy them to the same directory.
- Xcode does not provide an option for Contents/Helpers in its GUI. For that, you can select “Absolute Path” for your destination in the Copy Files Phase and use $(CODESIGNING_FOLDER_PATH)/Contents/Helpers to have the product placed in the correct directory. (rdar://problem/29940005)
- Similarly, Bundle/NSBundle will make it difficult to find your executable, if:
- your executables are the same case insensitive, and you try to use url(forAuxiliaryExecutable:)
- you put your product in Contents/Helpers, since again, there is no built-in method for accessing the folder as there is for for MacOS (executableURL), Resources (resourceURL), etc. Just stick with Bundle.main.bundleURL.appendingPathComponent(“Contents”, isDirectory: true).appendingPathComponent(“Helpers”, isDirectory: true) (rdar://problem/29940479)
Saagar Jha
On Jan 8, 2017, at 10:39 AM, Ken Thomases < email@hidden> wrote:
On Jan 8, 2017, at 12:23 PM, Chris Hanson < email@hidden> wrote:
On Jan 8, 2017, at 8:59 AM, Saagar Jha < email@hidden> wrote:
Some things ideas I’ve had: - Add the Command Line Tool's product to the app’s Copy Bundle Resources. This seems to be the easiest way, but it seems to be dependent on the last build I did for the Command Line Tool (i.e. if I archived the app after debugging the CLT, the unoptimized binary would be copied over)
This is probably what you'll want to do, by dragging the product reference — which is build-products relative — to the Copy Bundle Resources phase.
Except you should create a different Copy Files build phase to copy to Contents/MacOS or Contents/Helpers or another of the standard locations for code inside the app bundle.[1] Then, drag the product reference to that Copy Files build phase. It shouldn't be copied to the Resources. Because the reference is relative to the build products, it won't copy the one from the Debug directory when building the Release configuration for archiving. It'll expect there to be a built version in the Release directory.
In order to guarantee there is a built version there, you should also add a dependency on the command line tool target to you app target. That ensures you just need to build your app, and the tool will always be built first if needed.
You should also make sure "Skip Install" is turned on for the command line tool target, so when you Archive it's only built, since the app target is responsible for putting it in the right place.
Regards, Ken
|