从项目中删除CocoaPods的正确方法是什么?我想移除整个CocoaPod。由于客户的限制,我不能使用它。我只需要一个xcodeproj,而不是一个xcworkspace。
当前回答
从项目中删除CocoaPods是可能的,但目前还没有被CLI自动化。首先,如果你唯一的问题是不能使用xcworkspace,你可以使用CocoaPods和xcodeprojects,使用——no-integrate标志,它会生成Pods。Xcodeproj,而不是工作空间。然后可以将这个xcodeproj作为子项目添加到主xcodeproj中。
如果你真的想移除所有CocoaPods集成,你需要做几件事:
注意:如果不正确地编辑这些内容,可能会破坏你的主项目。我强烈建议您将项目纳入源代码控制,以防万一。此外,这些指令适用于CocoaPods 0.39.0版本,它们可能会随着新版本而改变。
删除独立文件(Podfile Podfile。锁和你的Pods目录) 删除生成的xcworkspace 打开xcodeproj文件,删除对Pods的引用。xcconfig和libPods。a(在框架组中) 在构建阶段下,删除“复制Pods资源”、“嵌入Pods框架”和“检查Pods清单”。锁阶段。 这似乎是显而易见的,但您需要以其他方式集成第三方库,或者从代码中删除对它们的引用。
在这些步骤之后,您应该使用集成CocoaPods之前存在的单个xcodeproj进行设置。如果我遗漏了什么,请告诉我,我会编辑这个。
此外,我们一直在寻找如何改进CocoaPods的建议,所以如果你有一个问题,请提交到我们的问题跟踪器,这样我们就可以想出一个方法来解决它们!
EDIT
正如Jack Wu在评论中所示,有一个第三方CocoaPods插件可以为你自动化这些步骤。可以在这里找到。注意,它是第三方插件,可能并不总是在CocoaPods更新时更新。还要注意,它是由CocoaPods核心团队成员制作的,所以这个问题不会成为问题。
其他回答
详细的图形表示
你需要做的第一件事是删除Podfile, Podfile。锁、Pods文件夹和生成的工作区。 接下来,在.xcodeproj中,删除对Pods的引用。xcconfig文件和libPods。一个文件。 在Build Phases项目选项卡中,删除Check Pods清单。锁定部分(打开),复制Pods资源部分(底部)和嵌入Pod资源(底部)。 删除Pods.framework。
您唯一要做的就是包含您以前使用过的一些库。你可以通过简单地将pods文件夹中的任何文件夹拖到你的项目中(我更喜欢将它们放在我的Supporting Files文件夹中)来做到这一点。
这对我很管用。
从终端cd移动到项目文件夹。下面的步骤有助于将pod从项目中分离出来
$ sudo gem install cocoapods-deintegrate cocoapods-clean
$ pod deintegrate
$ pod clean
$ rm Podfile
然后只需打开项目文件,并删除Pod文件夹,如果它仍然在项目资源管理器的红色。构建项目……它准备好了!!
所提供的答案均正确有效。但是,当您运行pod安装和修改任何包含cocoapods配置的字段时,clean和deintegration将停止正常工作。
在我的情况下,我有,除其他FRAMEWORK_SEARCH_PATHS覆盖在构建设置和它变得乏味时,处理40个目标…
下面的ruby文件打算运行cocoapods命令来“完全”清理项目,并执行一些额外的清理,例如Build设置,并从项目中删除“Pod”文件夹。脚本还可能包含“clean”或“deintegrate”执行的操作。
require 'xcodeproj'
### HELPERS ###
# Array extension for non-Ruby rail
class Array
# Wraps and object into an array
#
# @param object [Any] The object to be wrapped
# @return [Any] The array with the value wrapped. If the object is nil, then returns empty array
def self.wrap(object)
if object.nil?
[]
elsif object.respond_to?(:to_ary)
object.to_ary || [object]
else
[object]
end
end
end
# Performs the cocoapods clean up actions. It will install the dependencies needed.
def cocoapod_clean_actions
## DEINTEGRATE
puts "** Installing Cocoapods 'DEINTEGRATE' **"
system("sudo gem install cocoapods-deintegrate")
puts "** Performing Cocoapods 'DEINTEGRATE' **"
system("pod deintegrate")
## CLEAN
puts "** Installing Cocoapods 'CLEAN' **"
system("sudo gem install cocoapods-deintegrate")
puts "** Performing Cocoapods 'CLEAN' **"
system("pod clean")
end
# Performs a clean up on the build settings removing all the identified pods leftovers
#
# @param project [Xcodeproj] Xcode project where to permorm the actions
def clean_build_settings(project)
puts "** Removing Cocoapods references from 'BUILD SETTING' **"
podsOcurrence = "PODS"
project.targets.each { |target|
target.build_configurations.each { |build_configuration|
puts "Inspecting BUILD_SETTINGS for TARGET => #{target.name} & CONFIGURATION => #{build_configuration.name}"
build_settings = build_configuration.build_settings
build_settings.each { |key, value|
if key.include?(podsOcurrence)
build_settings.delete(key)
else
clean(build_settings, key, podsOcurrence)
end
}
}
}
project.save()
end
# Performs a clean-up on a specific key of the build settings by removing the occurrences given. It also cleans the value if empty.
#
# @param build_settings [Hash] Build Settings for a specific target and configuration
# @param flag [String] Key to find in the build_settings
# @param occurence [String] The occurence to be removed from the value of build settings key
def clean(build_settings, flag, occurence)
puts "CLEAN => flag = #{flag}, ocurrence = #{occurence}"
indexes = Array.new()
build_settings_flag = Array.wrap(build_settings[flag])
build_settings_flag.each_with_index { |value, index|
if value.include?(occurence)
previous_index = index - 1
if previous_index >= 0 && build_settings_flag[previous_index].to_s&.start_with?("-")
indexes.append(previous_index)
end
indexes.append(index)
end
}
if indexes.count > 0
build_settings_flag.delete_if.with_index { |_, index|
indexes.include? index
}
# Replace the value for the build setting
if build_settings_flag.empty?
puts "Removing empty array #{flag}"
build_settings.delete(flag)
else
puts "Reassining array #{flag}"
build_settings[flag] = build_settings_flag
end
end
end
# Performs a clean up on the build settings removing all the identified pods leftovers
#
# @param project [Xcodeproj] Xcode project where to permorm the actions
def clean_build_phases(project)
puts "** Removing Cocoapods references from 'BUILD_PHASES' **"
project.targets.each { |target|
#if target.name == "WhiteLabel" #TESTING
puts "Inspecting BUILD_PHASES for TARGET => #{target.name}"
target.shell_script_build_phases.each { |shell_script|
if shell_script.name.include?("[CP]")
puts "Removing '#{shell_script.name}' shell script"
shell_script.remove_from_project()
elsif shell_script.name == "Crashlytics Run Script"
puts "Deleting '#{shell_script.name}'"
# Add extra build phases such as the Crashlytics
#shell_script.remove_from_project()
end
}
#break #TESTING
#end #TESTING
}
project.save()
end
# Removes all the unwanted cocoapods files and folders from the project
#
# @param project [Xcodeproj] Xcode project where to permorm the actions
def remove_files_and_folders(project)
puts "** Removing Cocoapods files and folders from project **"
## Project
# BE CAREFUL WITH GROUP(LINK) NAME AND GROUP PATH(FOLDER)
project.groups.find{ |group| group.path == "Pods" }&.remove_from_project()
project.save()
# File system
system('rm -rf Pods')
#system('rm Podfile')
end
### MAIN ###
puts "********** Cocoapods CLEAN UP **********"
cocoapod_clean_actions()
puts "********** Cocoapods EXTRA CLEAN UP **********"
project = Xcodeproj::Project.open "./WhiteLabel.xcodeproj"
clean_build_settings(project)
clean_build_phases(project)
remove_files_and_folders(project)
project.save()
它可以被称为
ruby PodExtraClean.rb
$ sudo gem install cocoapods-deintegrate cocoapods-clean
$ pod deintegrate
$ pod clean
$ rm Podfile
推荐文章
- Xcode构建失败“架构x86_64未定义的符号”
- 如何使用Xcode创建。ipa文件?
- 我可以在没有“构建和运行”的情况下启动iPhone模拟器吗?
- Cocoapods命令失败,提示“No such file or directory @ dir_initialize - /Users/<username>/”。cocoapods /回购(Errno: ENOENT):“
- Xcode 4 -在新的Macintosh安装上的配置文件上“没有找到有效的签名标识”错误
- Xcode +删除所有断点
- Swift:理解// MARK
- 自定义dealloc和ARC (Objective-C)
- 你常用的Xcode快捷键有哪些?
- 确保您的项目构建设置正在生成一个dSYM文件。对于所有配置,DEBUG_INFORMATION_FORMAT都应该设置为dwarf-with-dsym
- 如何改变时间和时区在iPhone模拟器?
- 为iOS模拟器构建,但链接框架'****.framework'是为iOS构建的
- 如何象征崩溃日志Xcode?
- Xcode - ld:没有为- lpods找到库
- 我如何输入RGB值到接口生成器?