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

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

Open
pikacode opened this issue May 30, 2016 · 10 comments

Comments

@pikacode
Copy link

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
Copy link
Member

What is the .tbd?

@pikacode
Copy link
Author

pikacode commented May 31, 2016

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

@segiddins
Copy link
Member

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
Copy link
Author

pikacode commented May 31, 2016

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
Copy link

hi, @yasashi ,

Have you found the solution for adding .tbd file?

@pikacode
Copy link
Author

pikacode commented Aug 2, 2016

@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
Copy link
Author

pikacode commented Aug 2, 2016

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

@tennysondy
Copy link

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

@tennysondy
Copy link

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

@troyzhao
Copy link

哎呦!好屌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants