adtrace / adtrace_sdk_flutter

This is the Flutter SDK of
https://adtrace.io/
MIT License
6 stars 1 forks source link

iOS build error #5

Closed sajjad-n closed 1 month ago

sajjad-n commented 2 years ago

Hi guys πŸ‘‹ I have implemented the package according to documentation but when I want to build iOS, getting this error :

Failed to build iOS app
Error output from Xcode build:
↳
    objc[47766]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libauthinstall.dylib (0x1f6ceec10) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x10ce542c8). One of the two will be used. Which one is undefined.
    objc[47766]: Class AMSupportURLSession is implemented in both /usr/lib/libauthinstall.dylib (0x1f6ceec60) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x10ce54318). One of the two will be used. Which one is undefined.
    ** BUILD FAILED **

Xcode's output:
↳
    Writing result bundle at path:
        /var/folders/bd/5c7b530j6sb62_rlkg6266180000gn/T/flutter_tools.tqWJmb/flutter_ios_build_temp_dir3gzr4u/temporary_xcresult_bundle

    2 warnings generated.
    /Users/sajjad/flutter-sdk/.pub-cache/hosted/pub.dartlang.org/adtrace_sdk_flutter-1.2.0/ios/Classes/AdTraceSdkDelegate.m:4:9: warning: non-portable path to file '"AdTraceSdkDelegate.h"'; specified path differs in case from file name on disk [-Wnonportable-include-path]
    #import "AdtraceSdkDelegate.h"
            ^~~~~~~~~~~~~~~~~~~~~~
            "AdTraceSdkDelegate.h"
    1 warning generated.
    /Users/sajjad/flutter-sdk/.pub-cache/hosted/pub.dartlang.org/adtrace_sdk_flutter-1.2.0/ios/Classes/AdTraceSdkDelegate.m:4:9: warning: non-portable path to file '"AdTraceSdkDelegate.h"'; specified path differs in case from file name on disk [-Wnonportable-include-path]
    #import "AdtraceSdkDelegate.h"
            ^~~~~~~~~~~~~~~~~~~~~~
            "AdTraceSdkDelegate.h"
    1 warning generated.
    2 warnings generated.
    /Users/sajjad/sunny/ios/Runner/GeneratedPluginRegistrant.m:10:2: warning: missing submodule 'adtrace_sdk_flutter.AdtraceSdk' [-Wincomplete-umbrella]
    #import <adtrace_sdk_flutter/AdtraceSdk.h>
     ^      ~
    While building module 'mobile_scanner' imported from /Users/sajjad/sunny/ios/Runner/GeneratedPluginRegistrant.m:94:
    In file included from <module-includes>:2:
    /Users/sajjad/sunny/build/ios/Debug-iphonesimulator/mobile_scanner/mobile_scanner.framework/Headers/mobile_scanner-Swift.h:495:31: warning: 'objc_ownership' only applies to Objective-C object or block pointer types; type here is 'CVPixelBufferRef _Nullable' (aka 'struct __CVBuffer *') [-Wignored-attributes]
    - (CVPixelBufferRef _Nullable __unsafe_unretained)copyPixelBuffer SWIFT_WARN_UNUSED_RESULT;
                                  ^
    1 warning generated.
    /Users/sajjad/sunny/ios/Runner/GeneratedPluginRegistrant.m:174:4: error: declaration of 'AdtraceSdk' must be imported from module 'adtrace_sdk_flutter.AdTraceSdk' before it is required
      [AdtraceSdk registerWithRegistrar:[registry registrarForPlugin:@"AdtraceSdk"]];
       ^
    In module 'adtrace_sdk_flutter' imported from /Users/sajjad/sunny/ios/Runner/GeneratedPluginRegistrant.m:10:
    /Users/sajjad/sunny/build/ios/Debug-iphonesimulator/adtrace_sdk_flutter/adtrace_sdk_flutter.framework/Headers/AdTraceSdk.h:3:12: note: declaration here is not visible
    @interface AdtraceSdk : NSObject<FlutterPlugin>
               ^
    2 warnings and 1 error generated.
    note: Using new build system
    note: Planning
    note: Build preparation complete
    note: Building targets in dependency order
    /Users/sajjad/sunny/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.2.99. (in target 'ReachabilitySwift' from project 'Pods')
    /Users/sajjad/sunny/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.2.99. (in target 'OrderedSet' from project 'Pods')
    /Users/sajjad/sunny/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.2.99. (in target 'FMDB' from project 'Pods')

    Result bundle written to path:
        /var/folders/bd/5c7b530j6sb62_rlkg6266180000gn/T/flutter_tools.tqWJmb/flutter_ios_build_temp_dir3gzr4u/temporary_xcresult_bundle

