BranchMetrics / capacitor-branch-deep-links

Capacitor plugin for branch.io deep links
MIT License
32 stars 43 forks source link

SDK missing AdServices import - iOS #33

Open scottholdren opened 3 years ago

scottholdren commented 3 years ago

A recent update to the SDK has removed the AdServices import, which is breaking iOS builds. Manually setting

pod 'Branch', '1.38.0' has fixed it for now.

stevecarlton commented 3 years ago

+1 for breaking our iOS builds.

@scottholdren do you mind clarifying where you added this? I tried adding at the bottom of /ios/App/Podfile by got an error when running ionic cap sync:

[!] CocoaPods could not find compatible versions for pod "Branch":
  In Podfile:
    Branch (= 1.38.0)

Edit: I did the following below and unfortunately still got the build error ld: framework not found AdServices

  1. Added pod 'Branch', '1.38.0' in the target 'App' do section of /ios/App/Podfile
  2. Went to /ios/App in terminal and ran pod install --repo-update
scottholdren commented 3 years ago

I am appending it to /ios/App/Podfile, followed by some stuff to fix bitcode errors.

I am running

pod repo update ionic capacitor add ios cat build_resources/Podfile.extras >> ios/App/Podfile

in that order every time.

build_resources/Podfile.extras

pod 'Branch', '1.38.0'

def disable_bitcode_for_target(target)
    target.build_configurations.each do |config|
      config.build_settings['ENABLE_BITCODE'] = 'NO'

      remove_cflags_matching(config.build_settings, ['-fembed-bitcode', '-fembed-bitcode-marker'])
    end
end

def remove_cflags_matching(build_settings, cflags)
  existing_cflags = build_settings['OTHER_CFLAGS']

  removed_cflags = []
  if !existing_cflags.nil?
    cflags.each do |cflag|
      existing_cflags.delete_if { |existing_cflag| existing_cflag == cflag && removed_cflags << cflag }
    end
  end

  if removed_cflags.length > 0
    build_settings['OTHER_CFLAGS'] = existing_cflags
  end
end

post_install do |installer|
  project_name = Dir.glob("*.xcodeproj").first
  project = Xcodeproj::Project.open(project_name)
  project.targets.each do |target|
    disable_bitcode_for_target(target)
  end
  project.save

  installer.pods_project.targets.each do |target|
    disable_bitcode_for_target(target)
  end

  installer.pods_project.save
end
stevecarlton commented 3 years ago

I am appending it to /ios/App/Podfile, followed by some stuff to fix bitcode errors.

I am running

pod repo update ionic capacitor add ios cat build_resources/Podfile.extras >> ios/App/Podfile

in that order every time.

build_resources/Podfile.extras

pod 'Branch', '1.38.0'

def disable_bitcode_for_target(target)
    target.build_configurations.each do |config|
      config.build_settings['ENABLE_BITCODE'] = 'NO'

      remove_cflags_matching(config.build_settings, ['-fembed-bitcode', '-fembed-bitcode-marker'])
    end
end

def remove_cflags_matching(build_settings, cflags)
  existing_cflags = build_settings['OTHER_CFLAGS']

  removed_cflags = []
  if !existing_cflags.nil?
    cflags.each do |cflag|
      existing_cflags.delete_if { |existing_cflag| existing_cflag == cflag && removed_cflags << cflag }
    end
  end

  if removed_cflags.length > 0
    build_settings['OTHER_CFLAGS'] = existing_cflags
  end
end

post_install do |installer|
  project_name = Dir.glob("*.xcodeproj").first
  project = Xcodeproj::Project.open(project_name)
  project.targets.each do |target|
    disable_bitcode_for_target(target)
  end
  project.save

  installer.pods_project.targets.each do |target|
    disable_bitcode_for_target(target)
  end

  installer.pods_project.save
end

Thank you, I'll give this a shot!

nbiles commented 3 years ago

Having the same issue still.

KirstenStake commented 2 years ago

same issue. has anyone got this working withpod 'Branch', '1.39.4' ?