Skip to content

fix(ios): include the Obj-C shim in the podspec source_files - #397

Open
bohdanvela wants to merge 2 commits into
Dev-hwang:masterfrom
bohdanvela:fix/ios-podspec-objc-shim-path
Open

fix(ios): include the Obj-C shim in the podspec source_files#397
bohdanvela wants to merge 2 commits into
Dev-hwang:masterfrom
bohdanvela:fix/ios-podspec-objc-shim-path

Conversation

@bohdanvela

Copy link
Copy Markdown

Problem

The Obj-C shim added in 11.0.2 is never compiled under CocoaPods, so 11.0.2 still fails exactly like 11.0.1 for non-SPM apps (#395, #396):

Semantic Issue (Xcode): Unknown receiver 'FlutterForegroundTaskPlugin';
did you mean 'SwiftFlutterForegroundTaskPlugin'?
ios/Runner/GeneratedPluginRegistrant.m

Cause

Both globs in source_files are resolved relative to the podspec's directory (ios/). The Swift glob carries the flutter_foreground_task/ prefix, but the Obj-C one does not:

s.source_files = 'flutter_foreground_task/Sources/flutter_foreground_task/**/*.swift',
                 'Classes/**/*.{h,m}'

So CocoaPods looks for ios/Classes/, while the files actually live in ios/flutter_foreground_task/Classes/. The glob matches nothing, the shim is silently dropped from the pod, and FlutterForegroundTaskPlugin never exists for the generated registrant — the class is otherwise only declared in FlutterForegroundTaskPluginSPMBridge.swift behind #if SWIFT_PACKAGE, which is not defined for CocoaPods builds.

Fix

Add the missing prefix so the shim is part of the pod.

Verification

Built a real CocoaPods (non-SPM) app against this repo, wiping Pods/ and build/ before each run and changing only this glob:

source_files Obj-C glob Result FlutterForegroundTaskPlugin.m refs in generated Pods.xcodeproj
'Classes/**/*.{h,m}' (11.0.2 as published) Unknown receiver 'FlutterForegroundTaskPlugin' 0
'flutter_foreground_task/Classes/**/*.{h,m}' (this PR) ✅ builds and links 4

Environment: Flutter 3.47.2, CocoaPods 1.16.2, Xcode iOS device release build, SPM disabled (flutter config --no-enable-swift-package-manager).

Closes #395
Closes #396

The shim added in 11.0.2 is never compiled under CocoaPods, so 11.0.2 still
fails exactly like 11.0.1 (Dev-hwang#395, Dev-hwang#396):

  Semantic Issue (Xcode): Unknown receiver 'FlutterForegroundTaskPlugin';
  did you mean 'SwiftFlutterForegroundTaskPlugin'?
  ios/Runner/GeneratedPluginRegistrant.m

Both globs in source_files are resolved relative to the podspec's directory
(ios/). The Swift glob carries the `flutter_foreground_task/` prefix, but the
Obj-C one does not, so CocoaPods looks for ios/Classes/ while the files
actually live in ios/flutter_foreground_task/Classes/. The glob matches
nothing and the shim is silently dropped from the pod.

Add the missing prefix so the shim is compiled.

Verified on a CocoaPods (non-SPM) app, clean Pods/ and build/ each time,
changing only this glob:

  before -> Unknown receiver ...; 0 references to
            FlutterForegroundTaskPlugin.m in the generated Pods.xcodeproj
  after  -> builds and links; 4 references
@bohdanvela

Copy link
Copy Markdown
Author

@Dev-hwang please take a look, it should fix these issues
#396
#395

@bohdanvela

Copy link
Copy Markdown
Author

I had the same problem and when I tried to clean the cache, the error persisted

Ship the podspec fix so CocoaPods users are unblocked; 11.0.2 still fails
with "Unknown receiver 'FlutterForegroundTaskPlugin'" because the shim it
added never reaches the pod.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants