Frameworks

RSS for tag

Ask questions about APIs that can drive features in your apps.

Frameworks Documentation

Posts under Frameworks tag

201 Posts
Sort by:
Post not yet marked as solved
5 Replies
4.2k Views
Hi there, I'm working on an app that contains a mini system monitoring utility. I would like to list the top CPU-using processes. As Quinn “The Eskimo!” has repeatedly cautioned, relying on private frameworks is just begging for maintenance effort in the future. Ideally, I want to go through public headers/frameworks. I've gone to great lengths to try to find this information myself, and at this point I'm just struggling. I detail my research below. Any pointers in the right direction would be much appreciated! Attempts Libproc First I looked at libproc. Using proc_pidinfo with PROC_PIDTHREADINFO, I'm able to get each thread of an app, with its associated CPU usage percentage. Summing these, I could get the total for an app. Unfortunately, this has two downsides: Listing a table of processes now takes O(proces_count) rather than just O(process_count), and causes way more syscalls to be made It doesn't work for processes owned by other users. Perhaps running as root could alleviate that, but that would involve making a priviliedged helper akin to the existing sysmond that Activity Monitor.app uses. I'm a little scared of that, because I don't want to put my users at risk. Sysctl Using the keys [CTL_KERN, KERN_PROC, KERN_PROC_PID, someProcessID], I'm able to get a kinfo_proc - https://github.com/apple-opensource/xnu/blob/24525736ba5b8a67ce3a8a017ced469abe101ad5/bsd/sys/sysctl.h#L750-L776 instance. Accessing its .kp_proc - https://github.com/apple-opensource/xnu/blob/24525736ba5b8a67ce3a8a017ced469abe101ad5/bsd/sys/proc.h#L96-L150.p_pctcpu - https://github.com/apple-opensource/xnu/blob/24525736ba5b8a67ce3a8a017ced469abe101ad5/bsd/sys/proc.h#L123 looked really promising, but that value is always zero. Digging deeper, I found the kernel code that fills this struct in (fill_user64_externproc - https://github.com/apple-opensource/xnu/blob/c76cff20e09b8d61688d1c3dfb8cc855cccb93ad/bsd/kern/kern_sysctl.c#L1121-L1168). The assignment of p_pctcpu - https://github.com/apple-opensource/xnu/blob/c76cff20e09b8d61688d1c3dfb8cc855cccb93ad/bsd/kern/kern_sysctl.c#L1149 is in a conditional region, relying on the _PROC_HAS_SCHEDINFO_ flag. Disassembling the kernel on my mac, I could confirm that the assignment of that field never happens (thus _PROC_HAS_SCHEDINFO_ wasn't set during compilation, and the value will always stay zero) Reverse engineering Activity Monitor.app Activity Monitor.app makes proc_info and sysctl system calls, but from looking at the disassembly, it doesn't look like that's where its CPU figures come from. From what I can tell, it's using private functions from /usr/lib/libsysmon.dylib. That's a user library which wraps an XPC connection to sysmond (/usr/libexec/sysmond), allowing you to create requests (sysmon_request_create), add specific attributes you want to retrieve (sysmon_request_add_attribute), and then functions to query that data out (sysmon_row_get_value). Getting the data "striaght from the horses mouth" like this sounds ideal. But unfortunately, the only documentation/usage I can find of sysmond is from bug databases demonstrating a privilege escalation vulnerability lol. There are some partial reverse engineered header files floating around, but they're incomplete, and have the usual fragility/upkeep issues associated with using private APIs. On one hand, I don't want to depend on a private API, because that takes a lot of time to reverse engineer, keep up with changes, etc. On the other, making my own similar privileged helper would be duplicating effort, and expose a bigger attack surface. Needless to say, I have no confidence in being able to make a safer privileged helper than Apple's engineers lol Reverse engineering iStat Menus Looks like they're using proc_pid_rusage - https://github.com/apple-opensource/xnu/blob/24525736ba5b8a67ce3a8a017ced469abe101ad5/libsyscall/wrappers/libproc/libproc.h#L103-L108 . However, I don't know how to convert the cpu_*_time fields of the resulting struct rusage_info_v4 - https://github.com/apple-opensource/xnu/blob/24525736ba5b8a67ce3a8a017ced469abe101ad5/bsd/sys/resource.h#L306-L343 to compute a "simple" percentage. Even if I came up with some formula that produces plausible looking results, I have no real guarantee it's correct or equivalent to what Activity Monitor shows.
Posted
by
Post not yet marked as solved
3 Replies
2.2k Views
In my project I have a framework build target and a resource bundle build target. The framework target has the resource bundle target set in the Dependencies build phase. My goal is to create an xcframework that contains my framework and resource bundle. Typically, frameworks contain a Bundles or Resources folder containing resource bundles. When I use xcodebuild to archive my framework I use options: SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES The xcarchive is created just fine. When I look inside the xcarchive I see: My resource bundle under Products/Library/Bundles My framework under Products/Library/Frameworks (without the resource bundle inside) When I create the xcframework, each -framework argument on the "xcodebuild -create-xcframework" has to be a path into each xcarchive like "foo.xcarchive/Products/Library/Frameworks/foo.framework" The xcframework is created, but the resource bundle from Products/Library/Bundles doesn't get copied into the xcframework. Do I need to manually copy the contents of Products/Library/Bundles into each foo.framework/Resources inside the xcframework?
Posted
by
Post marked as solved
3 Replies
2k Views
This seems to be a pretty weird issue. I'm following along with a SpriteKit tutorial, and while I can build my project and run it on my phone, I keep getting this error in the IDE: Cannot load underlying module for SpriteKit It says it cannot load the module but that's weird because SpriteKit should be a native framework that must've been installed with my XCode. It is pretty annoying because XCode is not context-aware, and code completion doesn't work for any object that's derived from SpriteKit. Here's my system info: XCode version: Version 12.0 (12A7209) MacOS version: MacOS Catalina 10.15.7 (19H2) Is this a bug in XCode?
Posted
by
Post not yet marked as solved
10 Replies
2k Views
The application is getting hung on startup, I could manage to get the system spindump. I see two threads of the application in waiting state, please refer the following call stack extract from the spin dump, thread 0x1f44ee(main thread) 2  CFRunLoopObserverInvalidate + 277 (CoreFoundation + 528065) [0x7fff2041dec1]                    1  -[_NSArrayM dealloc] + 309 (CoreFoundation + 140978) [0x7fff203bf6b2]                     1  freetiny + 134 (libsystemmalloc.dylib + 24773) [0x7fff201510c5]                      1  ulockwait + 10 (libsystemkernel.dylib + 9678) [0x7fff202f35ce]                       *1  ??? (kernel + 6750000) [0xffffff800087ff30] (blocked by turnstile waiting for CUI [28858] [unique pid 128518] thread 0x1f456b)                    thread 0x1f456b  1  -[SBPropertyThunk initWithElement:inDocument:] + 314 (ScriptingBridge + 62301) [0x7fff5379d35d]               1  squish3 + 588 (ScriptingBridge + 68213) [0x7fff5379ea75]                1  +[NSString stringWithUTF8String:] + 68 (Foundation + 150974) [0x7fff2116bdbe]                 1  CFStringCreateWithBytes + 27 (CoreFoundation + 64294) [0x7fff203acb26]                  1  CFStringCreateImmutableFunnel3 + 2126 (CoreFoundation + 14583) [0x7fff203a08f7]                   1  CFRuntimeCreateInstance + 293 (CoreFoundation + 16753) [0x7fff203a1171]                    1  malloczonecalloc + 59 (libsystemmalloc.dylib + 114359) [0x7fff20166eb7]                     1  szonemallocshouldclear + 66 (libsystemmalloc.dylib + 10131) [0x7fff2014d793]                      1  tinymallocshouldclear + 142 (libsystemmalloc.dylib + 14363) [0x7fff2014e81b]                       1  _ulockwait + 10 (libsystem_kernel.dylib + 9678) [0x7fff202f35ce]                        *1  ??? (kernel + 6750000) [0xffffff800087ff30] (blocked by turnstile waiting for CUI [28858] [unique pid 128518] thread 0x1f44ee) I am not sure but suspecting that it might be causing that hang issue
Posted
by
Post not yet marked as solved
1 Replies
1.8k Views
We met many crashes like below on iOS 15, it seems multi-thread issue EXC_BAD_ACCESS. We get the dataServiceIdentifier on different threads. Does CTTelephonyNetworkInfo not thread-safe anymore from iOS 15? 0 libobjc.A.dylib _objc_retain 1 CoreTelephony -[CoreTelephonyClientMux cachedValueForSelector:] 2 CoreTelephony -[CoreTelephonyClient(Data) getCurrentDataServiceDescriptorSync:] 3 CoreTelephony -[CTTelephonyNetworkInfo dataServiceIdentifier]
Posted
by
Post not yet marked as solved
1 Replies
1.4k Views
(By "stable," I don't mean in a crashing or breaking sense; I mean it in the sense of a stable sorting algorithm, where duplicate elements will be kept in the same order in which they appeared in the unsorted collection.) I have a script that builds an XCFramework for iOS & tvOS, on simulator & device. It never changes the order in which the -framework arguments are passed to xcodebuild -create-xcframework. If I regenerate the XCFramework without any code or config changes, however, the order of entries in Info.plist always changes. Sample git diff: <string>x86_64</string> </array> <key>SupportedPlatform</key> - <string>tvos</string> + <string>ios</string> <key>SupportedPlatformVariant</key> <string>simulator</string> </dict> <dict> <key>LibraryIdentifier</key> - <string>ios-x86_64-simulator</string> + <string>ios-arm64</string> <key>LibraryPath</key> <string>Foo.framework</string> <key>SupportedArchitectures</key> <array> - <string>x86_64</string> + <string>arm64</string> </array> <key>SupportedPlatform</key> <string>ios</string> - <key>SupportedPlatformVariant</key> - <string>simulator</string> </dict> <dict> <key>LibraryIdentifier</key> - <string>ios-arm64</string> + <string>tvos-x86_64-simulator</string> <key>LibraryPath</key> <string>Foo.framework</string> <key>SupportedArchitectures</key> <array> - <string>arm64</string> + <string>x86_64</string> </array> <key>SupportedPlatform</key> - <string>ios</string> + <string>tvos</string> + <key>SupportedPlatformVariant</key> + <string>simulator</string> </dict> </array> <key>CFBundlePackageType</key> It doesn't affect the runtime in any way, as far as I know, but it's a minor irritation that I have to commit the changes to source control every time. Is there a way for xcodebuild -create-xcframework to either honor the order in which I passed the -framework arguments in, or at least keep the Info.plist file "stable" between script invocations? (This behavior is the same on Xcode 12.x & the XCode 13 beta versions.)
Posted
by
Post not yet marked as solved
9 Replies
17k Views
When archiving & exporting App with Xcode 13. The Frameworks of the created app will have their Info.plist modified. CFBundleShortVersionString is being changed to have the same value as the application version. Steps to reproduce: Create iOS App project with v1.0.0 Add dynamic framework dependencies. ex: Framework A v3.0.0, Framework B v12.0.0. Archive Project. Distribute app AppStore Connect Export Finish the rest of the process with default values. Investigate generated IPA file Investigate .app file inside IPA Investigate frameworks inside .app file. CFBundleShortVersionString of all the frameworks is 1.0.0
Posted
by
Post not yet marked as solved
2 Replies
2k Views
Hello there, i would like to ask a question related xcode build confinguration. So i have create a Common.framework that i used in other project, because of the .framework file is quite large then i want to generate Common.framework but with Generate Debug Symbols is NO, and the result Common.framework size is reduced The question is there any negative impact that will happen to my app that use Common.framework?
Posted
by
Post not yet marked as solved
8 Replies
8.9k Views
I have been working with a framework to add multiplayer support to my app. The app runs on test devices, simulators, and archives perfectly fine and the app is fine without the framework. But when I go to distribute the app, I see get this error related to the multiplayer framework I have added. I have tried updating the minimumOSVersion to 9.0, 10.0, 12.0, and 13.0 everywhere (info.plist, deployment info, build settings, etc) and they all match with each build/archive but no matter what I can't get fix this error. This error only shows up when I go to distribute the app to the store. Any ideas on what to try or how to fix this issue? I've attached a screenshot of the issue below.
Posted
by
Post not yet marked as solved
1 Replies
943 Views
I have 2 frameworks, which are both Swift Statically-linked frameworks. This means that my Mach-O Type is Static Library for both of the targets. One of the targets (A) depends on another target (B). I successfully archive A, and then I successfully archive B, linking against A. Embedding is enabled, however I don't seem to find any mentions of A in the exported build artifacts. However, when I import archived and exported B in another target, it gives me a compilation error: ld: warning: Could not find or use auto-linked framework 'A' Undefined symbols for architecture x86_64: "A.someMethodInsideA() -> Swift.Int", referenced from: B.someMethodInsideB() -> Swift.Int in B(B.o) ld: symbol(s) not found for architecture x86_64 You see, I set the A's Mach-O Type to Static Library, so I expect A's binaries to be completely embedded into B with static linkage, but this doesn't happen for some reason. How can I embed a static framework inside a static framework?
Posted
by
Post not yet marked as solved
3 Replies
2.6k Views
Hello, maybe anyone know anything about HCE (Host card emulation) feature on iOS? As far as I read, it's not possible to achieve this functionality on iOS, but maybe there are plans to implement that? Or maybe it's clear that it wont be allowed to be used at all? Thanks:)
Posted
by
Post not yet marked as solved
1 Replies
2.5k Views
We are implementing third party XCFrameworks for our clients. We are planning to use @_implementationOnly import in our SDK due to our framework pluggability requirement. We are skeptical about using this in our SDK due to the following warning. https://github.com/apple/swift/blob/main/docs/ReferenceGuides/UnderscoredAttributes.md Could you please confirm that if we use this @_implementationOnly import in our framework, do we get any problems when our Clients are submitting their apps to AppStore ? Underscored Attributes Reference : WARNING: This information is provided primarily for compiler and standard library developers. Usage of these attributes outside of the Swift monorepo is STRONGLY DISCOURAGED.
Posted
by
Post marked as solved
56 Replies
82k Views
Hello, I've upgraded from xcode 14.2 to xcode 14.3 beta, and now I can't archive anymore for Any iOS Device (arm64) with the following error : PhaseScriptExecution [CP]\ Embed\ Pods\ Frameworks mkdir -p /Users/max/Library/Developer/Xcode/DerivedData/Max-dmwafkgdrzqavzcmbdjbjgmmuxby/Build/Intermediates.noindex/ArchiveIntermediates/Release_preprod/BuildProductsPath/Release_preprod-iphoneos/MaxApp.app/Frameworks Symlinked... rsync --delete -av --filter P .*.?????? --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "../../../IntermediateBuildFilesPath/UninstalledProducts/iphoneos/ActionSheetPicker_3_0.framework" "/Users/max/Library/Developer/Xcode/DerivedData/Max-dmwafkgdrzqavzcmbdjbjgmmuxby/Build/Intermediates.noindex/ArchiveIntermediates/Release_preprod/InstallationBuildProductsLocation/Applications/MaxApp.app/Frameworks" building file list ... rsync: link_stat "/Users/max/Workspace/MaxApp/../../../IntermediateBuildFilesPath/UninstalledProducts/iphoneos/ActionSheetPicker_3_0.framework" failed: No such file or directory (2) done sent 29 bytes received 20 bytes 98.00 bytes/sec total size is 0 speedup is 0.00 rsync error: some files could not be transferred (code 23) at /AppleInternal/Library/BuildRoots/9e200cfa-7d96-11ed-886f-a23c4f261b56/Library/Caches/com.apple.xbs/Sources/rsync/rsync/main.c(996) [sender=2.6.9] Command PhaseScriptExecution failed with a nonzero exit code Any idea why it works fine with xCode 14.2 and not with xCode 14.3 beta please ? I tryed to delete the [CP] Embed Pods Frameworks script, but it has re-created it and get the same issue. I tryed to build and debug in a simulator, and it works fine. I tryed to delete "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64; in the .pbxproj file
Posted
by
Post not yet marked as solved
1 Replies
917 Views
Hello everyone, I want to add FBX capabilities to my app so I downloaded and installed the FBX SDK for iOS from the Autodesk website. But when it came to setting up the sdk for my Xcode project, the only article I could find was from 2014 and the guide is outdated and doesn't work anymore. I do not know a lot about c or working with frameworks/APIs, so I need some help getting this set up... Thanks for any help in advance!
Posted
by
Post not yet marked as solved
2 Replies
894 Views
IOPSCopyPowerSourcesInfo → kIOPSBatteryHealthKey returning incorrect value Background: I write software to monitor computer system health. I'm having problems getting battery health information on my new M2 notebook. Given the following Objective-C program: #include <Foundation/NSObjCRuntime.h> #include <IOKit/ps/IOPSKeys.h> #include <IOKit/ps/IOPowerSources.h> #include <assert.h> int main() { CFTypeRef psInfo = IOPSCopyPowerSourcesInfo(); assert(psInfo != NULL); CFArrayRef list = IOPSCopyPowerSourcesList(psInfo); assert(list != NULL); long count = CFArrayGetCount(list); for(long i = 0; i < count; i++) { CFDictionaryRef ps = IOPSGetPowerSourceDescription( psInfo, CFArrayGetValueAtIndex(list, i)); assert(ps != NULL); CFStringRef deviceName = (CFStringRef)CFDictionaryGetValue( ps, CFSTR(kIOPSNameKey)); assert(deviceName != NULL); CFStringRef serialNumber = (CFStringRef)CFDictionaryGetValue( ps, CFSTR(kIOPSHardwareSerialNumberKey)); assert(serialNumber != NULL); CFStringRef health = (CFStringRef)CFDictionaryGetValue( ps, CFSTR(kIOPSBatteryHealthKey)); assert(health != NULL); NSLog(@"\nName=\"%@\"\nSerialNumber=\"%@\"\n" "BatteryHealth=\"%@\"\n", (__bridge NSString*)deviceName, (__bridge NSString*)serialNumber, (__bridge NSString*)health); } CFRelease(list); CFRelease(psInfo); return 0; } and looking at the IOPSKeys.h header, I expect to get one of "Poor", "Fair", or "Good" for the value of kIOPSBatteryHealthKey. https://opensource.apple.com/source/IOKitUser/IOKitUser-1845.81.1/ps.subproj/IOPSKeys.h.auto.html Instead, on my 2022 M2 Macbook Air running 13.2.1 (22D68), I get the following output: Name="InternalBattery-0" SerialNumber="F8Y2422145S10X2A7" BatteryHealth="Check Battery" At the same time, the "System Information app says "Condition: Normal". Am I missing something? This seems to be a bug, right? Should I look into filing a Technical Support Incident?
Posted
by
Post not yet marked as solved
2 Replies
684 Views
Hello, According to the recent news about the apps submitted after April 25th must be built with XCode 14,1 or later - it's not clear if the app's dependencies in form of xcframeworks should also be build with XCode 14.1, or this applies only for the host app. Thanks
Posted
by
Post not yet marked as solved
1 Replies
528 Views
I'm using the BackgroundAssets framework to download data for my app. Since updating to the iOS 16.4 SDK, Apple is rejecting my app from being uploaded to testflight with the following error: Missing Info.plist value. The extension at <app extension> requires the BAInitialDownloadRestrictions.BAEssentialDownloadAllowance key to be present in the app's Info.plist. Unfortunately, the BAEssentialDownloadAllowance key doesn't exist in the documentation for BackgroundAssets seen here: https://developer.apple.com/documentation/bundleresources/information_property_list/bainitialdownloadrestrictions Does anyone know what this key is for? I can't find any info online
Posted
by
Post not yet marked as solved
6 Replies
824 Views
To download files, we have two NSURLSession objects. One configured for foreground downloads and one for background downloads. Initially, we download user-requested files in the foreground using downloadTaskWithRequest, because foreground downloads are faster than background downloads. We then also start a background task for each download using beginBackgroundTaskWithName:expirationHandler:. This background task's expiration handler starts a background download if the download didn't complete in the foreground. It cancels the foreground download with resume data using cancelByProducingResumeData. A background download task is then started using downloadTaskWithResumeData. Now, testing has shown that background download tasks resume correctly (the urlSession(_:downloadTask:didResumeAtOffset:expectedTotalBytes:) callback is called by iOS) if the background task is started immediately. However, iOS can decide to start these background download tasks later. As a sidenote, the isDiscretionary property of our background download session is set to the default, which should be false. The issue we have is that background downloads that are resumed several minutes (6,5 minutes in the session I'm currently looking at) after their original foreground download was cancelled, are not resumed properly. They download the remaining part of the file, but the first part that was downloaded in the foreground is lost. What could have happened? Perhaps the temporary file has been deleted in the meantime? Is there some way to maintain this file or detect this case?
Posted
by