-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Description
New Issue Checklist
🚫 If this template is not filled out your issue will be closed with no comment. 🚫
- I have looked at the DocumentationI have filled out this issue template.To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
Issue Info
Info | Value |
---|---|
Platform | ios |
Platform Version | 9.X & 10.X |
Masonry Version | 1.1.0 |
Integration Method | cocoapods |
Issue Description
Crash: -[UIView mas_bottomMargin]: unrecognized selector sent to instance 0x7fe34460a6a0
Possibly other margin methods too.
Worked with Masonry v1.0.2
Edit:
[UIView mas_bottomMargin]
was working with Masonry 1.0.2 in XCodes 8.3.3 (8E3004b) and 9.0 (9A235), tested in devices and simulators iOS 9.X and 10.X.
Using Masonry v1.1.0 crashes with unrecognized selector, in any of the XCodes and simulators mentioned above, even after Project -> clean + clean build folder + manually deleting derived data.
I'm using MAS_SHORTHAND_GLOBALS
A quick difference I see is in View+MASAdditions.h
, when defining mas_xxxMargin
, its within conditional block:
- Masonry v1.0.2:
#if TARGET_OS_IPHONE || TARGET_OS_TV
- Masonry v1.1.0:
#if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000)
My application's __IPHONE_OS_VERSION_MIN_REQUIRED
is 90000
Edit 2:
I downloaded the repo and ran the Example project's Margins
example and it did not crash.
I then decided to create a simple test project to try and reproduce the crash and I was able to.
My test project consisted of a Podfile with only Masonry 1.1.0 pod:
platform :ios, '9.0'
target 'test' do
pod 'Masonry', '1.1.0'
end
My project's deployment target was 9.0 (and afterwards tested with 10.3), a single view controller with this code:
#import <Masonry/Masonry.h>
...
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIView *tmp = [[UIView alloc] init];
tmp.backgroundColor = [UIColor blueColor];
[self.view addSubview:tmp];
[tmp mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(self.view);
make.height.equalTo(@20);
make.bottom.equalTo(tmp.superview.mas_bottomMargin);
}];
}
Crash:
2017-09-21 12:52:31.898 test[47946:212235] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView mas_bottomMargin]: unrecognized selector sent to instance 0x7ffcdda05420'
*** First throw call stack:
(
0 CoreFoundation 0x000000010b0c4b0b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010ab29141 objc_exception_throw + 48
2 CoreFoundation 0x000000010b134134 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x000000010b04b840 ___forwarding___ + 1024
4 CoreFoundation 0x000000010b04b3b8 _CF_forwarding_prep_0 + 120
5 test 0x0000000108ca5940 __29-[ViewController viewDidLoad]_block_invoke + 608
6 test 0x0000000108cb7ada -[UIView(MASAdditions) mas_makeConstraints:] + 138
...
Edit 3:
Sample project: test.zip
Edit 4:
As @robertjpayne said, use_frameworks!
could be used as workaround if you are able to (which isn't my case).
I've researched a bit more and found that, even though my Podfile states I target iOS 9, each individual pod has its own deployment target. I checked the Masonry pod and found it is targeting iOS 6, leading to the crash. My workaround was setting each pod minimum deployment target equal to my project's with a post install hook as such:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
end
end
end
Reference: https://stackoverflow.com/a/37289688/1077288
Activity
beloso commentedon Sep 20, 2017
It happens with me too
robertjpayne commentedon Sep 21, 2017
This doesn't make much sense as the code here has hardly changed at all… Does it work with Xcode 9 and Masonry 1.0.2?
ghost commentedon Sep 21, 2017
Xcode 9.0 + Masonry 1.1.0 crashes, Clean -> Build, then goes OK, confused.
robertjpayne commentedon Sep 21, 2017
@guofengld so it doesn't crash once you do a full clean + build? Sounds like a weird Xcode issue
jonz-tech commentedon Sep 21, 2017
xcode 8.3.3 build the lasted version will cash when use XXXMargin . so i don't think so it's a weird xcode issuse.
robertjpayne commentedon Sep 21, 2017
@jonz-tech have you tried a full clean? Including deleting your DerrivedData folder? It seems super suspicious because nothing about these API's changed.
ghost commentedon Sep 21, 2017
@robertjpayne "ios deployment_target" was set to "6.0", so __IPHONE_OS_VERSION_MIN_REQUIRED equals to 60000, mas_leftMargin、mas_rightMargin were not implemented, but they were declared 😂
jonz-tech commentedon Sep 21, 2017
i had try. here is my issue.
#460
i had checked your project .it seems nothing change, and still cause some problem.
does the implement was missing in podspec?
CristianoCastro commentedon Sep 21, 2017
Updated issue to add some info about Xcode, devices tested and configurations
robertjpayne commentedon Sep 21, 2017
@CristianoCastro super helpful thank you, I have no idea why it's letting the header go through but not the API, gah!
robertjpayne commentedon Sep 21, 2017
@CristianoCastro just one last question -- does it crash on device? Or just simulators?
robertjpayne commentedon Sep 21, 2017
Hrm I'm not really sure what to say here, if I clone this project and run the Masonry iOS Examples and tap into the
Margins
example it doesn't crash.This is with shorthand mode on.
Whats your min deployment target set to?
beloso commentedon Sep 21, 2017
It crashes on simulators as well. We are testing our UI on the iPhone X simulator and it crashes there.
robertjpayne commentedon Sep 21, 2017
@beloso can you try just downloading the .tar.gz of the v1.1.0 release and running the examples and tapping into the margins example?
I can't replicate the crash on my end…
CristianoCastro commentedon Sep 21, 2017
@robertjpayne updated issue to include results of running the example
Margins
and a test project17 remaining items
CristianoCastro commentedon Sep 28, 2017
@robertjpayne the test project is working now when using the master branch, tested in XCode 9 on iOS 10 & 11. Though I have warnings about some enumerations in masonry being partial (I don't recall if they are new or not)
hhyymm commentedon Oct 23, 2017
cocoapods
Masonry Version | 1.1.0
iOS Simulator 8.4 && 11.0
Xcode 8.3.3 + Xcode9.0
Podfile use setting blow
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '8.0'
end
end
end
It works well
robertjpayne commentedon Oct 24, 2017
@CristianoCastro did you ever find a way around the warnings?
CristianoCastro commentedon Oct 25, 2017
@robertjpayne I didn't research the subject further due to a deadline and the cocoapods workaround of setting each target's IPHONEOS_DEPLOYMENT_TARGET doing the trick
xingheng commentedon Oct 31, 2017
I don't think this is an issue related cocoapods, the cocoapods uses the main app project's deployment target when running
pod install
at the first time only, AFAIK. However, this library's deployment target is iOS 6.0 in the podspec file, then the precompiler should support all the above iOS systems. The margins (leftMargins
andbottomMargin
) is supported on iOS 8 only, those symbols shouldn't be occurred in the main project code which has an iOS 6/7 deployment target. It should be a kind of compiling error there.The new introduced macros in 1.1.0 get the hint.
#if TARGET_OS_IPHONE || TARGET_OS_TV
@robertjpayne
Rogerlin2013 commentedon Apr 17, 2018
@xingheng Can't agree you more
godera commentedon Apr 24, 2018
@robertjpayne when adding files to project, i take no error. But podding it cause 'unrecognized selector sent to instance xxx'.
Lucashuang0802 commentedon Jun 28, 2018
@xingheng so do we have a solution here?
Suncoldx333 commentedon Sep 6, 2018
by command "pod install --verbose", I find cocoapods install masonry with 6.0 which decided in Masonry.podspec
so click Pods->Masonry, search "deployment target" in "Build Settings", check if it is 6.0, and choose version you want
ghost commentedon Dec 27, 2018
This one fixes the Crash, Thanks! @Suncoldx333
The iOS Deployment Target is changed to "iOS 6.0", Change back to 8.0 or higher works for me
xingheng commentedon Dec 27, 2018
@Suncoldx333 I don't think that's a good fix, the
Pods/Pods.xcodeproj
is under thePods
directory which is added to.gitignore
in SCM in general, becausecocoapods
manages the project file via automation completely.Suncoldx333 commentedon Dec 27, 2018
yes you are right. what I did will be nothing after pod install. and I think this issue has been solved when @CristianoCastro share the Edit 4, just add those code into podfile.
ghost commentedon Dec 27, 2018
I notice there is a Waring for my project after pods install, Xcode 10 will automatically change

iOS deployment target to the right one.
RbBtSn0w commentedon Sep 13, 2019
So, how about now?
desperadocarl commentedon Aug 4, 2021
So, how about now? confused!