Problem archiving project to create XcFramework - ios

** I am running following command to create archive. **
`
xcodebuild archive \
-scheme ScannerV1 \
-configuration Release \
-destination 'generic/platform=iOS Simulator' \
-archivePath './build/ScannerV1.framework-iphonesimulator.xcarchive' \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
`
This is my pod file
`
target 'ScannerV1' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for ScannerV1
pod 'IQKeyboardManagerSwift'
pod 'ProgressHUD'
pod 'GoogleMLKit/FaceDetection'
pod 'GoogleMLKit/BarcodeScanning'
pod 'GoogleMLKit/TextRecognition','2.2.0'
pod 'Alamofire'
# pod 'SwiftKeychainWrapper'
end
post_install do |pi|
pi.pods_project.targets.each do |t|
t.build_configurations.each do |config|
config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
end
end
end
`
**This is the error I am getting . **
SwiftEmitModule normal x86_64 Emitting\ module\ for\ ScannerV1 (in target 'ScannerV1' from project 'ScannerV1') (1 failure)
Also as you can see I have commented SwiftKeychainWrapper pod . This is because I was getting error that SwiftKeychainWrapper is not found / No such module SwiftKeychainWrapper .
Now I got an error and that is : error: no such module 'Alamofire'
I mentioned above what I tried . I am expecting to create archive when creating xcframework

Related

Pods errors on xcode project

