which carthage: /usr/local/bin/carthagecarthage version: 0.31.2xcodebuild -version: Xcode 10.1 Build version 10B61--no-build? N--no-use-binaries? Y--use-submodules? N--cache-builds? Y--new-resolver? NCartfile
gtihub "<my own framework>" "<some branch>"
Carthage Output
Carthage runs fine on the command line.
Actual outcome
I followed the Carthage README.md instructions for iOS apps: Dragging my Carthage built framework to General > Linked Frameworks and Libraries and adding the copy-frameworks Build Phases > Run Script.
The app builds fine, but when I run it in the Simulator, I get:
dyld: Library not loaded: @rpath/MyFramework.framework/MyFramework
Referenced from: /Users/<me>/Library/Developer/CoreSimulator/Devices/A3651DD6-F31D-4866-963F-12A57C575BEC/data/Containers/Bundle/Application/B4D47B47-16B0-42EC-8321-5BFD7D58DD45/MyApp.app/MyApp
Reason: image not found
This issue can be resolved by either adding $(FRAMEWORKS_FOLDER_PATH) to Build Settings > Runpath Search Paths, or by adding my framework in a Build Phases > Copy Files Phase with Destination set to Frameworks.
Expected outcome
The app should just run when following the README.md.
When searching for solutions I find several people having all kinds of issues related to this. Some add frameworks as Embedded Binaries (something the README.md explicitly only says for macOS applications). Others add the frameworks to a Copy Files Phase. I also found a, less related, Python script to replace copy-frameworks.
Some of the work-arounds I found in Carthage issues, but didn't make it to the README.md.
Is the README.md outdated/wrong?
Dragging & Dropping should work, the alternative method is to manually add the framework to Linked Libraries & Frameworks.
Did you specify the input files to the carthage copy-frameworks phase?
@blender I've also manually added my framework to Build Phases > Link Binary With Libraries (which is where it of course also shows up now). Same result.
Yes, I have specified both input and output files of the copy-frameworks Run Script phase.
I'll try with a new project myself.
@blender I'd suggest to create both a new framework and app. I'll do the same.
My new framework + app work. But when I remove the Run Script Input File, I get the same error as in my original app. So I'm going to double check everything there.
@blender It was a silly typo in the Run Script > Input File. (I thought the Input & Output Files are only by the Xcode build system to determine the scripts 'build' dependencies.)
Apologies for the noise. I'm very happy things work as the README.md says!
Most helpful comment
@blender It was a silly typo in the Run Script > Input File. (I thought the Input & Output Files are only by the Xcode build system to determine the scripts 'build' dependencies.)
Apologies for the noise. I'm very happy things work as the README.md says!