본문 바로가기
Flutter

Podfile - flutter 3.29 적용

by kage2k 2025. 4. 27.
728x90
반응형

최근에 gpt 3o 에 도움을 받아서 podfile 에서 미리 에러를 해결하는 방향을 물어서 테스팅 해서 기록으로 남긴다. 

 

# ios/Podfile ── Flutter 3.29.x + 사용자 커스텀
platform :ios, '15.0'           # Flutter 3.29 최소 권장 iOS

ENV['COCOAPODS_DISABLE_STATS'] = 'true'
install! 'cocoapods', deterministic_uuids: false  # UUID 재현성 해제(옵션)

use_frameworks!                # Swift 동적 프레임워크 지원
use_modular_headers!           # Obj-C 모듈형 헤더

# ────────────────────────────────────────────────────────────
# FLUTTER_ROOT 경로를 Podfile에서 얻기 위한 헬퍼
def flutter_root
  generated_xcode_build_settings_path = File.expand_path(
    File.join('..', 'Flutter', 'Generated.xcconfig'),
    __FILE__
  )
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. Run `flutter pub get` first."
  end
  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. " \
        "Try deleting it, then run `flutter pub get`."
end

# flutter_install_all_ios_pods, flutter_additional_ios_build_settings 로드
require File.expand_path(
  File.join('packages', 'flutter_tools', 'bin', 'podhelper'),
  flutter_root
)

# ────────────────────────────────────────────────────────────
target 'Runner' do
  # Flutter 및 플러그인 Pods 주입
  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))

  # (옵션) 테스트 타깃 추가 예시
  # target 'RunnerTests' do
  #   inherit! :search_paths
  # end
end

# ────────────────────────────────────────────────────────────

post_install do |installer|
    # 모든 Pods 타깃(플러그인) 처리
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        # ✅ Apple-Silicon 맥에서만 arm64 제외
        if `uname -m`.strip == 'arm64'
          config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'
        else
          # Intel Mac이라면 arm64 slice도 빌드하도록 허용
          config.build_settings.delete('EXCLUDED_ARCHS[sdk=iphonesimulator*]')
        end



        config.build_settings.delete('ENABLE_BITCODE')
        config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'NO'   # ← 추가
      end
      flutter_additional_ios_build_settings(target)
    end
  
    # Runner·테스트 타깃 처리
    installer.aggregate_targets.each do |aggregate|
      aggregate.user_project.targets.each do |t|
        t.build_configurations.each do |c|
          c.build_settings.delete('ENABLE_BITCODE')
          c.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION']
        end
      end
    end
  end

 

저장하고 

ios/Podfile.lock 파일이 있다면 삭제

 

flutter clean && flutter pub get

cd ios && pod deintegrate && pod install --repo-update

cd .. && flutter run (또는 flutter build ipa)

 

 

300x250
반응형