|
26 | 26 | frameworks_group = project.groups.find { |group| group.display_name == 'Frameworks' }
|
27 | 27 | frameworks_group ||= project.new_group('Frameworks')
|
28 | 28 | default_target = project.targets.find { |target| target.to_s == default_target_name }
|
29 |
| -targets = project.targets |
| 29 | +targets = project.targets.select { |target| (target.is_a? Xcodeproj::Project::Object::PBXNativeTarget) && |
| 30 | + (target.product_type == "com.apple.product-type.application") && |
| 31 | + (target.platform_name == :ios) } |
30 | 32 | framework_ref = frameworks_group.new_file("#{framework_root}/#{framework_name}")
|
31 | 33 |
|
32 | 34 | # Add Instabug to every target that is of type application
|
33 | 35 | targets.each do |target|
|
34 |
| - if target.is_a? Xcodeproj::Project::Object::PBXNativeTarget && (target.product_type == "com.apple.product-type.application") && (target.platform_name == :ios) |
| 36 | + # Add new "Embed Frameworks" build phase to target |
| 37 | + embed_frameworks_build_phase = target.build_phases.find { |build_phase| build_phase.to_s == 'Embed Instabug Framework'} |
| 38 | + Kernel.exit(0) if embed_frameworks_build_phase |
| 39 | + embed_frameworks_build_phase = project.new(Xcodeproj::Project::Object::PBXCopyFilesBuildPhase) |
| 40 | + embed_frameworks_build_phase.name = 'Embed Instabug Framework' |
| 41 | + embed_frameworks_build_phase.symbol_dst_subfolder_spec = :frameworks |
| 42 | + target.build_phases << embed_frameworks_build_phase |
35 | 43 |
|
36 |
| - # Add new "Embed Frameworks" build phase to target |
37 |
| - embed_frameworks_build_phase = target.build_phases.find { |build_phase| build_phase.to_s == 'Embed Instabug Framework'} |
38 |
| - Kernel.exit(0) if embed_frameworks_build_phase |
39 |
| - embed_frameworks_build_phase = project.new(Xcodeproj::Project::Object::PBXCopyFilesBuildPhase) |
40 |
| - embed_frameworks_build_phase.name = 'Embed Instabug Framework' |
41 |
| - embed_frameworks_build_phase.symbol_dst_subfolder_spec = :frameworks |
42 |
| - target.build_phases << embed_frameworks_build_phase |
43 |
| - |
44 |
| - # Add static library to non default targets' build phase |
45 |
| - if target.name != default_target_name |
46 |
| - static_library_file_reference = default_target.frameworks_build_phase.files_references.find { |file_reference| file_reference.path == 'libRNInstabug.a' } |
47 |
| - target.frameworks_build_phase.add_file_reference(static_library_file_reference) |
48 |
| - end |
| 44 | + # Add static library to non default targets' build phase |
| 45 | + if target.name != default_target_name |
| 46 | + static_library_file_reference = default_target.frameworks_build_phase.files_references.find { |file_reference| file_reference.path == 'libRNInstabug.a' } |
| 47 | + target.frameworks_build_phase.add_file_reference(static_library_file_reference) |
| 48 | + end |
49 | 49 |
|
50 |
| - # Add framework search path to target |
51 |
| - target.build_configurations.each do |config| |
52 |
| - framework_search_paths = target.build_settings(config.name)['FRAMEWORK_SEARCH_PATHS'] |
| 50 | + # Add framework search path to target |
| 51 | + target.build_configurations.each do |config| |
| 52 | + framework_search_paths = target.build_settings(config.name)['FRAMEWORK_SEARCH_PATHS'] |
53 | 53 |
|
54 |
| - framework_search_paths ||= ['$(inherited)'] |
55 |
| - framework_search_paths = [framework_search_paths] unless framework_search_paths.is_a?(Array) |
56 |
| - framework_search_paths << framework_root unless framework_search_paths.include? framework_root |
| 54 | + framework_search_paths ||= ['$(inherited)'] |
| 55 | + framework_search_paths = [framework_search_paths] unless framework_search_paths.is_a?(Array) |
| 56 | + framework_search_paths << framework_root unless framework_search_paths.include? framework_root |
57 | 57 |
|
58 |
| - target.build_settings(config.name)['FRAMEWORK_SEARCH_PATHS'] = framework_search_paths |
59 |
| - end |
| 58 | + target.build_settings(config.name)['FRAMEWORK_SEARCH_PATHS'] = framework_search_paths |
| 59 | + end |
60 | 60 |
|
61 |
| - # Add framework to target as "Embedded Frameworks" |
| 61 | + # Add framework to target as "Embedded Frameworks" |
62 | 62 |
|
63 |
| - build_file = embed_frameworks_build_phase.add_file_reference(framework_ref) |
64 |
| - target.frameworks_build_phase.add_file_reference(framework_ref) |
65 |
| - build_file.settings = { 'ATTRIBUTES' => ['CodeSignOnCopy', 'RemoveHeadersOnCopy'] } |
| 63 | + build_file = embed_frameworks_build_phase.add_file_reference(framework_ref) |
| 64 | + target.frameworks_build_phase.add_file_reference(framework_ref) |
| 65 | + build_file.settings = { 'ATTRIBUTES' => ['CodeSignOnCopy', 'RemoveHeadersOnCopy'] } |
66 | 66 |
|
67 | 67 |
|
68 |
| - #Add New Run Script Phase to Build Phases |
69 |
| - phase = target.new_shell_script_build_phase(INSTABUG_PHASE_NAME) |
70 |
| - phase.shell_script = INSTABUG_PHASE_SCRIPT |
71 |
| - end |
| 68 | + #Add New Run Script Phase to Build Phases |
| 69 | + phase = target.new_shell_script_build_phase(INSTABUG_PHASE_NAME) |
| 70 | + phase.shell_script = INSTABUG_PHASE_SCRIPT |
72 | 71 | end
|
73 | 72 |
|
74 | 73 | # Save Xcode project
|
|
0 commit comments