├── .gitignore ├── Gemfile ├── LICENSE.txt ├── README.md ├── Rakefile ├── cocoapods-readonly.gemspec ├── lib ├── cocoapods-readonly.rb ├── cocoapods-readonly │ ├── gem_version.rb │ └── toggle_readonly.rb └── cocoapods_plugin.rb └── spec ├── command └── readonly_spec.rb └── spec_helper.rb /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | pkg 3 | .idea/ 4 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # Specify your gem's dependencies in cocoapods-readonly.gemspec 4 | gemspec 5 | 6 | group :development do 7 | gem 'cocoapods' 8 | gem 'bacon' 9 | end 10 | 11 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2015 Yelp 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cocoapods-readonly 2 | 3 | Developers switching from submodules are used to modifying library source files from within Xcode. If you don’t checkout a local version first, changes won’t be picked up by git and might be lost the next time you run ‘pod install.' 4 | 5 | This plugin removes the write permission from all pod-related files that aren’t installed via a local pod. Xcode will then give you a helpful message, noting that the file is locked. 6 | 7 | ## Installation 8 | 9 | $ gem install cocoapods-readonly 10 | 11 | ## Usage 12 | 13 | This runs automatically on pod install – you don't have to do anything. 14 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'bundler/gem_tasks' 2 | 3 | def specs(dir) 4 | FileList["spec/#{dir}/*_spec.rb"].shuffle.join(' ') 5 | end 6 | 7 | desc 'Runs all the specs' 8 | task :specs do 9 | sh "bundle exec bacon #{specs('**')}" 10 | end 11 | 12 | task :default => :specs 13 | 14 | -------------------------------------------------------------------------------- /cocoapods-readonly.gemspec: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | lib = File.expand_path('../lib', __FILE__) 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 4 | require 'cocoapods-readonly/gem_version.rb' 5 | 6 | Gem::Specification.new do |spec| 7 | spec.name = "cocoapods-readonly" 8 | spec.version = CocoapodsReadonly::VERSION 9 | spec.authors = ["Mason Glidden", "Yelp"] 10 | spec.email = ["mglidden@yelp.com", "mobile@yelp.com"] 11 | spec.description = %q{Makes CocoaPods source files read-only, so you can't accidently modify them.} 12 | spec.summary = %q{Developers switching from submodules are used to modifying library source files from within Xcode. This locks those files as needed so Xcode warns you when attempting to edit.} 13 | spec.homepage = "https://github.com/Yelp/cocoapods-readonly" 14 | spec.license = "Apache" 15 | 16 | spec.files = `git ls-files`.split($/) 17 | spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } 18 | spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) 19 | spec.require_paths = ["lib"] 20 | 21 | spec.add_development_dependency "bundler", "~> 1.3" 22 | spec.add_development_dependency "rake" 23 | end 24 | -------------------------------------------------------------------------------- /lib/cocoapods-readonly.rb: -------------------------------------------------------------------------------- 1 | require 'cocoapods-readonly/gem_version' 2 | -------------------------------------------------------------------------------- /lib/cocoapods-readonly/gem_version.rb: -------------------------------------------------------------------------------- 1 | module CocoapodsReadonly 2 | VERSION = "1.0.1" 3 | end 4 | -------------------------------------------------------------------------------- /lib/cocoapods-readonly/toggle_readonly.rb: -------------------------------------------------------------------------------- 1 | module Pod 2 | class Installer 3 | def _set_permissions(permissions) 4 | installer = installer_rep 5 | for pod in installer.pods 6 | # if the pod is actually in Pods/, and not a :path linked pod 7 | if pod.root.parent == installer.sandbox_root 8 | for file in Dir.glob(pod.root + '**/*').reject { |f| File.directory?(f) } 9 | File.chmod(permissions, file) 10 | end 11 | end 12 | end 13 | end 14 | 15 | alias_method :real_perform_post_install_actions, :perform_post_install_actions 16 | def perform_post_install_actions 17 | real_perform_post_install_actions 18 | _set_permissions(0444) 19 | end 20 | 21 | alias_method :real_run_pre_install_hooks, :run_pre_install_hooks 22 | def run_pre_install_hooks 23 | real_run_pre_install_hooks 24 | _set_permissions(0644) 25 | end 26 | end 27 | end -------------------------------------------------------------------------------- /lib/cocoapods_plugin.rb: -------------------------------------------------------------------------------- 1 | require 'cocoapods-readonly/toggle_readonly.rb' 2 | -------------------------------------------------------------------------------- /spec/command/readonly_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../spec_helper', __FILE__) 2 | 3 | module Pod 4 | describe Command::Readonly do 5 | describe 'CLAide' do 6 | it 'registers it self' do 7 | Command.parse(%w{ readonly }).should.be.instance_of Command::Readonly 8 | end 9 | end 10 | end 11 | end 12 | 13 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'pathname' 2 | ROOT = Pathname.new(File.expand_path('../../', __FILE__)) 3 | $:.unshift((ROOT + 'lib').to_s) 4 | $:.unshift((ROOT + 'spec').to_s) 5 | 6 | require 'bundler/setup' 7 | require 'bacon' 8 | require 'cocoapods' 9 | 10 | require 'cocoapods_plugin' 11 | 12 | #-----------------------------------------------------------------------------# 13 | 14 | module Pod 15 | 16 | # Disable the wrapping so the output is deterministic in the tests. 17 | # 18 | UI.disable_wrap = true 19 | 20 | # Redirects the messages to an internal store. 21 | # 22 | module UI 23 | @output = '' 24 | @warnings = '' 25 | 26 | class << self 27 | attr_accessor :output 28 | attr_accessor :warnings 29 | 30 | def puts(message = '') 31 | @output << "#{message}\n" 32 | end 33 | 34 | def warn(message = '', actions = []) 35 | @warnings << "#{message}\n" 36 | end 37 | 38 | def print(message) 39 | @output << message 40 | end 41 | end 42 | end 43 | end 44 | 45 | #-----------------------------------------------------------------------------# 46 | --------------------------------------------------------------------------------