Modules Issue (Xcode): Declaration of 'AdtraceSdk' must be imported from module 'adtrace_sdk_flutter.AdTraceSdk' before it is required

Flutter doctor output:

Doctor summary (to see all details, run flutter doctor -v):
[βœ“] Flutter (Channel stable, 3.0.4, on macOS 11.4 20F71 darwin-arm, locale en-US)
[βœ“] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[βœ“] Xcode - develop for iOS and macOS (Xcode 13.2.1)
[βœ“] Chrome - develop for the web
[βœ“] Android Studio (version 2021.2)
[βœ“] Android Studio (version 2020.3)
[βœ“] VS Code (version 1.69.2)
[βœ“] Connected device (4 available)
[βœ“] HTTP Host Availability

β€’ No issues found!
namini40 commented 2 years ago

@sajjad-n hi there, sorry for a bit delay. thank you for your well described issue.

try removing Podfile.lock,.symlinks and Pods inside ios folder. make sure you are using the latest version of adtrace_sdk_flutter go to ios module using cd ios reinstall pods using pod install run the project again.

for more detailed response it will be great if you could say what is your project's environment sdk in pubspec.yaml file.

sajjad-n commented 2 years ago

@namini40 Thank you for your response. I followed your description and got this error:

Failed to build iOS app
Error output from Xcode build:
↳
    objc[13556]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libauthinstall.dylib (0x1f2feac10) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x10eb302c8). One of the two will be used. Which one is undefined.
    objc[13556]: Class AMSupportURLSession is implemented in both /usr/lib/libauthinstall.dylib (0x1f2feac60) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x10eb30318). One of the two will be used. Which one is undefined.
    ** BUILD FAILED **

Xcode's output:
↳
    Writing result bundle at path:
        /var/folders/bd/5c7b530j6sb62_rlkg6266180000gn/T/flutter_tools.srxjp3/flutter_ios_build_temp_dirHjxet2/temporary_xcresult_bundle

    While building module 'adtrace_sdk_flutter' imported from /Users/sajjad/sunny/ios/Runner/GeneratedPluginRegistrant.m:10:
    In file included from <module-includes>:1:
    In file included from /Users/sajjad/sunny/build/ios/Debug-iphonesimulator/adtrace_sdk_flutter/adtrace_sdk_flutter.framework/Headers/adtrace_sdk_flutter-umbrella.h:14:
    /Users/sajjad/sunny/build/ios/Debug-iphonesimulator/adtrace_sdk_flutter/adtrace_sdk_flutter.framework/Headers/AdTraceSdkDelegate.h:3:9: error: include of non-modular header inside framework module 'adtrace_sdk_flutter.AdTraceSdkDelegate': '/Users/sajjad/sunny/build/ios/Debug-iphonesimulator/Adtrace-sdk/Adtrace_sdk.framework/Headers/Adtrace.h' [-Werror,-Wnon-modular-include-in-framework-module]
    #import "Adtrace.h"
            ^
    1 error generated.
    /Users/sajjad/sunny/ios/Runner/GeneratedPluginRegistrant.m:10:9: fatal error: could not build module 'adtrace_sdk_flutter'
    #import <adtrace_sdk_flutter/AdtraceSdk.h>
     ~~~~~~~^
    While building module 'mobile_scanner' imported from /Users/sajjad/sunny/ios/Runner/GeneratedPluginRegistrant.m:94:
    In file included from <module-includes>:2:
    /Users/sajjad/sunny/build/ios/Debug-iphonesimulator/mobile_scanner/mobile_scanner.framework/Headers/mobile_scanner-Swift.h:495:31: warning: 'objc_ownership' only applies to Objective-C object or block pointer types; type here is 'CVPixelBufferRef _Nullable' (aka 'struct __CVBuffer *') [-Wignored-attributes]
    - (CVPixelBufferRef _Nullable __unsafe_unretained)copyPixelBuffer SWIFT_WARN_UNUSED_RESULT;
                                  ^
    1 warning generated.
    1 warning and 2 errors generated.
    note: Using new build system
    note: Planning
    note: Build preparation complete
    note: Building targets in dependency order
    /Users/sajjad/sunny/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.2.99. (in target 'ReachabilitySwift' from project 'Pods')
    /Users/sajjad/sunny/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.2.99. (in target 'OrderedSet' from project 'Pods')
    /Users/sajjad/sunny/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.2.99. (in target 'FMDB' from project 'Pods')

    Result bundle written to path:
        /var/folders/bd/5c7b530j6sb62_rlkg6266180000gn/T/flutter_tools.srxjp3/flutter_ios_build_temp_dirHjxet2/temporary_xcresult_bundle

