Build, test, and submit your app using Xcode, Apple's integrated development environment.

Posts under Xcode tag

200 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Re: "Unknown Apple ID" entries in Xcode Accounts settings
Hello! This post is a response to another post from Oct 17 that has already been locked for some reason: https://forums.developer.apple.com/forums/thread/766500 After upgrading to Xcode 16.0, our build machine was no longer able to archive and upload builds to App Store Connect automatically, as every single time it would say: `IDEDistribution: Failed to log in with account "(null)" while checking for an App Store Connect account` I tried using the workaround in the post above as suggested, but it does not help the problem. Removing and signing out of the account just results in Xcode not being able to do automatic signing because it no longer has access to the account with privileges to do that automatic signing. error: exportArchive No Accounts error: exportArchive No signing certificate "iOS Distribution" found I also tried Xcode 16.1 beta 3 as suggested and now the build machine's account is actually removed after every build via our build system! I have to log on after every build, log back in, and then upload the build to App Store Connect manually. I'm guessing that this "workaround" was added to Xcode itself, which is not serving its intended purpose and has actually made things worse. Not sure if there is a more official venue to send a bug report, but I'm posting here for help since that's where I originally found the post and it appeared to be written by an Apple engineer. Any other possible workarounds? Should I try one of the newer beta releases? Any help would be appreciated as this is becoming very cumbersome and a routine update of Xcode on our build machine has caused a ton of headaches.
4
0
289
Oct ’24
Xcode Arguments Passed On Launch won't load
I am building and running a simple Open MPI C application. In order to run it, I configured the run process in this way:\ Edit Scheme -> Run -> Info -> Executable -> Other... -> /path/to/mpiexec Edit Scheme -> Run -> Arguments -> Arguments Passed On Launch -> -np 4 "$(BUILT_PRODUCTS_DIR)/$(EXECUTABLE_NAME)" Now, instead of the hardcoded "4" as the number of processes, I want to specify an environment variable (like the already existing BUILT_PRODUCTS_DIR and EXECUTABLE_NAME environment variables), so I enter in Environment Variables NUM_PROCS as Name and 4 as Value. Thus, I write in Arguments Passed On Launch the whole quoted string: "-np" "$(NUM_PROCS)" "$(BUILT_PRODUCTS_DIR)/$(EXECUTABLE_NAME)". And Xcode can't read the NUM_PROCS environment variable (despite I can easily read it in the C program by a getenv("NUM_PROCS")!), in fact, it runs the default number of processes of my system (12). I tried in a very large number the different ways of writing arguments (every string on a new line, with quotes, without quotes, ...), but none worked as I expected. M3 Pro, macOS Sequoia 15.0.1 Xcode 16.0
2
0
198
Oct ’24
App Crashes on iOS 12
Hello! My app is crashing on iOS 12. On other versions (i.e. 15, 17), we could not reproduce it. The problem occurs every once in a while. It simply crashes after a few seconds using the App. I got a crash report and will include in the post. Looks like Language exception crash , but i could not narrow it down to the cause of the problem. The crash happens under the "suggestd" name. Appreciate if someone can help. suggestd-2024-10-24-134830.txt
5
0
251
3w
Breakpoint issue: 'self cannot be reconstructed'
Hello! We're working on a large app with over 400 modules in both Swift and Objective-C, totaling more than 3 million lines of code. Since the release of Xcode 15 and 16 this summer, we’ve been experiencing issues with LLDB that have made debugging practically impossible. Here are some of the problems we’re facing: The first breakpoint takes a very long time to hit. When using 'po self', we encounter the following error: error: type for self cannot be reconstructed: type for typename "$s5MyModule10PlayerViewCD" was not found (cached) error: Couldn't realize Swift AST type of self. Hint: using `v` to directly inspect variables and fields may still work. We get numerous log messages like this: Debugging will be degraded due to missing types. Rebuilding the project will regenerate the needed module files.warning: (arm64) /Users/egormerkushev/Library/Developer/Xcode/DerivedData/App-enhtbwiyebmjsffoqkqhhpshsfia/Build/Products/Debug-iphoneos/MyModule.framework/MyModule(UploadConfiguration.o) 0x000000000000079d: unable to locate module needed for external types: /Users/builder/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/169D1N0MIKBUI/Security-3BRN4UPIIGHME.pcm error: '/Users/builder/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/169D1N0MIKBUI/Security-3BRN4UPIIGHME.pcm' does not exist In the Derived Data folder, we find files with hash-like names, such as: Security-3JM2E93YFDLZNYHWPPIMWNENB.d Security-3JM2E93YFDLZNYHWPPIMWNENB.dia Security-3JM2E93YFDLZNYHWPPIMWNENB.pcm Security-3JM2E93YFDLZNYHWPPIMWNENB.scan Security-3NAAT3MGN7XY96KVJW529HR41.d Security-3NAAT3MGN7XY96KVJW529HR41.dia Security-3NAAT3MGN7XY96KVJW529HR41.pcm Security-3NAAT3MGN7XY96KVJW529HR41.scan Security-3RJH8STJC01N1KKN7JCY1WK7F.d Security-3RJH8STJC01N1KKN7JCY1WK7F.dia Security-3RJH8STJC01N1KKN7JCY1WK7F.pcm Security-3RJH8STJC01N1KKN7JCY1WK7F.scan Security-3TILE9XTY0B8UV9VYL7Y0MJN.d Security-3TILE9XTY0B8UV9VYL7Y0MJN.dia Security-3TILE9XTY0B8UV9VYL7Y0MJN.pcm Security-3TILE9XTY0B8UV9VYL7Y0MJN.scan Security-3ZE8O6ZPHE4L52UZGL0PCBA59.d Security-3ZE8O6ZPHE4L52UZGL0PCBA59.dia ... When enabling LLDB logs with: log enable -f /tmp/lldb.log lldb all we end up with a 1.5GB log file containing hundreds of thousands of error messages. Finally, the LLDB console output in Xcode ends with errors like: error: Assertion failed: (byte_size > 0 && byte_size <= 8 && "GetMaxU64 invalid byte_size!"), function GetMaxU64, file DataExtractor.cpp, line 527 Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): 0 LLDB 0x0000000116ccfe1c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56 1 LLDB 0x000000011682fdcc lldb_private::lldb_assert(bool, char const*, char const*, char const*, unsigned int) + 148 2 LLDB 0x000000011682944c lldb_private::DataExtractor::GetMaxU64(unsigned long long*, unsigned long) const + 72 3 LLDB 0x00000001167335a8 lldb_private::CompilerType::GetValueAsScalar(lldb_private::DataExtractor const&, unsigned long long, unsigned long, lldb_private::Scalar&, lldb_private::ExecutionContextScope*) const + 304 4 LLDB 0x000000011666f0f4 lldb_private::Value::ResolveValue(lldb_private::ExecutionContext*, lldb_private::Module*) + 388 5 LLDB 0x0000000116671e94 lldb_private::ValueObject::ResolveValue(lldb_private::Scalar&) + 104 6 LLDB 0x0000000116674d6c lldb_private::ValueObject::GetValueAsSigned(long long, bool*) + 140 7 LLDB 0x000000011650510c lldb::SBValue::GetValueAsSigned(long long) + 160 8 lldb-rpc-server 0x00000001025ebe70 rpc_server::_ZN4lldb7SBValue16GetValueAsSignedEx::HandleRPCCall(rpc_common::Connection&, rpc_common::RPCStream&, rpc_common::RPCStream&) + 92 ... 13 libsystem_pthread.dylib 0x00000001917fb2e4 _pthread_start + 136 14 libsystem_pthread.dylib 0x00000001917f60fc thread_start + 8 Please file a bug report against lldb reporting this failure log, and as many details as possibleerror: Assertion failed: (byte_size > 0 && byte_size <= 8 && "GetMaxU64 invalid byte_size!"), function GetMaxU64, file DataExtractor.cpp, line 527 Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): 0 LLDB 0x0000000116ccfe1c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56 1 LLDB 0x000000011682fdcc lldb_private::lldb_assert(bool, char const*, char const*, char const*, unsigned int) + 148 2 LLDB 0x000000011682944c lldb_private::DataExtractor::GetMaxU64(unsigned long long*, unsigned long) const + 72 3 LLDB 0x00000001167335a8 lldb_private::CompilerType::GetValueAsScalar(lldb_private::DataExtractor const&, unsigned long long, unsigned long, lldb_private::Scalar&, lldb_private::ExecutionContextScope*) const + 304 4 LLDB 0x000000011666f0f4 lldb_private::Value::ResolveValue(lldb_private::ExecutionContext*, lldb_private::Module*) + 388 5 LLDB 0x0000000116671e94 lldb_private::ValueObject::ResolveValue(lldb_private::Scalar&) + 104 6 LLDB 0x0000000116674c44 lldb_private::ValueObject::GetValueAsUnsigned(unsigned long long, bool*) + 140 7 LLDB 0x0000000116505224 lldb::SBValue::GetValueAsUnsigned(unsigned long long) + 160 8 lldb-rpc-server 0x00000001025ebf18 rpc_server::_ZN4lldb7SBValue18GetValueAsUnsignedEy::HandleRPCCall(rpc_common::Connection&, rpc_common::RPCStream&, rpc_common::RPCStream&) + 92 9 lldb-rpc-server 0x00000001025f62b8 rpc_common::Connection::PrivateHandleRPCPacket(rpc_common::RPCPacket&, rpc_common::RPCPacket&, bool&) + 628 10 lldb-rpc-server 0x00000001025f9e8c Packets::ProcessPackets() + 564 11 lldb-rpc-server 0x00000001025f9bf4 Packets::ReadThread() + 276 12 lldb-rpc-server 0x00000001025f9ad4 Packets::RunReadThread(void*) + 12 13 libsystem_pthread.dylib 0x00000001917fb2e4 _pthread_start + 136 14 libsystem_pthread.dylib 0x00000001917f60fc thread_start + 8 Please file a bug report against lldb reporting this failure log, and as many details as possiblePrinting description of self: error: type for self cannot be reconstructed: type for typename "$s5MyModule10PlayerViewCD" was not found (cached) error: Couldn't realize Swift AST type of self. Hint: using `v` to directly inspect variables and fields may still work. In short, our debugger is completely unusable at this point, which is severely impacting our team's ability to develop effectively. Do you have any suggestions on how we can resolve these issues? We would really appreciate your help. Thank you!
8
24
972
2w
dyld[53510]: Symbol not found - React Native app issue with running on real device
I develop React Native app with dynamically linked pods, and app runs on simulator well, while running it on connected device returns this error: dyld[53510]: Symbol not found: __ZN5swift39swift51override_conformsToSwiftProtocolEPKNS_14TargetMetadataINS_9InProcessEEEPKNS_24TargetProtocolDescriptorIS1_EEN7__swift9__runtime4llvm9StringRefEPFPKNS_35TargetProtocolConformanceDescriptorIS1_EES4_S8_SC_E Referenced from: <4A3492BF-0479-3124-BE58-05BAED71BB20> /private/var/containers/Bundle/Application/0D9FDF5C-BBC9-4060-972B-B2D6FD91E321/BFF.app/Frameworks/Framework1 Expected in: <0549B906-CB15-3735-AA15-FAEB5F687C8B> /private/var/containers/Bundle/Application/0D9FDF5C-BBC9-4060-972B-B2D6FD91E321/BFF.app/Frameworks/Framework2 I already tried different things: Different versions of IPHONEOS_DEPLOYMENT_TARGET Ensured that all dependencies using same Swift version Different linking Tested on different devices and iOS versions Standard cleaning of derived data and reinstalling podfiles also included BUILD_LIBRARY_FOR_DISTRIBUTION="YES" ENABLE_BITCODE="NO"
0
0
141
Oct ’24
xcrun xcresulttool Failed to create a new result bundle reader
I need to read results of a test in Xcode post-action of Test. So the script that runs after tests contains SUMMARY=$(xcrun xcresulttool get test-results summary --path $RESULT_FILE 2>> "$LOGS") If I run my script from terminal, everything is ok but if I launch tests and the post-action is executed, I got Warning: unknown environment variable SWIFT_DEBUG_INFORMATION_FORMAT Warning: unknown environment variable SWIFT_DEBUG_INFORMATION_VERSION Warning: unknown environment variable SWIFT_DEBUG_INFORMATION_FORMAT Warning: unknown environment variable SWIFT_DEBUG_INFORMATION_VERSION Error: Failed to create a new result bundle reader, underlying error: failed to read metadata with underlying error (type: FileSystemError: 3 - [:] - The operation couldn’t be completed. (MinimalTSCBasic.FileSystemError error 3.) Usage: xcresulttool <subcommand> See 'xcresulttool --help' for more information. It might be that the environment set by Xcode is missing something but I cannot figure out what, any idea?
2
1
218
2w
How would you approach an Encryption Key being leaked?
I was curious as to the procedure for having an encryption key leaked and was hoping to have your opinions on how these two questions will be answered [if you were in the position]. Q1: Let's say, for instance, that you're making a social media network that stores private messages in a database network (such as Firebase) and uses basic encryption to store that data into an encrypted format (e.g., text message: "Hello Mous772!"; Firebase data: "deaErG5gao7J5qw/QI3EOA=="). But oh no! Someone got access to the encryption key used to encrypt hundreds of thousands of messages. You cannot simply delete thousands of messages because of this hacker, so how should you deal with this? This is where my question comes in. Is it possible to change the encryption key for all of the data if I am using the code system at the bottom of this question and using that code system to store encrypted data in Firebase? If so, how would you go about doing that? (Please use simple language; I'm not good with this stuff). Q2: What, in your opinion, is the best way to prevent this in the first place? I was told that a good solution was to store two sets of the same data; when one kegs it, we shut down the original and use the backup; however, this does not sound sustainable at all. I want to know what steps can be taken to ensure this never happens. [Please don't give me "Well... you can never *really hide these keys!" I'm well aware it's not possible to never have them leaked ever; I'm just looking for best practices only.] This is the encryption system we are using for this hypothetical app. // MARK: Value // MARK: Private private let key: Data private let iv: Data // MARK: - Initialzier init?(key: String, iv: String) { guard key.count == kCCKeySizeAES128 || key.count == kCCKeySizeAES256, let keyData = key.data(using: .utf8) else { debugPrint("Error: Failed to set a key.") return nil } guard iv.count == kCCBlockSizeAES128, let ivData = iv.data(using: .utf8) else { debugPrint("Error: Failed to set an initial vector.") return nil } self.key = keyData self.iv = ivData } // MARK: - Function // MARK: Public func encrypt(string: String) -> Data? { return crypt(data: string.data(using: .utf8), option: CCOperation(kCCEncrypt)) } func decrypt(data: Data?) -> String? { guard let decryptedData = crypt(data: data, option: CCOperation(kCCDecrypt)) else { return nil } return String(bytes: decryptedData, encoding: .utf8) } func crypt(data: Data?, option: CCOperation) -> Data? { guard let data = data else { return nil } let cryptLength = data.count + key.count var cryptData = Data(count: cryptLength) var bytesLength = Int(0) let status = cryptData.withUnsafeMutableBytes { cryptBytes in data.withUnsafeBytes { dataBytes in iv.withUnsafeBytes { ivBytes in key.withUnsafeBytes { keyBytes in CCCrypt(option, CCAlgorithm(kCCAlgorithmAES), CCOptions(kCCOptionPKCS7Padding), keyBytes.baseAddress, key.count, ivBytes.baseAddress, dataBytes.baseAddress, data.count, cryptBytes.baseAddress, cryptLength, &bytesLength) } } } } guard Int32(status) == Int32(kCCSuccess) else { debugPrint("Error: Failed to crypt data. Status \(status)") return nil } cryptData.removeSubrange(bytesLength..<cryptData.count) return cryptData } } //let password = "UserPassword1!" //let key128 = "1234567890123456" // 16 bytes for AES128 //let key256 = "12345678901234561234567890123456" // 32 bytes for AES256 //let iv = "abcdefghijklmnop" // 16 bytes for AES128 //let aes128 = AES(key: key128, iv: iv) //let aes256 = AES(key: key256, iv: iv) //let encryptedPassword128 = aes128?.encrypt(string: password) //aes128?.decrypt(data: encryptedPassword128) //let encryptedPassword256 = aes256?.encrypt(string: password) //aes256?.decrypt(data: encryptedPassword256)
3
0
186
Oct ’24
Xcode 16 build warning
I encountered an issue when implementing the WKUIDelegate protocol and NSItemProviderWriting protocol. Below is a minimal example of the code that reproduces the issue: import UIKit import WebKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. } } class ItemProvider: NSObject, NSItemProviderWriting { static var writableTypeIdentifiersForItemProvider: [String] { fatalError() } func loadData( withTypeIdentifier typeIdentifier: String, forItemProviderCompletionHandler completionHandler: @escaping @Sendable (Data?, (any Error)?) -> Void ) -> Progress? { fatalError() } } extension ViewController: WKUIDelegate { func webView( _ webView: WKWebView, runJavaScriptAlertPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping @MainActor @Sendable () -> Void ) { fatalError() } } When implementing the WKUIDelegate protocol after NSItemProviderWriting protocol, the following warning appears: Instance method 'webView(_:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:)' nearly matches optional requirement 'webView(_:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:)' of protocol 'WKUIDelegate' The target's SWIFT_VERSION is 6.0.
0
0
162
Oct ’24
Command CodeSign failed with a nonzero exit code
I have not been able to open any of my apps since I uploaded my latest update midOctober 2023. Previously I have tried everything on forums from removing derived data, adding new options in build folder and more. Since then I have wasted hours trying to open any app from my iCloud / hard disk and I wonder if part of the problem is caused by backing up to iCloud, as I can open from an external hard disk. It takes almost as long to upload from hard disk than cloud so whole thing annoying, does this add clues to this frustrating problem ? Also when I opened one of my apps it had made hundreds of unassigned assets that all had to be removed individually. I have no idea how to continue with my work I have three other apps in progress, but am halted at present but such a stupid small detail. // here is full commet /Users/ruwickigmail.com/Desktop/0-APPS-2023/InstaAnimates/InstaAnimates.xcodeproj: warning: Unable to find a target which creates the host product for value of $(TEST_HOST) '/Users/ruwickigmail.com/Desktop/0-APPS-2023/InstaAnimates/DerivedData/InstaAnimates/Index.noindex/Build/Products/Debug-maccatalyst/InstaAnimates.app/Contents/MacOS/InstaAnimates' (in target 'InstaAnimatesTests' from project 'InstaAnimates') My bundle ID is fine but it crashes on loading so may be due to something in signing but everything looks fine. I note that there are hundreds of enquiries on the forums, but most are unanswered. as this is an regular Xcode Apple problem and there are hundreds of people being put of continuing with their apps could the Apple team look into this please.
1
0
329
Oct ’24
Xcode: All Pull Request Changes + Code Review
I have the newest Xcode and macOS. When I'm trying to check Pull Request changes then when I click on any changed/added file, then instead of view with file I see infinite spinner. This happened in all files. I've tried to reinstall Xcode, macOS, clone new repo. This feature works once per 10-20 tries. Also when I try to manually compare uncommitted changes to some commit in Code Review mode, then I don't see any changes and no error appears. When I use git command line command in terminal, everything works and I receive changes. What can I do to fix this problem? I've tried Xcode 16.1 beta, and I can't go back to Xcode 15. Anyone has this problem? Anyone has any ideas?
0
0
137
Oct ’24
ML model performance on iPhone test is always 0
Hi, Im using Xcode to test ML model performance. When I create a performance report on my Mac, I can get the performance report with prediction, load and Compilation time in ms. But when I tried to test the performance on iPhone16pro, although the test came to an end normally, but the prediction/load/compilation time are always 0, and there were no Compute Unit Mapping below. Thanks for your help.
0
0
132
Oct ’24
Cocoa: Simultaneous fullscreen toggle & opening of modal dialog fails
Does Cocoa have documentation that describes why this functionality is not supported? To try it out is simple, create a default application that uses Objective C in XCode, add a button that toggles the window into fullscreen and opens a modal save-as dialog at the same time. The fullscreen transition will half-complete but kick the application out of fullscreen instantly. Is this expected behavior? The test application is attached below. The XCode test application
1
0
175
Oct ’24
Conditionally compile newer API with older XCode
I made an update to my app's code to make use of the new Contact access limited permission (CNAuthorizationStatusLimited), like so: if (@available(iOS 18.0, *)) { switch ([CNContactStore authorizationStatusForEntityType:CNEntityTypeContacts]) { case CNAuthorizationStatusLimited: <snip> However, later I discovered there's another totally unrelated issue which only manifests when the app is built with XCode 16. It isn't a trivial change to workaround, so for now I would like to make a release to the app store which makes use of the new CNAuthorizationStatusLimited status but is built using XCode 15. However, building with XCode 15 results in a "Use of undeclared identifier 'CNAuthorizationStatusLimited' error. If the code were making use of a new API, I could workaround using a selector for example, however as this is an enum, is there Is there any workaround possible for this - or its just not possible to build using XCode 15 and the source code contain references to CNAuthorizationStatusLimited?
2
0
202
Oct ’24
Gradient rendering issue with alpha set to something other than one
Gradients with colors that have alpha are not rendered correctly anymore. I made a simple project to illustrate that. Just create Objective C project and paste this code inside the ViewController. `#import <UIKit/UIKit.h> @interface CustomView : UIView @property (nonatomic, strong) NSArray<NSNumber *> *colorsArray; // The color components array // Custom initializer that accepts an NSArray of color components (instancetype)initWithFrame:(CGRect)frame colors:(NSArray<NSNumber *> *)colorsArray; @end @implementation CustomView // Custom initializer (instancetype)initWithFrame:(CGRect)frame colors:(NSArray<NSNumber *> *)colorsArray { self = [super initWithFrame:frame]; if (self) { _colorsArray = colorsArray; // Store the colors array } return self; } (void)drawRect:(CGRect)rect { // Get the current context CGContextRef context = UIGraphicsGetCurrentContext(); // Convert NSArray to a C-style array of CGFloats size_t count = self.colorsArray.count; CGFloat colors[count]; for (size_t i = 0; i < count; i++) { colors[i] = [self.colorsArray[i] floatValue]; } // Create a color space CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); // Create the gradient with the passed colors CGGradientRef gradient = CGGradientCreateWithColorComponents(colorSpace, colors, NULL, count / 4); // Define the start and end points of the gradient CGPoint startPoint = CGPointMake(rect.origin.x, rect.origin.y); CGPoint endPoint = CGPointMake(rect.origin.x, rect.origin.y + rect.size.height); // Draw the rectangle with the gradient CGContextSaveGState(context); CGContextAddRect(context, rect); CGContextClip(context); CGContextDrawLinearGradient(context, gradient, startPoint, endPoint, 0); CGContextRestoreGState(context); // Release resources CGGradientRelease(gradient); CGColorSpaceRelease(colorSpace); } @end @interface ViewController : UIViewController @end @implementation ViewController (void)viewDidLoad { [super viewDidLoad]; // Get the screen bounds CGRect screenBounds = [UIScreen mainScreen].bounds; // Define the size of each custom view CGFloat customViewWidth = screenBounds.size.width * 0.75; CGFloat customViewHeight = screenBounds.size.height * 0.75; // Define a dynamic set of colors for the first custom view (red to blue) NSArray<NSNumber *> *colorsArray1 = @[ @1.0, @0.0, @0.0, @1.0, // Red @0.0, @0.0, @1.0, @1.0 // Blue ]; // TODO: This is the bug, there is no transparency NSNumber *alpha = @0.0;// this is the ***** bug **** // Define a dynamic set of colors for the second custom view (green to yellow) NSArray<NSNumber *> *colorsArray2 = @[ @0.0, @1.0, @0.0, alpha, // Green @1.0, @1.0, @0.0, @1.0 // Yellow ]; // Calculate the position for the first view (centered horizontally and vertically, with slight offset) CGRect frame1 = CGRectMake((screenBounds.size.width - customViewWidth) / 2 - customViewWidth * 0.25, (screenBounds.size.height - customViewHeight) / 2 - customViewHeight * 0.25, customViewWidth, customViewHeight); CustomView *customView1 = [[CustomView alloc] initWithFrame:frame1 colors:colorsArray1]; // Calculate the position for the second view (slightly shifted from the first view to partially overlap) CGRect frame2 = CGRectMake((screenBounds.size.width - customViewWidth) / 2 + customViewWidth * 0.25, (screenBounds.size.height - customViewHeight) / 2 + customViewHeight * 0.25, customViewWidth, customViewHeight); CustomView *customView2 = [[CustomView alloc] initWithFrame:frame2 colors:colorsArray2]; // Set autoresizing so they adjust with the screen size customView1.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; customView2.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; // Add the custom views to the view controller's view [self.view addSubview:customView1]; [self.view addSubview:customView2]; } @end`
3
0
184
Oct ’24