diff --git a/ios/RNInstabug/InstabugReactBridge.m b/ios/RNInstabug/InstabugReactBridge.m index 72e936356..d80f79b4f 100644 --- a/ios/RNInstabug/InstabugReactBridge.m +++ b/ios/RNInstabug/InstabugReactBridge.m @@ -229,7 +229,7 @@ - (dispatch_queue_t)methodQueue { [Instabug identifyUserWithEmail:email name:name]; } -RCT_EXPORT_METHOD(logout) { +RCT_EXPORT_METHOD(logOut) { [Instabug logOut]; } diff --git a/link.rb b/link.rb index a5a1c7b4c..b3b5e23f6 100644 --- a/link.rb +++ b/link.rb @@ -5,18 +5,18 @@ 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 @@ -24,22 +24,27 @@ # 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" @@ -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 diff --git a/package.json b/package.json index f40e38e7f..7abd40118 100644 --- a/package.json +++ b/package.json @@ -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()" diff --git a/unlink.rb b/unlink.rb new file mode 100644 index 000000000..014d4dcae --- /dev/null +++ b/unlink.rb @@ -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 \ No newline at end of file