Lexical or Preprocessor Issue (Xcode): Include of non-modular header inside framework module 'adtrace_sdk_flutter.AdTraceSdkDelegate': '/Users/sajjad/sunny/build/ios/Debug-iphonesimulator/Adtrace-sdk/Adtrace_sdk.framework/Headers/Adtrace.h'
/Users/flutter-sdk/.pub-cache/hosted/pub.dartlang.org/adtrace_sdk_flutter-1.2.0/ios/Classes/AdTraceSdkDelegate.h:2:8

Parse Issue (Xcode): Could not build module 'adtrace_sdk_flutter'

my environment sdk:

environment:
  sdk: ">=2.14.0 <3.0.0"
namini40 commented 2 years ago

thank you again. @sajjad-n

about the first error: AMSupportURLConnectionDelegate ... this link and this link probably help.

about the second error : Include of non-modular ... try opening ios module inside xcode and go to Build Settings under Target and set Allow Non-modular Includes in Framework Modules to YES

in case the problem still exists:

  1. try building an empty flutter project (make sure to set all the settings as your working project) and add adtrace_sdk_flutter to it ,build and run (you can use example project in current repo too)
  2. try removing adtrace_sdk_flutter from your project and run, add it again and see if the problem still remain.
  3. if everything you have done is still generating the same error, do a favor and send me your sample empty project you are getting the error from (on github or email me: namini40@gmail.com), to help us figure the problem ASAP. πŸ™πŸ™
sajjad-n commented 2 years ago

Before I issued the error I searched for the problem and faced these solutions but they didn't work! then I tried a new project and the problem still remained. The compiler points to:

#if __has_include(<adtrace_sdk_flutter/AdtraceSdk.h>)
#import <adtrace_sdk_flutter/AdtraceSdk.h>   <-- missing submodule 'adtrace_sdk_flutter.AdtraceSdk'
#else
@import adtrace_sdk_flutter;
#endif 
.
.
.
@implementation GeneratedPluginRegistrant

+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry {
[AdtraceSdk registerWithRegistrar:[registry registrarForPlugin:@"AdtraceSdk"]];  <-- Declaration of 'AdtraceSdk' must be imported from module 'adtrace_sdk_flutter.AdTraceSdk' before it is required

lines in GeneratedPluginRegistrant.m When set Allow Non-modular Includes in Framework Modules to YES, the first error I issued is returned. I also tried adjust_sdk package, and it worked fine.

namini40 commented 2 years ago

I tried to re-generate the issue using different set ups and settings but unfortunately no results. I event tried different iOS versions. It would be great if you could send a sample project that generates the error so that i can take a look at it. I will be trying to generate the error again and using locally added package in the meanwhile. if anything came up I'll catch up with you immediately.

sajjad-n commented 2 years ago

I have uploaded the test project and you can find it here, I hope it helps to fix the issue Thank you πŸ™

namini40 commented 2 years ago

@sajjad-n hello again. thank to you the problem was detected. we have a new patch on adtrace_sdk_flutter. I mentioned you in the Official PR 🀝 you can test the sdk too and if everything was ok close the issue on your will.

masood5400 commented 2 years ago

Thank you very much for your support. In a few days, I and @sajjad-n will check again.

sajjad-n commented 2 years ago

Good news! πŸ˜€ I've tested the new version and it worked! Thank you @namini40 for your support. πŸ™

MasoudRashidi commented 1 month ago

I add the last version of package and I delete Pods , .symlinks folders and podfile.lock and after do that I run pod install command in iOS module.

Then I get below error:

Launching lib/main.dart on iPhone 15 Pro Max in debug mode...
Running pod install...
Running Xcode build...
Xcode build done.                                           25.5s
Failed to build iOS app
Lexical or Preprocessor Issue (Xcode): Include of non-modular header inside framework module 'adtrace_sdk_flutter.AdTraceSdkDelegate': '/Users/masoudrashidizadeh/projects/flutter/jwaan/stylist-app/build/ios/Debug-iphonesimulator/Adtrace-sdk/Adtrace_sdk.framework/Headers/Adtrace.h'
/Users/masoudrashidizadeh/.pub-cache/hosted/pub.dev/adtrace_sdk_flutter-1.5.0/ios/Classes/AdTraceSdkDelegate.h:1:8

Parse Issue (Xcode): Could not build module 'adtrace_sdk_flutter'
/Users/masoudrashidizadeh/projects/flutter/jwaan/stylist-app/ios/Runner/GeneratedPluginRegistrant.m:9:8

Could not build the application for the simulator.
Error launching application on iPhone 15 Pro Max.

My Flutter sdk version is: 3.24.1 And version of package is: 1.5.0

namini40 commented 1 month ago

sorry if I ask again cause you didn't mention it @MasoudRashidi tried this Solution (the second part in solutions)?

namini40 commented 1 month ago

any questions or updates on this matter? will be glad to help

namini40 commented 1 month ago

closing the issue, feel free to open it if any questions came up