CocoaPods / Xcodeproj

Create and modify Xcode projects from Ruby.
http://rubygems.org/gems/xcodeproj
MIT License
2.37k stars 458 forks source link

Method: Xcodeproj::Project::Object::AbstractTarget#add_system_library can't add '.tbd' lib #379

Open pikacode opened 8 years ago

pikacode commented 8 years ago

Hi: I'm trying: target.add_system_libraries("z") the "libz.dylib" has been added,but not the "libz.tbd" I looked for "/lib/xcodeproj/project/object/native_target.rb",it's: path = "usr/lib/lib#{name}.dylib" Is there any way to add "libz.tbd"?

segiddins commented 8 years ago

What is the .tbd?

pikacode commented 8 years ago

In Xcode 7 it changes from ".dylib" to ".tbd" image

segiddins commented 8 years ago

I don't know what the purpose of those tbds are (I suspect they're just stubs from cating a few of them), but having .dylib in the Xcodeproj seems to have the same effect?

pikacode commented 8 years ago

There is no .dylib anymore,.tbd instead Maybe this can help: http://stackoverflow.com/questions/31450690/why-xcode-7-shows-tbd-instead-of-dylib And all the .dylib can't be used such as: image Also can't be searched out : image

You can hava a try with Xcode 7 : )

Actully .dylibs can be found at /usr/lib,but Xcode 7 use bitcode for reducing the size of code as default,.tbds are used as reference to the .dylibs,I guess so....

tennysondy commented 8 years ago

hi, @Yasashi ,

Have you found the solution for adding .tbd file?

pikacode commented 8 years ago

@tennysondy i add a method to extend Xcodeproj, and then judge Xocde version. it works for me ^^ ps:i am ios native developer, maybe it's not the best code for rb, first time to write rb...

require 'xcodeproj'

# extend
module Xcodeproj
    class Project
        module Object
        class AbstractTarget < AbstractObject
            def add_system_library_tbd(names)
                Array(names).each do |name|
                    path = "usr/lib/lib#{name}.tbd"
                    files = project.frameworks_group.files
                    unless reference = files.find { |ref| ref.path == path }
                        reference = project.frameworks_group.new_file(path, :sdk_root)
                    end
                    frameworks_build_phase.add_file_reference(reference, true)
                    reference
                end
            end

        end
    end
end
end

# get Xcode version
xcode_version_path = "/Applications/Xcode.app/Contents/version.plist"

xcode_version = 0

if File.exists?(xcode_version_path)
    find = 0
    open(xcode_version_path,"r") do |file|
        file.each_line do |line|
            if find == 1
                xcode_version = line.delete("<string>").delete("</string>")
                puts "Xcode version:#{xcode_version}"
                while(xcode_version.length > 4)
                    xcode_version = xcode_version.chop
                end
                break
            end
            if line.include?"CFBundleShortVersionString"
                find = 1
            end
        end
    end
    else
    puts "Please install Xcode under the directory '/Applications/' "
    exit
end

# select method
if xcode_version.to_i >= 7
      target.add_system_library_tbd("z")
else
      target.add_system_library("z")
end
pikacode commented 8 years ago

@tennysondy 晕,都特么中国人,你说什么英文。。。

tennysondy commented 8 years ago

@Yasashi 非常感谢,我也是发了之后才发现你是中国人,哈哈~~~

tennysondy commented 8 years ago

@Yasashi 本来想直接找你聊的,发现github上不能直接联系

troyzhao commented 7 years ago

哎呦!好屌