1
- #!/usr/bin/env ruby
2
- require 'xcodeproj'
3
- require 'fileutils'
4
-
5
- # Replace these with your values
6
- current_path = Dir . pwd
7
- project_path = Dir . glob ( "#{ current_path } /ios/*.xcodeproj" ) . first
8
- file_name = File . basename ( project_path , ".xcodeproj" )
9
- project_location = './ios/' +file_name +'.xcodeproj'
10
- target_name = file_name
11
- framework_root = '../node_modules/instabug-reactnative/ios'
12
- framework_name = 'Instabug.framework'
13
-
14
- # Get useful variables
15
- project = Xcodeproj ::Project . open ( project_location )
16
- frameworks_group = project . groups . find { |group | group . display_name == 'Frameworks' }
17
- if frameworks_group == nil
18
- frameworks_group = project . new_group ( 'Frameworks' )
19
- end
20
- target = project . targets . find { |target | target . to_s == target_name }
21
- frameworks_build_phase = target . build_phases . find { |build_phase | build_phase . to_s == 'FrameworksBuildPhase' }
22
-
23
- # Add new "Embed Frameworks" build phase to target
24
- embed_frameworks_build_phase = project . new ( Xcodeproj ::Project ::Object ::PBXCopyFilesBuildPhase )
25
- embed_frameworks_build_phase . name = 'Embed Frameworks'
26
- embed_frameworks_build_phase . symbol_dst_subfolder_spec = :frameworks
27
- target . build_phases << embed_frameworks_build_phase
28
-
29
- # Add framework search path to target
30
- [ 'Debug' , 'Release' ] . each do |config |
31
- paths = [ '$(inherited)' , framework_root ]
32
- target . build_settings ( config ) [ 'FRAMEWORK_SEARCH_PATHS' ] = paths
33
- end
34
-
35
- # Add framework to target as "Embedded Frameworks"
36
- framework_ref = frameworks_group . new_file ( "#{ framework_root } /#{ framework_name } " )
37
- build_file = embed_frameworks_build_phase . add_file_reference ( framework_ref )
38
- frameworks_build_phase . add_file_reference ( framework_ref )
39
- build_file . settings = { 'ATTRIBUTES' => [ 'CodeSignOnCopy' , 'RemoveHeadersOnCopy' ] }
40
-
41
- # Save Xcode project
1
+ #!/usr/bin/env ruby
2
+ begin
3
+ require 'xcodeproj'
4
+ rescue LoadError
5
+ puts ( 'xcodeproj doesn\'t exist' )
6
+ Kernel . exit ( 0 )
7
+ end
8
+ require 'fileutils'
9
+
10
+ # Replace these with your values
11
+ current_path = Dir . pwd
12
+ project_path = Dir . glob ( "#{ current_path } /ios/*.xcodeproj" ) . first
13
+ file_name = File . basename ( project_path , ".xcodeproj" )
14
+ project_location = './ios/' +file_name +'.xcodeproj'
15
+ target_name = file_name
16
+ framework_root = '../node_modules/instabug-reactnative/ios'
17
+ framework_name = 'Instabug.framework'
18
+
19
+ # Get useful variables
20
+ project = Xcodeproj ::Project . open ( project_location )
21
+ frameworks_group = project . groups . find { |group | group . display_name == 'Frameworks' }
22
+ if frameworks_group == nil
23
+ frameworks_group = project . new_group ( 'Frameworks' )
24
+ end
25
+ target = project . targets . find { |target | target . to_s == target_name }
26
+ frameworks_build_phase = target . build_phases . find { |build_phase | build_phase . to_s == 'FrameworksBuildPhase' }
27
+
28
+ # Add new "Embed Frameworks" build phase to target
29
+ embed_frameworks_build_phase = project . new ( Xcodeproj ::Project ::Object ::PBXCopyFilesBuildPhase )
30
+ embed_frameworks_build_phase . name = 'Embed Frameworks'
31
+ embed_frameworks_build_phase . symbol_dst_subfolder_spec = :frameworks
32
+ target . build_phases << embed_frameworks_build_phase
33
+
34
+ # Add framework search path to target
35
+ [ 'Debug' , 'Release' ] . each do |config |
36
+ paths = [ '$(inherited)' , framework_root ]
37
+ target . build_settings ( config ) [ 'FRAMEWORK_SEARCH_PATHS' ] = paths
38
+ end
39
+
40
+ # Add framework to target as "Embedded Frameworks"
41
+ framework_ref = frameworks_group . new_file ( "#{ framework_root } /#{ framework_name } " )
42
+ build_file = embed_frameworks_build_phase . add_file_reference ( framework_ref )
43
+ frameworks_build_phase . add_file_reference ( framework_ref )
44
+ build_file . settings = { 'ATTRIBUTES' => [ 'CodeSignOnCopy' , 'RemoveHeadersOnCopy' ] }
45
+
46
+ # Save Xcode project
42
47
project . save
0 commit comments