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

How to correctly include pre-built binary for signing? #1

Open
jhrtn opened this issue Aug 16, 2023 · 3 comments
Open

How to correctly include pre-built binary for signing? #1

jhrtn opened this issue Aug 16, 2023 · 3 comments

Comments

@jhrtn
Copy link

jhrtn commented Aug 16, 2023

Hi there,

Thanks a lot for this project. I'm new to the world of Apple signing and notarisation and is a very helpful resource.

I've created an OpenFrameworks app which utilises ffmpeg. I include a pre-built ffmpeg binary in the app's data folder.

I have mac.dist.include = bin/data included in my Makefile. Initially the notarisation failed as ffmpeg hadn't been signed. So I tried to include it using mac.dist.progs/mac.dist.libs in the Makefile, but couldn't figure out the correct way to get it copied across from my bin/data folder.

In my Makefile I added mac.dist.libs = bin/data/ffmpeg but at the codesign stage of make app dist-dmg I get the error:

===== codesign
codesign --sign "Developer ID Application: <My Developer ID>" --force --options runtime --timestamp build/dist/MyOFApp-1.0.0/bin/data/ffmpeg
build/dist/MyOFApp-1.0.0/bin/data/ffmpeg: No such file or directory

If I instead try to include mac.dist.libs = data/ffmpeg then I get:

===== distdir
mkdir -p build/dist/MyOFApp-1.0.0
rsync -a --exclude ".*"  \
                MyOFApp.app data/ffmpeg bin/data build/dist/MyOFApp-1.0.0
rsync: link_stat "<path to app>/MyOFApp/data/ffmpeg" failed: No such file or directory (2)

If I create a folder at the root of my project called data containing ffmpeg then it gets copied over correctly and the signing and notarization works.

I can see that the issue is just where the file gets copied to and from but from reading through the makefile I can't figure it out. Do I need to override mac.dist.dir or mac.dist.subdir?

Is there a suggested pattern for including files from bin/data to be signed?

Any pointers appreciated

Many thanks

@danomatika
Copy link
Member

Does the app build and run with the ffmpeg lib in bin/data? I have not tried that and I didn't know OF or Xcode supported this.

Generally, on macOS, it's best to include all dependent libs which aren't built-in to the OS within the .app bundle. Basically, you do this during one of the Build Phases in the Xcode project settings and probably need to change the library search path of the app so that it can find it.

This is not really something you do within the makefile. Check out the ofxTensorFlow2 repo https://github.com/zkmkarlsruhe/ofxTensorFlow2. Our solution here was the scripts/macos_install_libs.sh script which copies the libs inside the .app bundle on build as well as changes the lib search path. See the readme for how to invoke the script as one of the build phases: https://github.com/zkmkarlsruhe/ofxTensorFlow2/tree/main#xcode-build

Note: ffmpeg I believe has many dependencies which will also need to be included for this to work on another system. I for one have tried to bundle libs built via Homebrew into an app, for instance, and not had success making it unable on other computers. In my experience, it's best to build libs in statically, when possible, and when not, to build them separately and include them as stated,

@jhrtn
Copy link
Author

jhrtn commented Aug 16, 2023

Thanks for the info, I'll look into those links.

I'm using ofxVideoRecorder addon which hasn't been updated but works well still. I haven't had any issues bundling in just the single ffmpeg executable in the bin/data folder and setting the location for it as in this example

For my OF apps I usually put rsync -r bin/data "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Resources"; into my Build Phases to copy my data folder to within the .app - but that was presenting some other issues when signing and notarising which I think may be a separate issue?

@danomatika
Copy link
Member

danomatika commented Aug 16, 2023

but that was presenting some other issues when signing and notarising which I think may be a separate issue?

You would still need to change the lib paths via install_name_tool. As far as I understand, when the app is built in Xcode, the original path is set within the executable. If you place it in a different location, then the path needs to be manually changed. There is info on SO and the Apple docs about this.

Also, you want to place libs within Contents/Frameworks not Contents/Resources.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants