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

Automate copy-frameworks arguments — quite error prone #1131

Open
fatuhoku opened this Issue Feb 17, 2016 · 8 comments

Comments

Projects
None yet
9 participants
@fatuhoku
Copy link

fatuhoku commented Feb 17, 2016

The README reads:

4. On your application targets’ “Build Phases” settings tab, click the “+” icon and choose “New Run Script Phase”. Create a Run Script with the following contents:

/usr/local/bin/carthage copy-frameworks
and add the paths to the frameworks you want to use under “Input Files”, e.g.:

$(SRCROOT)/Carthage/Build/iOS/Box.framework
$(SRCROOT)/Carthage/Build/iOS/Result.framework
$(SRCROOT)/Carthage/Build/iOS/ReactiveCocoa.framework
This script works around an App Store submission bug triggered by universal binaries and ensures that necessary bitcode-related files and dSYMs are copied when archiving.

This can be quite a chore for Carthage users. This additional step makes maintaining the Xcode project quite error prone. For instance, it's possible to run and debug your app on the Simulator without a copy-framework step. Linker errors due to frameworks not being found (they weren't copied) would show up only when you're debugging on the device.

Provided this workaround will stick around (!), is there any way for copy-frameworks to get smart, and basically figure out from Cartfile that it should probably go and copy those dependencies' build .framework artefacts to save the developer from having to maintain this Run Build Phase?

Or, is this not Carthage's responsibility, because it's 'flexible'?

@mdiep

This comment has been minimized.

Copy link
Member

mdiep commented Feb 17, 2016

TBH I'm not sure why it was done that way. But having Carthage do it does seem like it'd be preferable if possible.

@NachoSoto

This comment has been minimized.

Copy link
Contributor

NachoSoto commented Feb 17, 2016

Provided this workaround will stick around (!), is there any way for copy-frameworks to get smart, and basically figure out from Cartfile that it should probably go and copy those dependencies' build .framework

That's a good idea. In practice, however, I think that assumes an ideal scenario. If you consider projects with multiple targets of different platforms, with Carthage dependencies that may or may not be for all platforms, and targets that may not want all dependencies... this wouldn't work so well.

I suppose if we can cross-check Cartfile with the list of linked frameworks in each target that should be accurate.

But @fatuhoku you're totally right. However, if you think about it, what's error prone is Xcode's configuration itself. Copying frameworks is necessary whether you use Carthage or not. The fact that this is done with copy-frameworks in the case of fat Carthage frameworks is just due to a century-old bug (excuse my perception problem again... I meant to say lack of a feature) that won't remove unnecessary slices from .frameworks.

@icecrystal23

This comment has been minimized.

Copy link

icecrystal23 commented Apr 5, 2016

To me, it would simplify everything if Carthage just built separate frameworks for the device vs the simulator instead of having to smash them together and then pull them apart again.

You can use the $(PLATFORM_NAME) macro to get "iOS" vs "iOS Simulator" and so forth, so it would only require minor updates to build settings for users.

@zirinisp

This comment has been minimized.

Copy link

zirinisp commented Sep 20, 2016

Has anyone tried the following:

https://github.com/lvillani/carthage-copy-frameworks

It is suppose to automate the build phase and include all frameworks with one line.

@anfriis

This comment has been minimized.

Copy link

anfriis commented Nov 30, 2016

Yes @zirinisp, I just tried the carthage-copy-frameworks and it works for me!
Could be worth mentioning in the README or somehow integrate this into Carthage

@guidomb

This comment has been minimized.

Copy link
Contributor

guidomb commented Feb 5, 2017

I uses the following Ruby script

#!/usr/bin/env ruby

command = "/usr/local/bin/carthage copy-frameworks"
frameworks_path = File.join(ARGV.first || ".", "Carthage/Build/iOS")
frameworks = Dir.entries(frameworks_path)
  .select { |entry| File.extname(entry) == ".framework" }
  .map { |framework| File.join(frameworks_path, framework) }
env_vars = frameworks.each_with_index
  .map { |framework, index| "SCRIPT_INPUT_FILE_#{index}=#{framework}" }
  .join(" ")
`SCRIPT_INPUT_FILE_COUNT=#{frameworks.count} #{env_vars} #{command}`

and then call it through a run script phase like

$SRCROOT/script/copy_frameworks $SRCROOT
@JakubBednar

This comment has been minimized.

Copy link

JakubBednar commented Feb 20, 2017

I have created a github project with a single python script here. You still have to provide Input Files in the build-phase setup, but you can provide only the frameworks build directly by projects in your Cartfile. Any dependecies of those frameworks are determined automatically using otool -L

@ikesyo

This comment has been minimized.

Copy link
Member

ikesyo commented Jun 26, 2018

Ref: #2477

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.