I am trying to update my xCode project with latest libraries, but I have errors building my project. Here are the details:
xcode 13.4.1
Cocoapods 1.11.3
Here is my Podfile:
# Uncomment the next line to define a global platform for your project
platform :ios, '13.0'
target 'la soundbox' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
pod 'FirebaseCore'
pod 'FirebaseFirestore'
pod 'FirebaseAuth'
pod 'FirebaseMessaging'
pod 'FirebaseInAppMessaging'
pod 'FirebaseAnalytics'
pod 'FirebaseCrashlytics'
pod 'FirebaseRemoteConfig'
pod 'Google-Mobile-Ads-SDK'
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
end
end
end
Before installing anything, here is what I do:
Clear Build folder
Exit xCode
Run those commands
rm -rf ~/Library/Caches/CocoaPods
rm -rf ~/Library/Developer/Xcode/DerivedData/*
rm -rf /path_to_project/Pods
rm /path_to_project/Podfile.lock
Restart mac
Launch xCode and build project
I have this error that keeps coming up (From FirebaseInAppMessaging pod, in FIRInAppMessaging.m):
'FirebaseCore/FIRAppInternal.h' file not found
Did not find header 'FIRAppInternal.h' in framework 'FirebaseCore'
What could be done to avoid this error ? I'm struggling on this and I really don't know what can I can do anymore

Pod lib lint fails for xcframework

I have xcode project with static lib and aggregate solution where I added Multi Platform Script at Build Phases so I can create xcframework:
SCHEME_NAME=${PROJECT_NAME}
FRAMEWORK_NAME=${PROJECT_NAME}
SIMULATOR_ARCHIVE_PATH="${BUILD_DIR}/${CONFIGURATION}/${FRAMEWORK_NAME}-iphonesimulator.xcarchive"
DEVICE_ARCHIVE_PATH="${BUILD_DIR}/${CONFIGURATION}/${FRAMEWORK_NAME}-iphoneos.xcarchive"
# Simulator xcarchieve
xcodebuild archive \
-scheme ${SCHEME_NAME} \
-archivePath ${SIMULATOR_ARCHIVE_PATH} \
-sdk iphonesimulator \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
# Device xcarchieve
xcodebuild archive \
-scheme ${SCHEME_NAME} \
-archivePath ${DEVICE_ARCHIVE_PATH} \
-sdk iphoneos \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
# Remove older version
rm -rf "${HOME}/Desktop/${FRAMEWORK_NAME}_${APPOXEE_SDK_VERSION}"
# Create Products && Documentation && SDK directories
mkdir -p "${HOME}/Desktop/${FRAMEWORK_NAME}_${APPOXEE_SDK_VERSION}/Documentation"
mkdir -p "${HOME}/Desktop/${FRAMEWORK_NAME}_${APPOXEE_SDK_VERSION}/SDK"
# Create xcframwork combine of all frameworks
xcodebuild -create-xcframework \
-library ${SIMULATOR_ARCHIVE_PATH}/Products/usr/local/lib/lib${FRAMEWORK_NAME}.a -headers ${SIMULATOR_ARCHIVE_PATH}/Products/usr/local/lib/${FRAMEWORK_NAME}Headers \
-library ${DEVICE_ARCHIVE_PATH}/Products/usr/local/lib/lib${FRAMEWORK_NAME}.a -headers ${DEVICE_ARCHIVE_PATH}/Products/usr/local/lib/${FRAMEWORK_NAME}Headers\
-output ${HOME}/Desktop/${FRAMEWORK_NAME}_${APPOXEE_SDK_VERSION}/SDK/${FRAMEWORK_NAME}.xcframework
which creates xcframework just fine. Inside that xcframework there is info.plist
which says that all architecture arm64, armv7 and i386, x86_64 are present at xcfremework, the same results I have when I do lipo -info
Podspec file looks like:
Pod::Spec.new do |s|
s.name = "TestSDK"
s.version = "6.0.4"
s.summary = "Test SDK enables developers to harnest the full power of Test Engage Platform on their iOS applications."
s.description = <<-DESC
Test SDK enables push notification in your iOS application, for engaging your application users and increasing retention.
DESC
s.homepage = "https://mapp.com"
s.license = { :type => "Custom", :file => "Licence.txt" }
s.author = { "Test Digital" => "https://test.com/contact-us/" }
s.source = { :git => "https://github.com/TestCloud/TestSDK.git", :tag => "6.0.4" }
s.ios.framework = 'UserNotifications'
s.platform = :ios, "10.0"
s.ios.vendored_frameworks = "SDK/TestSDK.xcframework"
s.preserve_paths = 'SDK/TestSDK.xcframework'
s.resource_bundle = { 'TestSDKResources' => 'SDK/TestSDKResources.bundle' }
s.requires_arc = true
end
and pod lib lint returns me an error:
Unable to find matching .xcframework slice in '../../../../../../../../Users/ssad.ter/Desktop/private_pod/TestSDK/SDK/TestSDK.xcframework RwarSDK library ios-arm64_armv7 ios-i386_x86_64-simulator' for the current build architectures (arm64 x86_64 i386).
but it contains those architecture as I explained.
the only way when pod lib lint went successfully is when I add to pod lib lint --configuration=Debug
But from the script you can see that Build for Distribution is set to YES and SKIP INSTALL to NO, same thing is done at build settings at XCode. And the Archive when you go to Edit scheme option at XCode is set to Release mode.
Can someone point me what may be the problem here?
Your plist shows you have only x86_64 and i386 architecture available for the simulator. Are you running the command on M1 mac? If yes you need to have arm64 arch support for the simulator as well or you can run pod lib lint under rosetta emulation like this:
arch -x86_64 pod lib lint

App crash on loading dependent libraries while making xcframework

I am making a xcframework. In my framework project, I have added cocoa pods like Alamofire, Realm, and more. When I integrate my xcframework in my application, the application crashes showing following error:
dyld: Symbol not found: _$s9Alamofire10HTTPMethodO3getyA2CmFWC
Referenced from: /private/var/containers/Bundle/Application/E81F9FBA-3876-4959-B675-B89A4EC0257A/BykesPod.app/Frameworks/MYFRAMEWORK.framework/MYFRAMEWORK
Expected in: /private/var/containers/Bundle/Application/E81F9FBA-3876-4959-B675-B89A4EC0257A/DEMOAPP.app/Frameworks/Alamofire.framework/Alamofire
in /private/var/containers/Bundle/Application/E81F9FBA-3876-4959-B675-B89A4EC0257A/DEMOAPP.app/Frameworks/MYFRAMEWORK.framework/MYFRAMEWORK
dyld: launch, loading dependent libraries
DYLD_LIBRARY_PATH=/usr/lib/system/introspection
DYLD_INSERT_LIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/usr/lib/libMainThreadChecker.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib
Following is the pod file of my framework project
target 'MYFRAMEWORK' do
project './MYFRAMEWORK.xcodeproj'
pod 'Realm'
pod 'RealmSwift'
pod 'Alamofire', '~> 4.8'
pod 'MBProgressHUD','1.1.0'
pod 'SwiftyJSON'
end
I have added following dependencies in my podspec file:
s.dependency "Realm"
s.dependency "RealmSwift"
s.dependency "Alamofire","~> 4.8.2"
s.dependency "MBProgressHUD","~> 1.1.0"
s.dependency "SwiftyJSON"
Following is the pod file of my demo application:
target 'DEMOAPP' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
pod 'PODNAME'
end
Following are the commands from which I am making xcframeworks
xcodebuild archive -workspace MYFRAMEWORK.xcworkspace -scheme MYFRAMEWORK -sdk iphoneos -archivePath "archives/0/ios_device.xcarchive" BUILD_LIBRARY_FOR_DISTRIBUTION=YES SKIP_INSTALL=NO
xcodebuild archive -workspace MYFRAMEWORK.xcworkspace -scheme MYFRAMEWORK -sdk iphonesimulator -archivePath "archives/0/ios_simulators.xcarchive" BUILD_LIBRARY_FOR_DISTRIBUTION=YES SKIP_INSTALL=NO
xcodebuild -create-xcframework -framework archives/0/ios_device.xcarchive/Products/Library/Frameworks/MYFRAMEWORK.framework -framework archives/0/ios_simulators.xcarchive/Products/Library/Frameworks/MYFRAMEWORK.framework -output build/MYFRAMEWORK.xcframework
Note: My code xcode version is 12.4
Solution to this problem is to enable following option in Target Build setting
Open Target build settings in Xcode
search for Build Libraries for distribution
change it to "Yes".
Note: If you are distributing Project/Library/Framework and it contains/depends on Cocoapods add following script into your destination Project where framework is integrated.
This script enables Build Libraries for distribution for all installing Cocoapod dependencies.
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
end
end
end
Currently, the solution I found was to make the "Build Libraries for distribution" flag true in the Pods project of my application. See attached screenshot.

React-Native IOS build giving error on pod install.?

Iam new to learning react-native and i want o generate an ios build but it keeps giving me this error whenever i try i run pod install. Iam unable to figure it out where iam wrong i have tried several options but it didnt work. If anyone can tell me where the problem is it would be a great help.
EOF
# Prepare exported header include
EXPORTED_INCLUDE_DIR="exported/glog"
mkdir -p exported/glog
cp -f src/glog/log_severity.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/logging.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/raw_logging.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/stl_logging.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/vlog_is_on.h "$EXPORTED_INCLUDE_DIR/"
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for arm-apple-darwin-strip... no
checking for strip... strip
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for arm-apple-darwin-gcc... /Library/Developer/CommandLineTools/usr/bin/cc -arch armv7 -isysroot
checking whether the C compiler works... no
xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: unable to lookup item 'Path' in SDK 'iphoneos'
/Users/shehzad/Library/Caches/CocoaPods/Pods/Release/Flipper-Glog/0.3.6-1dfd6/missing: Unknown `--is-lightweight' option
Try `/Users/shehzad/Library/Caches/CocoaPods/Pods/Release/Flipper-Glog/0.3.6-1dfd6/missing --help' for more information
configure: WARNING: 'missing' script is too old or missing
configure: error: in `/Users/shehzad/Library/Caches/CocoaPods/Pods/Release/Flipper-Glog/0.3.6-1dfd6':
configure: error: C compiler cannot create executables
See `config.log' for more details
[!] `xcodeproj` was renamed to `project`. Please update your Podfile accordingly.
[!] `<PBXResourcesBuildPhase UUID=`13B07F8E1A680F5B00A75B9A`>` attempted to initialize an object with an unknown UUID. `DC1D7AC84A2642079DCCD9FF` for attribute: `files`. This can be the result of a merge and the unknown UUID is being discarded.
my pod file
here is my ios project structure
comment out flipper command block if you are not using it.
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/#react-native-community/cli-platform-ios/native_modules'
platform :ios, '10.0'
target 'studypal' do
config = use_native_modules!
use_react_native!(:path => config["reactNativePath"])
target 'studypalTests' do
inherit! :complete
# Pods for testing
end
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable these next few lines.
# use_flipper!
# post_install do |installer|
# flipper_post_install(installer)
# end
end
target 'studypal-tvOS' do
# Pods for RnDiffApp-tvOS
target 'studypal-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
end
then try running pod install again
cd ios
pod install
this works for me everytime
Seems like you add xcodeproj property and that is causing the crash. Just rid that line.
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/#react-native-community/cli-platform-ios/native_modules'
platform :ios, '10.0'
target 'studypal' do
config = use_native_modules!
use_react_native!(:path => config["reactNativePath"])
target 'studypalTests' do
inherit! :complete
# Pods for testing
end
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable these next few lines.
use_flipper!
post_install do |installer|
flipper_post_install(installer)
end
end
target 'studypal-tvOS' do
# Pods for RnDiffApp-tvOS
target 'studypal-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
end

ld: framework not found AFNetworking

I get linking error when trying to compile iOS project from terminal with Xcode 7.1.1:
xcodebuild -project MyProject.xcodeproj -configuration Debug -target MyProject build
As result I receive next error:
ld: framework not found AFNetworking
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Here is my pod file:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
target "MyProject" do
pod "AFNetworking", "~> 2.0"
pod 'GoogleMaps'
pod 'MONActivityIndicatorView'
pod 'NYXImagesKit'
pod 'MagicalRecord'
pod 'FBSDKCoreKit'
pod 'FBSDKShareKit'
pod 'FBSDKLoginKit'
pod 'Countly'
end
xcodeproj 'MyProject'
I also tried adding link_with but get the same error. How to fix the problem above?
You need to build using the workspace generated by CocoaPods:
xcodebuild -workspace MyProject.xcworkspace -configuration Debug -scheme MyProject build
If you build just the project, xcodebuild does not see the dependency on the Pods project. Note that you have to use a scheme when building a workspace rather than a target. This means if you are building on a build server you will need to mark your scheme as shared in the scheme editor.

Resources