Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Usage of pods static library in user's project. #1

Closed
alloy opened this Issue · 10 comments

3 participants

@alloy
Owner

Currently the user still has to perform these steps:

  • Link against libraries that the pods library links against
  • Add header search paths that were added to the pods library

The user also has to perform these steps, but this might just be the simplest way that xcode allows:

  • Add pods static library to workspace
  • Configure project to Always Search User Paths and set User Header Search Paths to $(BUILT_PRODUCTS_DIR)

In addition, some changes to the pods static library project had to be made:

  • Change Public Headers Folder Path to $(TARGET_NAME)
  • Change Installation Directory to $(BUILT_PRODUCTS_DIR)

Most of this info was taken from: http://blog.carbonfive.com/2011/04/04/using-open-source-static-libraries-in-xcode-4

@alloy
Owner

In order to make the app link the right libraries in the simplest way seems to be to generate an xcconfig file that the user's target configurations need to be based on. This also fixes the other extra settings needed in the user's app. I’ve added some code that generates xcconfig files like:

USER_HEADER_SEARCH_PATHS = $(BUILT_PRODUCTS_DIR)
ALWAYS_SEARCH_USER_PATHS = YES
OTHER_LDFLAGS = -framework SystemConfiguration -framework CFNetwork -framework MobileCoreServices -l z.1.2.3 -l xml2.2.7.3
HEADER_SEARCH_PATHS = "$(SDKROOT)/usr/include/libxml2"
@alloy alloy closed this issue from a commit
@alloy alloy Add a dummy xcconfig file to the template and base the target configu…
…rations on. Also fix a few more other settings in the template. Closes #1.
3a8a62f
@alloy alloy closed this in 3a8a62f
@alloy alloy reopened this
@alloy
Owner

Still need to write-up how the user should setup her project to use cocoa-pods.

@fabiopelosin

Can this issue be closed?

@alloy
Owner

@irrationalfab Yeah definitely. I think it’s best if you just close tickets when you think that’s the correct course and optionally say ‘re-open if still applicable’ :)

@alloy alloy closed this
@JanC

Hi,
could you write a how to in the docs about how we are supposed to user CocoaPods in a Workspace that has both an "App" project and a static library project. I have troubles setting up such a environment. See this

https://groups.google.com/forum/?fromgroups=#!topic/cocoapods/DOVaKHXzfnI

cheers,
Jan

@fabiopelosin

Regarding the thread on the mailing list

platform :ios, '6.0'
# Pods used by the main App project
pod 'MACachedImageView', '~> 1.0.0'
pod 'RegexKitLite', '~> 4.0'
pod 'CocoaLumberjack', '~> 1.6'
# Pods used by the library project
xcodeproj 'PStatsKit/PStatsKit/PStatsKit'
target :PStatsKit do
    pod 'RegexKitLite', '~> 4.0'
end

The xcodeproj directive refers to the current target so a correct setup would have been:

target :PStatsKit do
  xcodeproj 'PStatsKit/PStatsKit/PStatsKit'
  pod 'RegexKitLite', '~> 4.0'
end
@JanC

Hi,
I tried doing as you wrote in this project

https://www.dropbox.com/s/7blzr46ckgi8wua/MyApp2.zip

but I'm getting the error

could not automatically select an Xcode workspace. Specify one in your Podfile.

The Podfile included in the zip is:

platform :ios, '6.0'


target :MyApp do
    pod 'MBProgressHUD', '~> 0.5'
    pod 'SEHumanizedTimeDiff', '~> 0.0.1'
end


target :MyLibrary do
    xcodeproj 'MyLibrary'
    pod 'SEHumanizedTimeDiff', '~> 0.0.1'
end
@fabiopelosin

When there is one than more project you need to specify the name of the workspace manually:

workspace 'MyApp'
platform :ios, '6.0'

target :MyApp do
    pod 'MBProgressHUD', '~> 0.5'
    pod 'SEHumanizedTimeDiff', '~> 0.0.1'
end


target :MyLibrary do
    xcodeproj 'MyLibrary'
    pod 'SEHumanizedTimeDiff', '~> 0.0.1'
end
@JanC

thanks @irrationalfab, that worked ;)

@JanC

Hi,
yet another problem :( If MyLibrary uses pod 'ASIHTTPRequest', '~> 1.8.1', I get a linker error:

can't locate file for: -lxml2.2
file: -lxml2.2 is not an object file (not allowed in a library)
can't locate file for: -lz.1
file: -lz.1 is not an object file (not allowed in a library)

This is the same problem as in #830 ... but shouldn't CocoaPods handle this ?

@alloy alloy referenced this issue from a commit
@alloy alloy Add a dummy xcconfig file to the template and base the target configu…
…rations on. Also fix a few more other settings in the template. Closes #1.
315db7f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.