-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode_generator.rb
61 lines (58 loc) · 1.45 KB
/
code_generator.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
require "xcodeproj"
module Xcodeproj
class CodeGenerator
attr_accessor :target_name
attr_accessor :pods_to_add
def initialize(t_name)
self.target_name=t_name
end
def header_code(class_name)
%{// Made by script
#import <Foundation/Foundation.h>
@interface #{class_name} : NSObject
@end}
end
def implementation_code(class_name)
%{// Made by script
#import "#{class_name}.h"
#{pods_imports.join("\n")}
@implementation #{class_name}
@end}
end
def pod_file_code(plugin=True)
%{# Made by script
# Uncomment the next line to define a global platform for your project
platform :ios, '10.0'
#{plugin ? "plugin 'cocoapods-project-hmap'" : ''}
target '#{target_name}' do
# Comment the next line if you don't want to use dynamic frameworks
# use_frameworks!
# Pods for #{target_name}
#{pods_dsl.join("\n")}
# m1 processor
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
config.build_settings["IPHONEOS_DEPLOYMENT_TARGET"] = '9.0'
end
end
end
end}
end
def pods_dsl
dsls=[]
pods_to_add.each do |one|
dsls << " pod '#{one}'"
end
dsls
end
def pods_imports
imports=[]
pods_to_add.each do |one|
imports << "#import <#{one}/#{one}.h>"
end
imports
end
end
end