Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…tive into hotfix/fix_crash_for_ios_8
  • Loading branch information
salmatarzi committed Sep 10, 2017
2 parents 0f43c93 + 851b51f commit 6db813a
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 11 deletions.
2 changes: 1 addition & 1 deletion ios/RNInstabug/InstabugReactBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ - (dispatch_queue_t)methodQueue {
[Instabug identifyUserWithEmail:email name:name];
}

RCT_EXPORT_METHOD(logout) {
RCT_EXPORT_METHOD(logOut) {
[Instabug logOut];
}

Expand Down
24 changes: 15 additions & 9 deletions link.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,46 @@
puts('xcodeproj doesn\'t exist')
Kernel.exit(0)
end
require 'fileutils'

# Replace these with your values
current_path = Dir.pwd
project_path = Dir.glob("#{current_path}/ios/*.xcodeproj").first
file_name = File.basename(project_path, ".xcodeproj")
project_location = './ios/'+file_name+'.xcodeproj'
project_location = "./ios/#{file_name}.xcodeproj"
target_name = file_name
framework_root = '../node_modules/instabug-reactnative/ios'
framework_name = 'Instabug.framework'

INSTABUG_PHASE_NAME = "Strip Frameworks"

INSTABUG_PHASE_SCRIPT = <<-SCRIPTEND
bash "${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/Instabug.framework/Instabug.bundle/strip-frameworks.sh"
SCRIPTEND

# Get useful variables
project = Xcodeproj::Project.open(project_location)
frameworks_group = project.groups.find { |group| group.display_name == 'Frameworks' }
if frameworks_group == nil
frameworks_group = project.new_group('Frameworks')
end
frameworks_group ||= project.new_group('Frameworks')
target = project.targets.find { |target| target.to_s == target_name }
frameworks_build_phase = target.build_phases.find { |build_phase| build_phase.to_s == 'FrameworksBuildPhase' }

# Add new "Embed Frameworks" build phase to target
embed_frameworks_build_phase = target.build_phases.find { |build_phase| build_phase.to_s == 'Embed Instabug Framework'}
Kernel.exit(0) if embed_frameworks_build_phase
embed_frameworks_build_phase = project.new(Xcodeproj::Project::Object::PBXCopyFilesBuildPhase)
embed_frameworks_build_phase.name = 'Embed Frameworks'
embed_frameworks_build_phase.name = 'Embed Instabug Framework'
embed_frameworks_build_phase.symbol_dst_subfolder_spec = :frameworks
target.build_phases << embed_frameworks_build_phase
target.build_phases << embed_frameworks_build_phase

# Add framework search path to target
['Debug', 'Release'].each do |config|
paths = ['$(inherited)', framework_root]
target.build_settings(config)['FRAMEWORK_SEARCH_PATHS'] = paths
framework_search_paths = target.build_settings(config)['FRAMEWORK_SEARCH_PATHS']

framework_search_paths ||= ['$(inherited)']
framework_search_paths = [framework_search_paths] unless framework_search_paths.is_a?(Array)
framework_search_paths << framework_root unless framework_search_paths.include? framework_root

target.build_settings(config)['FRAMEWORK_SEARCH_PATHS'] = framework_search_paths
end

# Add framework to target as "Embedded Frameworks"
Expand All @@ -48,6 +53,7 @@
frameworks_build_phase.add_file_reference(framework_ref)
build_file.settings = { 'ATTRIBUTES' => ['CodeSignOnCopy', 'RemoveHeadersOnCopy'] }


#Add New Run Script Phase to Build Phases
phase = target.new_shell_script_build_phase(INSTABUG_PHASE_NAME)
phase.shell_script = INSTABUG_PHASE_SCRIPT
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"homepage": "https://github.com/Instabug/instabug-reactnative#readme",
"rnpm": {
"commands": {
"postlink": "ruby ./node_modules/instabug-reactnative/link.rb || echo \"Ruby doesn't exist, if you're building this for Android only, then feel free to ignore this error, otherwise please install Ruby and run 'react-native link instabug-reactnative' again\""
"postlink": "ruby ./node_modules/instabug-reactnative/link.rb || echo \"Ruby doesn't exist, if you're building this for Android only, then feel free to ignore this error, otherwise please install Ruby and run 'react-native link instabug-reactnative' again\"",
"preunlink": "ruby ./node_modules/instabug-reactnative/unlink.rb || echo \"Ruby doesn't exist, if you're building this for Android only, then feel free to ignore this error, otherwise please install Ruby and run 'react-native link instabug-reactnative' again\""
},
"android": {
"packageInstance": "\t\tnew RNInstabugReactnativePackage.Builder(\"YOUR_ANDROID_APPLICATION_TOKEN\",MainApplication.this)\n\t\t\t\t\t\t\t.setInvocationEvent(\"shake\")\n\t\t\t\t\t\t\t.setPrimaryColor(\"#1D82DC\")\n\t\t\t\t\t\t\t.setFloatingEdge(\"left\")\n\t\t\t\t\t\t\t.setFloatingButtonOffsetFromTop(250)\n\t\t\t\t\t\t\t.build()"
Expand Down
46 changes: 46 additions & 0 deletions unlink.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env ruby
begin
require 'xcodeproj'
rescue LoadError
puts('xcodeproj doesn\'t exist')
Kernel.exit(0)
end

# Replace these with your values
current_path = Dir.pwd
project_path = Dir.glob("#{current_path}/ios/*.xcodeproj").first
file_name = File.basename(project_path, ".xcodeproj")
project_location = "./ios/#{file_name}.xcodeproj"
target_name = file_name
framework_root = '../node_modules/instabug-reactnative/ios'
framework_name = 'Instabug.framework'

INSTABUG_PHASE_NAME = "Strip Frameworks"

# Get useful variables
project = Xcodeproj::Project.open(project_location)
frameworks_group = project.groups.find { |group| group.display_name == 'Frameworks' }
target = project.targets.find { |target| target.to_s == target_name }
frameworks_build_phase = target.build_phases.find { |build_phase| build_phase.to_s == 'FrameworksBuildPhase' }

# Remove "Embed Frameworks" build phase to target
embed_frameworks_build_phase = target.build_phases.find { |build_phase| build_phase.to_s == 'Embed Instabug Framework'}
Kernel.exit(0) unless embed_frameworks_build_phase
target.build_phases.delete(embed_frameworks_build_phase)

# Remove framework search path from target
['Debug', 'Release'].each do |config|
target.build_settings(config)['FRAMEWORK_SEARCH_PATHS'].delete(framework_root)
end

# Remove framework from target from "Embedded Frameworks"
framework_ref = frameworks_group.files.find { |file_reference| file_reference.path == "#{framework_root}/#{framework_name}"}
frameworks_build_phase.remove_file_reference(framework_ref)
framework_ref.remove_from_project

#Delete New Run Script Phase from Build Phases
shell_script_build_phase = target.shell_script_build_phases.find { |build_phase| build_phase.to_s == INSTABUG_PHASE_NAME }
target.build_phases.delete(shell_script_build_phase)

# Save Xcode project
project.save

0 comments on commit 6db813a

Please sign in to comment.