CocoaPods / cocoapods-packager

CocoaPods plugin which allows you to generate a static library from a podspec.
Other
1.15k stars 219 forks source link

Do not pass `compiler_flags` to `xcodebuild` #135

Open mohemian-92817281 opened 8 years ago

mohemian-92817281 commented 8 years ago

You can declaratively specify build settings (e.g. frameworks, compiler flags) in your podspec. This is easier to maintain and replicate than build settings embedded in your Xcode project.

How would I go about doing that? I found nothing in the docs or in the help.

I would like to build a framework out of my pod with bitcode enabled and I feel stuck. I'm grateful for any hint.

segiddins commented 8 years ago

The CocoaPods guides have a section for different podspec attributes

mohemian-92817281 commented 8 years ago

Thanks for the quick reply and pointing me in the right direction!

I found an example here. facebook.compiler_flags = '-Wno-incomplete-implementation -Wno-missing-prototypes'

So I tried to use it in my podspec file like this: s.compiler_flags = '-Wno-implicit-function-declaration'

And build the static library using pod package --library ExampleSDK.podspec

Unfortunately the build fails. Output:

Build command failed: xcodebuild GCC_PREPROCESSOR_DEFINITIONS='PodsDummy_Pods_ExampleSDK=PodsDummy_PodPackage_ExampleSDK' -Wno-implicit-function-declaration ARCHS="x86_64 i386 arm64 armv7 armv7s" CONFIGURATION_BUILD_DIR=build clean build  -configuration Release -target Pods -project Pods/Pods.xcodeproj 2>&1
Output:
    xcodebuild: error: invalid option '-Wno-implicit-function-declaration'

Thanks again for your reply.

neonichu commented 8 years ago

Seems like you have found a bug with passing some custom compiler_flags.

segiddins commented 8 years ago

Those need to be passed as other c flags or other cpp flags

neonichu commented 8 years ago

Which already should be happening anyway through the generated Xcode project by CP itself, not sure why this additional code is even there.

mohemian-92817281 commented 8 years ago

I am using cocoapods version 0.39.0 by the way.

Edit: And cocoapods-packager-1.3.0 cocoapods-packager-1.3.0 depends on cocoapods (>= 0.38.2)

mohemian-92817281 commented 8 years ago

Using cocoapods version 1.0.0.beta.7 I get a different error.

Command

/usr/local/bin/pod package --verbose --library ExampleSDK.podspec

Stack

   CocoaPods : 1.0.0.beta.7
        Ruby : ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin15]
    RubyGems : 2.0.14.1
        Host : Mac OS X 10.11.4 (15E65)
       Xcode : 7.3 (7D175)
         Git : git version 2.5.1
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib
Repositories : collections - git@github.com:collections/Podspecs.git @ 9641f0304148650e1cae021cd3dda0a25b0cf119
               master - https://github.com/CocoaPods/Specs.git @ 04230baeac3290f11959d71ef2931e08909c0d08
               segmentio - git@github.com:segmentio/Podspecs.git @ b45336618c69d325eadd97f0d4b76d7908593e4b
               SimpleOAuth1 - https://github.com/anreitersimon/simple-oauth1 @ 1f19c2a3a51dc6eac11ed027fa68b37b837d182f
               thelevelup - https://github.com/TheLevelUp/ZXingObjC @ 71494951f511276e280e5035bd85e7678827b234

Plugins

cocoapods-deintegrate : 1.0.0.beta.1
cocoapods-packager    : 1.3.0
cocoapods-plugins     : 1.0.0.beta.1
cocoapods-search      : 1.0.0.beta.2
cocoapods-stats       : 1.0.0.beta.4
cocoapods-trunk       : 1.0.0.beta.3
cocoapods-try         : 1.0.0.beta.3

Error

NameError - uninitialized constant Pod::Command::Package::SourcesManager
/Library/Ruby/Gems/2.0.0/gems/cocoapods-packager-1.3.0/lib/cocoapods-packager/pod_utils.rb:73:in `spec_with_name'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-packager-1.3.0/lib/cocoapods-packager/pod_utils.rb:57:in `block in binary_only?'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-packager-1.3.0/lib/cocoapods-packager/pod_utils.rb:57:in `map'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-packager-1.3.0/lib/cocoapods-packager/pod_utils.rb:57:in `binary_only?'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-packager-1.3.0/lib/pod/command/package.rb:45:in `validate!'
/Library/Ruby/Gems/2.0.0/gems/claide-1.0.0.beta.3/lib/claide/command.rb:333:in `run'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.0.0.beta.7/lib/cocoapods/command.rb:50:in `run'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.0.0.beta.7/bin/pod:44:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'
mohemian-92817281 commented 8 years ago

I managed to achieve what I wanted to achieve by explicitly exporting OTHER_CFLAGS before running pod package.

export OTHER_CFLAGS='-fembed-bitcode' # enable bitcode
pod package --embedded ExampleSDK.podspec

Maybe this helps someone who has a similar problem. In any case, thanks again for your support and quick response.

glishijie commented 7 years ago

I want to export CC and CXX env var, but I find that it doesn't work.