2

Problem

I have add iOS Share Extension into a very simple Flutter project,

My code setup with device on feature branch, I also know bitcode in flutter is not ready yet:

Run Target: Share Extension on device

ld: '[Project_Path]/ios/DerivedData/Products/Debug-iphoneos/FMDB/libFMDB.a(FMDatabase.o)' 
does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting 
ENABLE_BITCODE)

Run Target: The Container App on device

NOTE: this [CP] Embed Pods Framworks is same as [ProjectCompare].

* Run custom shell script '[CP] Embed Pods Framworks'....
* Validate [Project_Path]/ios/DerivedData/Products/Debug-iphonos/Runner.app/PlugIns/
  ShareExtension.appe(in target: Runner)
* cd [Project_Path]/ios
* builtin-embeddedBinaryValidationUtility [Project_Path]/ios/DerivedData/Products/
  Debug-iphonos/Runner.app/PlugIns/ShareExtension.appex 
    -siging-cert [someID] 
    -info-plist-path [Project_Path]/ios/DerivedData/Products/Debug-iphonos/Runner.app/Info.plist
* error: Embedded binary is not signed with the same certificate as the parent app. 
  Verify the embedded binary target's code sign settings match the parent app's.
    * Embedded Binary Signing Certificate:    Not Code Signed
    * Parent App Signing Certificate:  iPhone Developer: MyName (XXXXX)

To Compare

I also have create a pure iOS project ProjectCompare too, and add Pod into it, after change. I open project with workspace and add Share Extension, it works well on device.

Question

So I think maybe some script related to Flutter setup cause this error ? Or the script in Podfile ?

Any idea how to do?

UPDATE

After overwrite setting in Target: Share Extension:

  • LIBRARY_SEARCH_PATHS = "";
  • OTHER_LDFLAGS = ""; or OTHER_LDFLAGS = "-ObjC";

Run Target: ShareExtension & Target: The Container App on device both works.

JerryZhou
  • 4,566
  • 3
  • 37
  • 60

1 Answers1

2

So with @pulyaevskiy's help. I found the fix:

Short:

overwrite setting in Target: Share Extension: (git diff sample)

LIBRARY_SEARCH_PATHS = "";

OTHER_LDFLAGS = ""; or OTHER_LDFLAGS = "-ObjC";

Detail:

  1. Location: when run Target: ShareExtension & Target: Container App both get error, just because adding the Target: Share Extension. It means the error are mostly coming from Target: ShareExtension.

  2. List the command details:

[Clang Path]/clang -arch arm64 -isysroot 
[iOS SDK Path]/iPhoneOS12.4.sdk 
-L[Project Path]/ios/DerivedData/Products/Debug-iphoneos 
-L[Project Path]/ios/DerivedData/Products/Debug-iphoneos/FMDB      <-- this 
-L[Project Path]/ios/DerivedData/Products/Debug-iphoneos/sqflite   <-- this 
-F[Project Path]/ios/DerivedData/Products/Debug-iphoneos 
-F[Project Path]/ios/Pods/../.symlinks/flutter/ios 
-filelist [Project Path]/ios/DerivedData/Build/Intermediates/Runner.build/Debug-iphoneos/ShareExtension.build/Objects-normal/arm64/ShareExtension.LinkFileList 
-Xlinker 
-rpath 
-Xlinker @executable_path/Frameworks 
-Xlinker 
-rpath 
-Xlinker @loader_path/Frameworks 
-Xlinker 
-rpath 
-Xlinker @executable_path/Frameworks 
-Xlinker 
-rpath 
-Xlinker 
@executable_path/../../Frameworks 
-miphoneos-version-min=12.4 
-dead_strip 
-Xlinker 
-object_path_lto 
-Xlinker [Project Path]/ios/DerivedData/Build/Intermediates/Runner.build/Debug-iphoneos/ShareExtension.build/Objects-normal/arm64/ShareExtension_lto.o 
-Xlinker 
-export_dynamic 
-Xlinker 
-no_deduplicate 
-fembed-bitcode-marker 
-fobjc-arc 
-fobjc-link-runtime 
-fapplication-extension 
-ObjC 
-lFMDB              <-- this 
-lsqflite           <-- this 
-lsqlite3           <-- this 
-framework Flutter  <-- this 
-e _NSExtensionMain 
-Xlinker 
-dependency_info 
-Xlinker [Project Path]/ios/DerivedData/Build/Intermediates/Runner.build/Debug-iphoneos/ShareExtension.build/Objects-normal/arm64/ShareExtension_dependency_info.dat 
-o [Project Path]/ios/DerivedData/Products/Debug-iphoneos/ShareExtension.appex/ShareExtension

Error detail:

ld: '[Project_Path]/ios/DerivedData/Products/Debug-iphoneos/FMDB/libFMDB.a(FMDatabase.o)' 
does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting 
ENABLE_BITCODE)
  1. So search Target: ShareExtension's setting with FMDB, there's 3 result:

    1. Other Linker Flags:-l"FMDB"
    2. Header Search Flags:"${PODS_ROOT}/Headers/Public/FMDB"
    3. Library Search Flags:"${PODS_CONFIGURATION_BUILD_DIR}/FMDB"
  2. Library Search Flags is the one like a path of DerivedData/Products/Debug-iphoneos/FMDB/libFMDB.a, so I overwrite it with "", result in git diff is add a new line: LIBRARY_SEARCH_PATHS = "";

  3. Run Target: ShareExtension to check result: These two line of command details are gone

-L[Project Path]/ios/DerivedData/Products/Debug-iphoneos/FMDB
-L[Project Path]/ios/DerivedData/Products/Debug-iphoneos/sqflite 

Error become(which also means above change works):

ld: library not found for -lFMDB
  1. Search FMDB again, and I guess the Other Linker Flags:-l"FMDB" are like the error of -lFMDB, so I overwrite it with ""(or left "-ObjC"), result in git diff is add a new line: OTHER_LDFLAGS = ""; or OTHER_LDFLAGS = "-ObjC";.

  2. Run Target: ShareExtension & Target: Container App now both works.

Check change in git differ

enter image description here enter image description here enter image description here

JerryZhou
  • 4,566
  • 3
  • 37
  • 60