Post

Replies

Boosts

Views

Activity

Can't get SecKeyCreateWithData to work with private key from my App Store Connect account.
I've tried all kinds of ways to get a SecKeyRef from the .p8 file I downloaded from my App Store Connect account. The key itself looks OK, as openssl gives this result: openssl asn1parse -in 359UpAdminKey.p8 0:d=0 hl=3 l= 147 cons: SEQUENCE 3:d=1 hl=2 l= 1 prim: INTEGER :00 6:d=1 hl=2 l= 19 cons: SEQUENCE 8:d=2 hl=2 l= 7 prim: OBJECT :id-ecPublicKey 17:d=2 hl=2 l= 8 prim: OBJECT :prime256v1 27:d=1 hl=2 l= 121 prim: OCTET STRING [HEX DUMP]:30... My method for creating the key is: '- (SecKeyRef)privateKeyFromP8:(NSURL *)p8FileURL error:(NSError **)error { // Read the .p8 file NSData *p8Data = [NSData dataWithContentsOfURL:p8FileURL options:0 error:error]; if (!p8Data) { return NULL; } // Convert P8 to base64 string, removing header/footer NSString *p8String = [[NSString alloc] initWithData:p8Data encoding:NSUTF8StringEncoding]; NSArray *lines = [p8String componentsSeparatedByString:@"\n"]; NSMutableString *base64String = [NSMutableString string]; for (NSString *line in lines) { if (![line containsString:@"PRIVATE KEY"]) { [base64String appendString:line]; } } // Decode base64 to raw key data NSData *keyData = [[NSData alloc] initWithBase64EncodedString:base64String options:0]; if (!keyData) { if (error) { *error = [NSError errorWithDomain:@"P8ImportError" code:1 userInfo:@{NSLocalizedDescriptionKey: @"Failed to decode base64 data"}]; } return NULL; } // Set up key parameters NSDictionary *attributes = @{ (__bridge NSString *)kSecAttrKeyType: (__bridge NSString *)kSecAttrKeyTypeECSECPrimeRandom, (__bridge NSString *)kSecAttrKeyClass: (__bridge NSString *)kSecAttrKeyClassPrivate, (__bridge NSString *)kSecAttrKeySizeInBits: @256 }; // Create SecKeyRef from the raw key data CFErrorRef keyError = NULL; SecKeyRef privateKey = SecKeyCreateWithData((__bridge CFDataRef)p8Data, (__bridge CFDictionaryRef)attributes, &keyError); if (!privateKey && keyError) { *error = (__bridge_transfer NSError *)keyError; NSError *bridgeError = (__bridge NSError *)keyError; if (error) { *error = bridgeError; // Pass the bridged error back to the caller } NSLog(@"Key Error: %@", bridgeError.localizedDescription); } return privateKey; } ` I get this error from SecKeyCreateWithData The operation couldn’t be completed. (OSStatus error -50 - EC private key creation from data failed) Filed a DTS incident, but they won't be back until after the New Year. I've tried all kinds of things. Various AI chatbots, etc. Nothing seems to be working. I'm sure the problem is something elementary, but have spent hours on this with no luck. Help, please.
1
0
429
Dec ’24
XCTestPlan configuration environment variables not passed in to XCUIApplication
I have an XCTestPlan with configurations for each country I support on the App Store, so I can generate screenshots without a crazy amount of work. Until Xcode 15, this worked fine. Now, it appears that while environment variables associated with the XCTestPlan itself are passed in to Xcode, those associated with each configuration are not. I did prefix the environment variables with "TEST_RUNNER_" as recommended elsewhere with no luck. Any suggestions?
1
0
238
Dec ’24
UITableViewDropItem missing in Xcode 16?
Following instructions from ChatGPT, I'm trying to rearrange the order of rows in a UITableView. - (void)tableView:(UITableView *)tableView performDropWithCoordinator:(id<UITableViewDropCoordinator>)coordinator { NSIndexPath *destinationIndexPath = coordinator.destinationIndexPath ?: [NSIndexPath indexPathForRow:self.items.count inSection:0]; [tableView performBatchUpdates:^{ for (UITableViewDropItem *dropItem in coordinator.items) { NSString *movedItem = dropItem.dragItem.localObject; if (movedItem) { NSIndexPath *sourceIndexPath = dropItem.sourceIndexPath; if (sourceIndexPath) { [self.items removeObjectAtIndex:sourceIndexPath.row]; [self.items insertObject:movedItem atIndex:destinationIndexPath.row]; [tableView moveRowAtIndexPath:sourceIndexPath toIndexPath:destinationIndexPath]; } } } } completion:nil]; } Xcode is complaining that UITableViewDropItem does not exist. The class is in all the documentation, it is just not showing up when needed! Suggestions?
1
0
285
Nov ’24
AVAsset tracks method does not return all tracks from GoPro mp4 file.
I'm trying to read all the tracks from a GoPro Hero9 camera mp4 file. The AVAsset tracks method says there are only 3 tracks, while ffmpeg says there are 5. I'm particularly interested in the "gpmd" track, which contains GPS data, which AVAsset seemingly does not recognize. Any suggestions? Mac and ffmpeg output below. macOS code XLog(@"AVAsset creation date = %@", asset.creationDate.value); XLog(@"AVAsset tracks.count = %ld", asset.tracks.count); NSArray *trackA = asset.tracks; index = 0; for (AVAssetTrack *track in trackA) { XLog(@"%ld. trackID = %d", index, track.trackID); XLog(@"%ld. mediaType = %@", index, track.mediaType); XLog(@"%ld. data size = %@", index, NSStringFromSize(track.naturalSize)); XLog(@"___________________________"); index++; } } produces 🔷AVAsset creation date = 2022-11-13 13:33:57 +0000 🔷AVAsset tracks.count = 3 🔷0. trackID = 1 🔷0. mediaType = vide 🔷0. data size = {3840, 2160} 🔷___________________________ 🔷1. trackID = 2 🔷1. mediaType = soun 🔷1. data size = {0, 0} 🔷___________________________ 🔷2. trackID = 3 🔷2. mediaType = tmcd 🔷2. data size = {0, 0} ffmpeg -i GX010045.MP4 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'GX010045.MP4': Metadata: major_brand : mp41 minor_version : 538120216 compatible_brands: mp41 creation_time : 2022-11-13T13:33:57.000000Z location : +38.0357-122.5819/ location-eng : +38.0357-122.5819/ firmware : HD9.01.01.72.00 Duration: 00:08:52.54, start: 0.000000, bitrate: 60206 kb/s Stream #0:0[0x1](eng): Video: hevc (Main) (hvc1 / 0x31637668), yuvj420p(pc, bt709), 3840x2160 [SAR 1:1 DAR 16:9], 59941 kb/s, 59.94 fps, 59.94 tbr, 60k tbn (default) Metadata: creation_time : 2022-11-13T13:33:57.000000Z handler_name : GoPro H.265 vendor_id : [0][0][0][0] encoder : GoPro H.265 encoder timecode : 13:33:09:07 Stream #0:1[0x2](eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 189 kb/s (default) Metadata: creation_time : 2022-11-13T13:33:57.000000Z handler_name : GoPro AAC vendor_id : [0][0][0][0] timecode : 13:33:09:07 Stream #0:2[0x3](eng): Data: none (tmcd / 0x64636D74) (default) Metadata: creation_time : 2022-11-13T13:33:57.000000Z handler_name : GoPro TCD timecode : 13:33:09:07 Stream #0:3[0x4](eng): Data: bin_data (gpmd / 0x646D7067), 48 kb/s (default) Metadata: creation_time : 2022-11-13T13:33:57.000000Z handler_name : GoPro MET Stream #0:4[0x5](eng): Data: none (fdsc / 0x63736466), 13 kb/s (default) Metadata: creation_time : 2022-11-13T13:33:57.000000Z handler_name : GoPro SOS At least one output file must be specified
1
0
770
Mar ’23
xcodebuild does not produce module map for MacOS, does for iOS
I'm converting my iOS framework to build for MacOS as well as iOS. Same project, different targets. I use a build script to build each frameworks, which are identical except for the target names. I've checked all the build settings to see that they are identical re:modules, and double-checked the search paths for frameworks and headers. What could I be doing wrong? (The framework successfully builds for MacOS. My app can't load it, however, I get the dreaded "Module 'LUXforMac' not found" message...
2
0
3.3k
Mar ’23